Potential abuse of .stringof
Mike via Digitalmars-d
digitalmars-d at puremagic.com
Tue Jun 9 17:09:48 PDT 2015
I am a little concerned about the discussion here
(https://github.com/D-Programming-Language/phobos/pull/3394#discussion_r31953154)
pertaining to the usage (or abuse) of .stringof.
[1]
https://github.com/D-Programming-Language/phobos/pull/3394#discussion_r31953154
JC: I've been told that stringof shouldn't be used for anything
other than debugging. Is there something else that can be used?
There's no guarantee that the result is stable?
AA: there was no other way I could do it
ML: A lot of the time there really is no other way. A large
amount of code in this vein that I've written invariably ends up
needing stringof as well. Maybe we should provide stronger
guarantees about what stringof produces.
AA: Well it'll break the unittests that's for sure :). The
problem here is with the function parameter lists. There is no
way to express storage classes such as ref, out, lazy as parts of
types.
I also think .stringof for types should offer better guarantees.
The simplest one is, for non-Voldemort types, pasting the string
into source code should be parsable as a type. Today that's not
always the case.
I smell an action item here. What can be done to make this less
of "There's no other way to do it" and more "That's how it should
be done"?
Mike
More information about the Digitalmars-d
mailing list