dmd 2.029 release

Daniel Keep daniel.keep.lists at gmail.com
Tue Apr 21 19:19:25 PDT 2009



Michel Fortin wrote:
> On 2009-04-21 11:18:39 -0400, Don <nospam at nospam.com> said:
> 
>> Yes. Actually, marking a nested function as pure doesn't make much sense.
>> It's entirely equivalent to moving it outside the function; a nested
>> pure function shouldn't be able to access any members of the enclosing
>> function, otherwise it's not pure. But DMD doesn't enforce that, and
>> so it creates inefficient and possibly buggy code.
> 
> What about immutable local variables? A pure function can access
> immutable globals, so it should be able to access immutable locals too.
> 

If you treat the nested function's context pointer as a pointer to a
struct matching the stack layout, then you can have pure nested
functions -- they have exactly the same semantics as a pure struct
member function.

  -- Daniel


More information about the Digitalmars-d-announce mailing list