Templates and stringof...

David Nadlinger see at klickverbot.at
Fri Aug 3 15:47:50 PDT 2012


On Friday, 3 August 2012 at 22:23:23 UTC, Era Scarecrow wrote:
>  Seems like an ugly hack though (to get this done). Why not 
> have another method of fullpathStringof or something similar? 
> Then again if this is one of the few cases that could benefit 
> from it, then maybe we should make it ugly so no one else will 
> use it.

This can't work in general. What should such a function return? 
The fully qualified name, i.e. including packages and modules? 
What is if the referred to entity is a nested function/local 
variable? What is if it is defined in a module which is not 
imported in the place where the string is mixed in?

Regarding Philippe Sigaud's stuff: He has done a lot of great 
work, but exactly this use of strings is why some of his template 
constructions are not usable in the real world. Again, using 
.stringof in conjunction with string mixins is almost never a 
good idea. Please trust me on this, I've done quite a bit of 
metaprogramming-heavy projects, and there are always ways around 
this, which are often more elegant as well.

David


More information about the Digitalmars-d-learn mailing list