On Friday, 19 August 2022 at 13:47:41 UTC, Paul Backus wrote:
On Friday, 19 August 2022 at 10:22:25 UTC, bauss wrote:
Is there a reason why .stringof is implementation defined and
not clearly defined in the spec how types and declarations
should be treated when being "converted to a string"?
I find it really odd that it's implementation defined and you
essentially can't rely on it anywhere.
It's something that has baffled me a lot.
Like are there something I'm missing that means it cannot be
specified?
Basically, `.stringof` is what the compiler uses when it needs
to display something in an error message. If it were locked
down in the spec, then making improvements to error messages
would in some cases require a deprecation cycle.
That said, it might still be worth specifying the behavior in a
few specific cases—e.g., guaranteeing that `.stringof` on an
integer value will always produce a valid integer literal.
Yeah I mean not all of its behavior has to be implementation
defined.