On Mon, 03 Jan 2011 17:23:29 -0500, Adam Ruppe <destructiona...@gmail.com>
wrote:
Over the weekend, I attacked opDispatch again and found some old
Variant bugs were killed. I talked about that in the Who uses D
thread.
Today, I couldn't resist revisiting a dynamic kind of object, and
made some decent progress on it.
http://arsdnet.net/dcode/dynamic.d
(You can compile that; there's a main() at the bottom of that file)
It isn't quite done - still needs op overloading, and probably better
errors, but it basically works.
It works sort of like a Javascript object.
[snip]
I've been working on an update to both std.json and std.variant. Previews
of both are available here:
https://jshare.johnshopkins.edu/rjacque2/public_html/
though they are still works in progress. Two of the big enhancements that
you might be interested in are call support and opDispatch + reflection +
prototype structs. To paraphrase your example:
Variant v;
v.a( 10 );
assert(v.a == 10);
v.a( { writefln("hello, world"); } );
v.a.call; //To be replaced by opCall, once struct opCall is fixed
(Bug 4053)
v.a( delegate void(string a, int x) { foreach(i;0..x) writeln(i+1,"
",a); } );
v.a("potatoes", 3);
I've also stubbed out a prototype style object, but I haven't really
tested it yet. Thoughts, comments and use/test cases are always welcomed.