The worst Phobos template (in binderoo)

David Nadlinger via Digitalmars-d digitalmars-d at puremagic.com
Wed Sep 14 16:11:44 PDT 2016


On Wednesday, 14 September 2016 at 22:48:29 UTC, Pierre Krafft 
wrote:
> I've had to use fullyQualifiedName in some string mixins.

Unless there is more to the example than what meets the eye, "had 
to" isn't quite true, and even with the `import moduleName!…` 
hack, your code is still unnecessarily restrictive. Just use ` ~ 
"fromJSON!(typeof(t." ~ name ~ "))…"` instead.

I'd really like to know where the notion that stringifying 
symbols for mixin code generation is a viable choice comes from. 
People seem to try with an irritating regularity, only to 
inevitably discover that it doesn't actually work some time 
later. That one can get dangerously close now that we have 
`moduleName` doesn't exactly help either.

  — David


More information about the Digitalmars-d mailing list