On Thursday, 24 May 2018 at 01:39:56 UTC, Jonathan M Davis wrote:
If you don't want an implict cast, then why did you declare an
alias this?
Because I wanted an inconvertible type which was exactly like the
int in the example but didn't want the implicit cast.
That's the whole point of alias this. If you want implicit
conversions, you use alias this. If you don't, you don't use
alias this. I don't understand why it would ever make sense to
declare an implicit conversion and then disable it.
I think it doesn't make sense to allow us to have any influence
on implicit casts. I don't think they should only be existant for
primitive types.
What if you had a struct with two ints and you coulc convert it
with an implicit cast into a different struct with two other
ints? For me it makes sense to want an implicit cast there.
Also, if you think that
Foo foo = 5;
is using an implicit cast, you're wrong. That's just calling
the constructor
I know, but 'writeln(foo)' compiles and runs but
'writeln(cast(int) foo)' does not