Objective-D, reflective programming, dynamic typing

dsimcha dsimcha at yahoo.com
Sun Apr 5 09:28:57 PDT 2009


== Quote from Andrei Alexandrescu (SeeWebsiteForEmail at erdani.org)'s article
> Christopher Wright wrote:
> > Andrei Alexandrescu wrote:
> >> Christopher Wright wrote:
> >>> What information did you find that you needed but is not available in
> >>> TypeInfo?
> >>
> >> To have constant-type dispatching without limitations you need the
> >> static type information.
> >
> > What do you mean by this? At first I thought you meant that TypeInfo
> > does not contain sufficient information to determine whether something
> > is const or immutable, but that is not the case. If you wish to convert
> > a Variant of a mutable thing to a const version of it, then you can
> > check whether the type you get is convertible, and without any trouble
> > -- the template instantiation to get the appropriate type will provide
> > the TypeInfo you need.
> >
> > So what's the issue?
> You may want to peruse the std.variant implementation. Variant is a
> struct containing a buffer for the data and a pointer to function. The
> function is a dispatcher for a handful of primitive operations.
> The pointer to function is assigned from the address of a function
> template. To get that address, you need the static type. That's the
> necessity.
> It's a very fast and very flexible design, but it does need the static
> type during initialization.
> Andrei

Have you used std.variant at all lately?  I think it's succumbed to bit rot as D2
has evolved, because various strange things happen when I try to use it.  If it's
not on the agenda to be completely revamped for the new Phobos anyhow, I'll look
into these errors in more detail and file some bug reports and patches.



More information about the Digitalmars-d mailing list