On 12/21/15 3:47 PM, anonymous wrote:
On 21.12.2015 21:20, Steven Schveighoffer wrote:
This seems like an incorrect feature then. Why wouldn't I want S to be
treated like any other const(char)*? Seems like it's explicitly saying
"treat this like a const(char)*"

To my understanding, `alias this` means "is implicitly convertible to
X", and not "is the same thing as X".

That is, `is(S == const(char)*)` is false, but `is(S : const(char)*)` is
true. It makes sense to me that isPointer behaves like the `==` variant.

And for sure, the `alias this` doesn't make S interchangeable with a
pointer. S may have a different size, the pointer may not be at a zero
offset in S, etc.

I'm not saying that isPointer should return true, I'm saying that it shouldn't be used here.

For the phobos code in question it comes down to what's less surprising,
I guess. Having such an `alias this` resolved before stringification, or
not. I'm not sure.

I think the issue here is the way the code determines it should use std.format. My preference is:

1. if the struct defines toString, then use std.format which will call that.
2. else if the struct aliases itself to some other type handled here, use that branch
3. else, use std.format anyway, and whatever happens happens.

-Steve

Reply via email to