Templates and stringof...

Era Scarecrow rtcvb32 at yahoo.com
Fri Aug 3 15:57:30 PDT 2012


On Friday, 3 August 2012 at 22:47:52 UTC, David Nadlinger wrote:
> 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?

  I would think, the exact 'text' of the way the variable was 
called, in my example it would be "inum.i", and since it would be 
at the local level (where the mixin was called) it should have 
access to everything that it did at that time.

> 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.

  I have limited experience making and using templates, so I'll 
have to believe you; But it still seems like there should be a 
much better way than an uber-ugly work around. One of the reasons 
I want to use an alias vs a string, is so I can use the 
constraints the way they are suppose to be.


More information about the Digitalmars-d-learn mailing list