Page 1 of 1

Queues and Extension methods

PostPosted: Tue Jan 29, 2013 2:32 pm
by DelphiGuy
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?

Re: Queues and Extension methods

PostPosted: Tue Jan 29, 2013 11:14 pm
by DelphiGuy
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

Re: Queues and Extension methods

PostPosted: Wed Jan 30, 2013 10:14 am
by nerdzero
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.

Re: Queues and Extension methods

PostPosted: Wed Jan 30, 2013 7:31 pm
by DelphiGuy
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.

Re: Queues and Extension methods

PostPosted: Thu Jan 31, 2013 11:12 am
by nerdzero
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

Re: Queues and Extension methods

PostPosted: Mon Feb 04, 2013 11:43 pm
by nerdzero
The MonoDevelop addin now correctly supports package references. Muchas gracias for bringing the bug to my attention.