Forums

Queues and Extension methods

General discussion about Cobra. Releases and general news will also be posted here.
Feel free to ask questions or just say "Hello".

Queues and Extension methods

Postby DelphiGuy » Tue Jan 29, 2013 2:32 pm

i'm trying to compile the following code under Win 7 monodevelop:

Code: Select all
myQueueInstance.dequeue
myQueueInstance.elementAt(2)


MD is fine with compiling and running the dequeue line, but never heard of "elementAt".

i see that "elementAt" is an "extension method": http://msdn.microsoft.com/en-us/library/7977ey2c.aspx

if my problem is syntax, then what syntax shall i use in order to call an extension method, please?
Last edited by DelphiGuy on Tue Jan 29, 2013 11:14 pm, edited 1 time in total.
DelphiGuy
 
Posts: 116

Re: Queues and Extension methods

Postby DelphiGuy » Tue Jan 29, 2013 11:14 pm

from: http://msdn.microsoft.com/en-us/library/bb299233.aspx

Namespace: System.Linq
Assembly: System.Core (in System.Core.dll)


so i added

Code: Select all
use System.Linq


to my code, because i couldn't remember offhand if that's provided as a default in cobra.

then i made a checkmark next to MD's "references" >> "edit references" >> "all" >> "System.Core"

this resulted in the dreaded "cobra internal error" when i tried to rebuild:

error: cobra internal error / win32 exception / the system cannot find the file specified
DelphiGuy
 
Posts: 116

Re: Queues and Extension methods

Postby nerdzero » Wed Jan 30, 2013 10:14 am

See here: viewtopic.php?f=4&t=1065&p=5429

As for the reference to System.Core, one is implicitly put in there for you by the MD addin when you compile so certain classes like HashSet<of T> can be resolved. I'll try and reproduce the bug and see if the root cause is from the addin or from the compiler.
nerdzero
 
Posts: 286
Location: Chicago, IL

Re: Queues and Extension methods

Postby DelphiGuy » Wed Jan 30, 2013 7:31 pm

ok, thanks for the heads up. there's so much to learn about .net and cobra!

let me know if you need any further code from me in order to replicate.
DelphiGuy
 
Posts: 116

Re: Queues and Extension methods

Postby nerdzero » Thu Jan 31, 2013 11:12 am

Okay, well the System.Core reference issue has to do with trying to use the "-pkg" compiler option on Windows. The Cobra compiler tries to execute the "pkg-config" command which typically doesn't exist on Windows (expect maybe with a CygWin installation) so it dies with the message: "the system cannot find the file specified"; which is referring to the pkg-config command itself as opposed to any referenced assemblies.

This can be reproduced from the command line with any Cobra source file by executing

Code: Select all
cobra -pkg:foo <source_filename>


I think the MonoDevelop addin has enough information to try and detect a package reference on Windows/.NET and provide a better error message, or possibly find the actual assemblies contained in the package and instead pass in one or more "-ref" options to the compiler which means everything would work. I'll open a bug report on GitHub. Thanks, DelphiGuy.

Charles, not sure if you want the compiler to provide a more descriptive error message or check to see .isRunningOnMono before trying to execute pkg-config. If so, I can open a ticket. I would guess the place to change is somehwhere around here: http://cobra-language.com/trac/cobra/br ... cobra#L714
nerdzero
 
Posts: 286
Location: Chicago, IL

Re: Queues and Extension methods

Postby nerdzero » Mon Feb 04, 2013 11:43 pm

The MonoDevelop addin now correctly supports package references. Muchas gracias for bringing the bug to my attention.
nerdzero
 
Posts: 286
Location: Chicago, IL


Return to Discussion

Who is online

Users browsing this forum: No registered users and 14 guests