Signals and Slots in D
Don Clugston
dac at nospam.com.au
Fri Sep 29 02:59:41 PDT 2006
Walter Bright wrote:
> Bill Baxter wrote:
>> I think railroading Qt's S&S into a language is the wrong approach.
>> What goes into the language should be a more general mechanism on top
>> of which schemes like dynamic S&S can be easily built.
>
> I agree, and thanks for letting me know about the string matching.
> That'll become possible in D later when it gets more introspection
> abilities.
Some thoughts about introspection:
The most basic introspection would simply be, for each class and struct
Typeinfo, add a pointer to a string that's just a concatenation of names
and mangled types.
[name]\0[mangleof]\0[name]\0[mangleof]\0...[name]\0[mangleof]\0\0.
Since we have .alignof and .sizeof, this would allow all data members to
be identified; and would allow code to be developed that could do
serialization stuff. It would also be reasonably compact.
And an identical treatment for the functions in the vtable (just need to
maintain the same order of functions). Given a string XXX, you could
search for a function named "slotXXX" in the manglelist, and call the
corresponding entry in the vtable.
It wouldn't deal with static functions (where you need the address as
well as the name and type info)
I guess the challenging issue is to make sure that functions that aren't
referenced don't get type info stored? I imagine those dynamic
languages have trouble discarding unused functions at link time. I think
you'd need to tell the compiler "don't discard this function even if you
think it's not used, it's only referenced in a text string".
More information about the Digitalmars-d
mailing list