getAttr method

downs default_357-line at yahoo.de
Fri Feb 1 11:33:28 PST 2008


bearophile wrote:
> Michiel Helvensteijn:
>> PHP has something similar.
> 
> I use that in Python, so I know that (once in while) it can be useful in Python code.
> But what I don't understand how much good it can be in a static language like D. I think Python has many other features that can be more useful for D (likes list comprehensions, generators, and few other syntactically sugared things, that ShedSkin translates to C++ quite well).
> 

Well, generators are available as add-on libraries; StackThreads form a superset of them :)

the following code is entirely valid D if you have scrapple.tools installed:
auto generator = stackthread = (void delegate(int) yield) { int i; while (true) yield(i++); };
writefln(generator(), generator(), generator());

Except that probably won't work on a stock phobos, because win32's MmFile is broken (patch in bugzilla), and the GC can be made to work with StackThreads but it's horribly inefficient, which is why scrapple.tools currently only works with the GC patch posted above. Sorry. But hey, maybe it or a similar patch will eventually be integrated into phobos!
:cue laugh track:
Yeah I know. But I still have a few specks of hope left. Call me stupid :)

> Bye,
> bearophile

 --downs



More information about the Digitalmars-d mailing list