July 23, 2007
The extended compile time reflection opens the door for all kinds of cool things! Here's an RTTI-Visitor, for instance.

It uses compile-time foreach to build a sequence of if-statements that check the classinfo and call the matching method.

Regards,
Christian

July 23, 2007
"Christian Kamm" <kamm.incasoftware@shift-at-left-and-remove-this.de> wrote in message news:f823if$1seh$1@digitalmars.com...
> The extended compile time reflection opens the door for all kinds of cool things! Here's an RTTI-Visitor, for instance.
>
> It uses compile-time foreach to build a sequence of if-statements that
> check
> the classinfo and call the matching method.
>
> Regards,
> Christian

That looks like multimethods.  :D


July 23, 2007
Congratulations!

With "signals and slots" and now traits it looks like D is ready for a GUI toolkit to be written for it, complete with drag-and-drop GUI builder รก la Qt Designer[1].

I can't wait to see that happen :-)

Bastiaan.

[1] http://trolltech.com/products/qt/features/designer


Walter Bright wrote:
> 
> http://www.digitalmars.com/d/1.0/changelog.html
> http://ftp.digitalmars.com/dmd.1.019.zip
> 
> http://www.digitalmars.com/d/changelog.html
> http://ftp.digitalmars.com/dmd.2.003.zip
July 23, 2007
"Christian Kamm" <kamm.incasoftware@shift-at-left-and-remove-this.de> wrote in message news:f823if$1seh$1@digitalmars.com...
> The extended compile time reflection opens the door for all kinds of cool things! Here's an RTTI-Visitor, for instance.
>
> It uses compile-time foreach to build a sequence of if-statements that
> check
> the classinfo and call the matching method.
>
> Regards,
> Christian

Cool, but it would be better to implement double dispatch than the Visitor pattern.  It is ultimately more efficient and more flexible.

-Craig


July 23, 2007
Very nice Walter!  Question about traits.  I'm guessing allMembers returns both functions and fields?  Is there an isField or isFunction to differentiate?

-Craig


July 23, 2007
> Cool, but it would be better to implement double dispatch than the Visitor pattern.  It is ultimately more efficient and more flexible.

It is simple to implement multiple dispatch using the same method as for the single dispatch example. The overhead is the same: two virtual function calls and some ifs doing address comparisons.

Might get less efficient or more complicated if you want to call the closest match instead of raising an error if there's no exact match.

Christian
July 23, 2007
Christian Kamm wrote:
> Thanks for fixing bug 668!
> 
> With the new __traits, the documentation for getVirtualFunctions states that
> it gets the "virtual overloads". What does that mean? If I make some of the
> methods final, it lists them anyway.

Final functions are still virtual (since the super classes are still calling it).

> Does it just get all overloads (and should be named getFunctionOverloads),
> or is there some limitation?

No, just the virtual functions.
July 23, 2007
Don Clugston wrote:
> I'm having trouble understanding the difference between "isScalar", "isArithmetic", and "isIntegral". Is this table correct?
> 
> int uint real wchar
> Y   Y    Y    N     isArithmetic
> N   N    Y    N     isFloating
> Y   Y    N    Y     isIntegral
> Y   Y    Y    Y     isScalar
> N   Y    N    N     isUnsigned
> 
> ----------------

wchar is arithmetic and unsigned.
July 23, 2007
Don Clugston wrote:
> extern(System) works on 2.003, but on 1.019, it prints:
> xxx.d(13): valid linkage identifiers are D, C, C++, Pascal, Windows

Oh crud, looks like I didn't fold that one in right.
July 23, 2007
Craig Black wrote:
> Very nice Walter!  Question about traits.  I'm guessing allMembers returns both functions and fields?  Is there an isField or isFunction to differentiate?

You can look at the types to see if they are data or functions. But probably more traits need to be added - I thought I'd wait on that to see just what was required, rather than throw in a lot of useless geegaws. It's hard to predict in advance.