struct : implicit conversion for function call arguments
Jonathan M Davis
jmdavisProg at gmx.com
Tue Jan 1 16:11:54 PST 2013
On Wednesday, January 02, 2013 00:37:32 d coder wrote:
> > That's not how you define implicit conversions in D. It's a weird hack
> > from C++.
>
> Thanks for clarification. I knew about alias this, but I thought it was in
> addition to constructor path.
Nope. It's the _only_ way to define implicit conversions in D. In general, D
requires explicit conversions in order to avoid all of the problems that
implicit conversions cause in C++ (e.g. C++ will do up to 3 implicit
conversions when passing an argument to a function; that gets particularly
nasty when combined with function overloading; you can quickly have no idea
what's actually being called without stepping through the code).
- Jonathan M Davis
More information about the Digitalmars-d
mailing list