stringof and mixins when the types aren't available

David Nadlinger code at klickverbot.at
Mon Jun 17 14:23:18 PDT 2013


On Monday, 17 June 2013 at 20:37:39 UTC, Dicebot wrote:
> As it should be, shouldn't it? That is the point of private. 
> Any workarounds can be very misleading.

Nah, I don't think so. For example let's assume you have a module 
A with a private struct MySuperSecretType. Now A wants to write 
instances of MySuperSecretType to disk, and it would be natural 
for a serialization library to be in another module B. But 
calling B.serialize(mySuperSecretInstance) won't work if 
serialize(T)(T t) tries to somehow access MySuperSecretType from 
outside instead of simply referring to its template parameter.

Trying to use the string identifier of symbols in mixin codegen 
is the "misleading workaround" here.

David


More information about the Digitalmars-d mailing list