Run Time Reflection
davidl
davidl at nospam.com
Tue Apr 13 20:13:21 PDT 2010
在 Sun, 11 Apr 2010 05:03:53 +0800,Daniel Ribeiro Maciel
<danielmaciel at gmail.com> 写道:
> Heya ppl!
>
> I've written a simple Compile Time (syntatic sugar mostly) and Run Time
> reflection library for methods only.
>
> It's not complete yet. I could not deal with certain issues in Run Time,
> such as ref/out function arguments, variadic function arguments. But
> it's mostly done.
>
> The problems are commented in the code.
>
> Naming conventions are bad and it is not properly modularized yet.
>
> I would welcome any input and I offer cooperation if you guys want to
> make a real time reflection library on phobos, or if anyone wants to
> make a more complete library, better structured library.
>
> In the meantime, I'll keep working on this.
>
> Best regards,
> Daniel
Great, i think if the metaobject disguise in a way acting exactly as the
original object it would be great. For example:
auto dmo = new reflect.MetaObject!Foo( foo );
Foo p = dmo;
I think this runtime reflection could be integrated into object.d
not every object necessarily become runtime reflexible. Just the base
object class provides a flag indicating if this object is actually a
runtime reflexible object. No other interface function would be added to
object which would bloat every object in D. The flag maybe extended for
other use as well. I know even adding a flag people would argue.
Next is providing a template function which is able to cast an object
which casted from MetaObject to the real object itself. I think it will be
better if the MetaObject!Foo actually derives Foo. Thus the cast could be
made easily. Then there's no barrier of passing a runtime reflexible
object to a library as it's a compiletime determined object, and deal with
it as a runtime reflexible object again later.
We may also want to treat every runtime reflexible object as one category
object which wouldn't work if the MetaObject derives different classes.
One possible solution is to make the MetaObject derives from the target
object type and also implements the general runtime reflexible interface.
We can manipulate all runtime reflexible object through a standardized
runtime reflexible interface. We can also cast those objects back towards
compiletime-determined object easily.
David L.
--
使用 Opera 革命性的电子邮件客户程序: http://www.opera.com/mail/
More information about the Digitalmars-d-announce
mailing list