More range woes: composed ranges are unsafe to return from functions

H. S. Teoh hsteoh at quickfur.ath.cx
Tue Oct 16 21:49:31 PDT 2012


On Tue, Oct 16, 2012 at 09:05:50PM -0600, Brad Anderson wrote:
> On Tue, Oct 16, 2012 at 2:54 PM, H. S. Teoh <hsteoh at quickfur.ath.cx> wrote:
[...]
> > So it seems like there is some kind of bad interaction between map
> > and joiner. Maybe as jethro said, it's wrong code produced by dmd
> > for the delegate passed to map? It seems to be dependent on the
> > reference to the local variable C, which seems to imply a corrupted
> > (or just out-of-scope?) delegate context.
[...]
> I'm starting to think maybe I shouldn't have closed my issue I reported
> awhile back:
> 
> http://d.puremagic.com/issues/show_bug.cgi?id=7978
> 
> I really need to read how closures are supposed to work.
[...]

Well, closures are *supposed* to give you access to the context of a
function that has gone out of scope -- usually implemented by allocating
the local variables referenced by the closure on the heap instead of the
stack. D is supposed to do this (TDPL, §5.8.1, p. 154). If dmd fails to
implement this, it's a bug.


T

-- 
It won't be covered in the book. The source code has to be useful for something, after all. -- Larry Wall


More information about the Digitalmars-d mailing list