Forums

Anonymous methods, also known as closures

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

Re: Anonymous methods, also known as closures

Postby jonathandavid » Sat Feb 07, 2009 3:30 pm

For the record:
I no longer think inline delegate declarations are necessary, because if one is lazy and don't want to declare the delegate on a separate line, one can use a generic delegate:

void foo(func as Converter<String, int>)   # Eq. to declaring a delegate "sig DelegateName(str as String)"
x = func("hi there")


Such generic delegates are provided by the .NET framework for most common scenarios (Func<> up to 4 params, and Action<> up to 4 params as well, where the difference is that Action has no return value). It would be interesting if Cobra provided its own version of such general purpose delegates, so that they can be used in other backends. By the way, Cobra seems to be able to consume generic delegates coming from a dll, but chokes when it sees one declared in a Cobra file. I don't know if that's a bug or a missing feature, but in any case it shouldn't be too hard to fix (I think the priority of that is low, though, since as I said .NET comes "preloaded" with all generic delegates that one might reasonably need).
jonathandavid
 
Posts: 159

Re: Anonymous methods, also known as closures

Postby Charles » Sun Feb 08, 2009 10:05 am

Sounds good.

Declaration of generic delegates in Cobra hasn't been tested. I'm sure the fix wouldn't be too bad.

Feel free to augment the wiki, if you like.
Charles
 
Posts: 2515
Location: Los Angeles, CA

Re: Anonymous methods, also known as closures

Postby jonathandavid » Sun Feb 08, 2009 11:56 am

I can take care of fixing the generic delegates thing, I'll assign myself a ticket if you think it's OK.

I'll probably write a wiki page about delegates as well. Do you think that's the proper place to talk about lambdas, or that lambdas should have a page of their own? I can use the term "anonymous methods" if you prefer.

BTW: I don't know how often you check the tickets but I've had some activity lately (tickets 145+ 146).
jonathandavid
 
Posts: 159

Re: Anonymous methods, also known as closures

Postby Charles » Mon Feb 09, 2009 4:30 am

Don't worry too much about the terminology or even structure. Just jot down a few notes as you think of them. We can expand and refactor the wiki as we go. I just want to encourage people to record their discoveries/learnings there.

I used to check tickets every day, but got busy the past couple weeks. I should be on a more regular schedule now. I have commented on both tickets.
Charles
 
Posts: 2515
Location: Los Angeles, CA

Previous

Return to Discussion

Who is online

Users browsing this forum: No registered users and 29 guests

cron