Foreach Closures?
Kapps
opantm2+spam at gmail.com
Mon Apr 9 06:44:08 PDT 2012
On Monday, 9 April 2012 at 13:19:32 UTC, Manu wrote:
> OMG, DO WANT! :P
> Who wrote this? I wonder if they'd be interested in adapting it
> to VisualD
> + MonoDevelop?
>
> On 9 April 2012 12:56, Ary Manzana <ary at esperanto.org.ar> wrote:
>
>> On 4/9/12 7:26 AM, Kevin Cox wrote:
>>
>>> I was wondering about the foreach statement and when you
>>> implement
>>> opApply() for a class it is implemented using closures. I
>>> was wondering
>>> if this is just how it is expressed or if it is actually
>>> syntatic
>>> sugar. The reason I aski is because if you have a return
>>> statement
>>> inside a foreach it returns from the outside function not the
>>> "closure".
>>>
>>> I was just wondering if anyone could spill the implementation
>>> details.
>>>
>>> Thanks,
>>> Kevin
>>>
>>
>> In this video you can see what foreach with opApply gets
>> translated to (at
>> about minute 1):
>>
>> http://www.youtube.com/watch?**v=oAhrFQVnsrY<http://www.youtube.com/watch?v=oAhrFQVnsrY>
That was Descent, a plugin for Eclipse. They did it by porting
DMD, with changes, to Java. A horribly painful task I'd imagine.
I wonder if it'd be easier by just creating bindings for DMD for
the language of choice.
That being said, if MonoDevelop's parser gets to the point where
it can evaluate this stuff well, I think that'd work just as
nicely. You won't quite be able to see the actual compiler's
representation of it, but you'd be able to expand mixins and such.
Note that Descent hasn't been updated in almost a year now
unfortunately.
More information about the Digitalmars-d
mailing list