Static foreach.
Jarrett Billingsley
kb3ctd2 at yahoo.com
Mon Nov 6 16:59:43 PST 2006
"Russ Lewis" <spamhole-2001-07-16 at deming-os.org> wrote in message
news:eiolhg$21va$1 at digitaldaemon.com...
> This looks to me like a good way to do reflection. Imagine that each
> variable had a property called "members" which returned the tuple of all
> of the members. Then dumping all of the members of a struct would be as
> simple as:
>
> foreach(member; this.members)
> writefln(member);
>
> Of course, if tuples were extended to include a "name" field, which was
> the name that was used to access the field, then we'd have everything:
>
> foreach(member; this.members)
> writefln(member.name," ",member);
>
> Of course, if we can do this, then we can do almost everything needed for
> reflection (especially if we are able to take the address of one element
> of a tuple, and that works out being the pointer to the member in the
> struct).
>
> Tuples aren't there yet, but they're close.
Wooooo! That's so tantalizing.
More information about the Digitalmars-d
mailing list