Interactive D?
Jari-Matti Mäkelä
jmjmak at utu.fi.invalid
Tue Feb 26 10:41:34 PST 2008
On Tue, 26 Feb 2008, Oskar Linde wrote:
> Jari-Matti Mäkelä wrote:
>> Some further ideas:
>>
>> catching exceptions, displaying the values and types of structs/classes and
>> their members recursively (if the default uses toString) -- hopefully this
>> will encourage Walter to fix some of the unspecified behavior with
>> .stringof, exporting the current state to a file, locating symbol
>> definitions.
>
> Catching exceptions actually already work:
Cool.
> Regarding stringof. The following is irritating, given:
>
> template A(T) { struct A {} }
> template B(T) { struct A {} struct B {} }
>
> A!(int) a;
> B!(int).B b;
>
> How do I reliably get the string representation of the type of a and b?
>
> There are two ways that I know of:
>
> 1. typeid(typeof(x)).toString
> 2. typeof(x).stringof
>
> The problem is that the results are:
>
> 1A: test.A!(int).A WRONG
> 1B: test.B!(int).B CORRECT
>
> 2A: A!(int) CORRECT (although not fully qualified)
> 2B: B WRONG
demangle(x.mangleof), x.init.stringof, and
typeid(typeof(x)).stringof) seem to be the only ways to return the full
FQN (including template member names) on compile time, but one needs to
have a demangle routine then first.
> Your other points are interesting and useful, but some of them are quite
> hard. I can't do much more than the D compiler can do at compile + runtime
> together.
The reflection stuff should be possible to do on compile time (only enums
fail). I'm not sure about exporting current state, now that I heard how
the utility works. Locating definitions is probably the hardest and needs
FQNs, maybe something more.
More information about the Digitalmars-d
mailing list