Re: static data in a sub-class

2012-12-22 Thread Ali Çehreli
On 12/22/2012 01:37 PM, Steve D wrote: > I will continue playing with your suggestions etc to see > what's cleanest. Both of those options have unnecessary costs. If everything is known at compile time, you can use the curiously recurring template pattern: import std.stdio; class A(SubT) {

Re: Reflection: Get all inherited classes of a base class

2012-12-22 Thread Jonathan M Davis
On Saturday, December 22, 2012 14:26:23 Jonathan M Davis wrote: > Best case, if each class > registered its existance when it was loaded into the environment (e.g with > a static constructor), then you could get a list of the classes which are > currently loaded, but that's not at all what you're a

Re: Reflection: Get all inherited classes of a base class

2012-12-22 Thread Jonathan M Davis
On Saturday, December 22, 2012 23:14:28 nrgyzer wrote: > Hi everyone, > > is it possible to get a list of all inherited classes from a base > class like this: > > class A { > ... > } > class B : A { > ... > } > class C : A { > ... > } > class D : B { > ... > } > > auto myClasses

Re: Reflection: Get all inherited classes of a base class

2012-12-22 Thread Adam D. Ruppe
On Saturday, 22 December 2012 at 22:14:28 UTC, nrgyzer wrote: is it possible to get a list of all inherited classes from a base class like this: Yes, though it isn't compile time - gotta be runtime. ClassInfo[] getChildClasses(ClassInfo c) { ClassInfo[] info; // MoudleInfo is

Re: static data in a sub-class

2012-12-22 Thread Steve D
On Saturday, 22 December 2012 at 21:14:58 UTC, Ali Çehreli wrote: On 12/22/2012 12:44 PM, Steve D wrote: Hello, How can I get class B's array printed, using inherited A's function? (Dmd 2.060) class A { static float[3] hi = 1; void f() { writefln("hi %s",hi); } } class B : A { static float[

Re: static data in a sub-class

2012-12-22 Thread Steve D
On Saturday, 22 December 2012 at 21:04:47 UTC, Jonathan M Davis wrote: On Saturday, December 22, 2012 21:44:33 Steve D wrote: Hello, How can I get class B's array printed, using inherited A's function? (Dmd 2.060) class A { static float[3] hi = 1; void f() { writefln("hi

Re: A pass() identity range?

2012-12-22 Thread Ali Çehreli
On 12/22/2012 12:55 AM, bearophile wrote: > To help writing/improving/debugging such code maybe it's useful to > create a pass() range in Phobos. I liked the idea yesterday but I thought that the name was a little off. How about a name like tap()? We tap into data as it's flowing through? Ali

Re: static data in a sub-class

2012-12-22 Thread Ali Çehreli
On 12/22/2012 12:44 PM, Steve D wrote: Hello, How can I get class B's array printed, using inherited A's function? (Dmd 2.060) class A { static float[3] hi = 1; void f() { writefln("hi %s",hi); } } class B : A { static float[3] hi = 2; } B b = new B(); b.f(); // prints 'hi [1,1,1]' // can I g

Re: static data in a sub-class

2012-12-22 Thread Jonathan M Davis
On Saturday, December 22, 2012 21:44:33 Steve D wrote: > Hello, > How can I get class B's array printed, using inherited A's > function? (Dmd 2.060) > > class A { > static float[3] hi = 1; > > void f() { writefln("hi %s",hi); } > } > > class B : A { > st

static data in a sub-class

2012-12-22 Thread Steve D
Hello, How can I get class B's array printed, using inherited A's function? (Dmd 2.060) class A { static float[3] hi = 1; void f() { writefln("hi %s",hi); } } class B : A { static float[3] hi = 2; } B b = new B(); b.f(); // prints 'hi [1,1,

Re: A pass() identity range?

2012-12-22 Thread bearophile
See also: http://tech.blinemedical.com/debugging-piped-sequences-f/ Bye, bearophile

Re: A pass() identity range?

2012-12-22 Thread monarch_dodra
On Saturday, 22 December 2012 at 08:55:35 UTC, bearophile wrote: I sometimes write code like: auto data = File("data.txt") .byLine() .map!(r => r.strip().dup)() .filter!(r => !r.empty)() .array(); To help writing/improving/debugging such code may

Re: Help me write "saveAll"

2012-12-22 Thread monarch_dodra
On Saturday, 22 December 2012 at 02:58:16 UTC, Timon Gehr wrote: On 12/21/2012 06:01 PM, monarch_dodra wrote: There are a lot of algorithms in std.algorithm that operate on "foo(Range, Needles...)(Range range, Needles needles)". Needles can be anything, in particular, either an "element" or a

A pass() identity range?

2012-12-22 Thread bearophile
I sometimes write code like: auto data = File("data.txt") .byLine() .map!(r => r.strip().dup)() .filter!(r => !r.empty)() .array(); To help writing/improving/debugging such code maybe it's useful to create a pass() range in Phobos. It's like a "i