Probably trivial, but VERY frustrating compiler bug
Steven Schveighoffer
schveiguy at gmail.com
Fri Aug 14 13:51:42 UTC 2020
On 8/14/20 9:16 AM, Adam D. Ruppe wrote:
> On Friday, 14 August 2020 at 12:47:01 UTC, Steven Schveighoffer wrote:
>> As of now, there are three ways the compiler can give you names of a
>> type:
>
> I actually personally use .mangleof when it doesn't have to be user
> visible... and if it does, I'll just demangle parts of it (the first
> part for the name is very simple, it is decimal-length-prefixed strings,
> then you join them back with dot and you're done, it is the type info at
> the end of the string that gets complicated to demangle).
I forgot about mangleof! A 4th string representation. But this one is
well defined, and unrelated (mostly) to the other 3.
>
> It is pretty well defined and has certain guarantees for linking.
Yes, it depends on the use case for sure.
> That said, I'd probably be ok with improving the definitions! I'd still
> tell people to never use it in mixins but it'd at least be ok for cases
> like this then.
Using it in mixins is not a good idea anyway. If you have the type alias
locally, use that.
But a consistent string representation would at least allow one to do
*something* with that information.
In particular, if .stringof and typeid(classInstance).name were
consistent, it would make things a lot easier.
That brings up another use case -- RTTI. Like if you wanted to implement
Object.factory. A language-sanctioned way to say "when I use this
string, I mean this type" unambiguously.
-Steve
More information about the Digitalmars-d
mailing list