digitalmars.D - toImpl deprecated, use opCast instead?
- Manu <turkeyman gmail.com> Jun 07 2012
--20cf302074baacbe5204c1e21e7a
Content-Type: text/plain; charset=UTF-8
Seriously?
I perceive to!T and cast(T) as fundamentally different operations. How can
opCast correctly perform the role of to! ?
cast() is a low level type cast, to! implies a conversion of some kind. If
you have a pointer type, I assume cast to operate on the pointer, and to!
to perform a conversion of the thing it represents.
to!int("12345") or cast(int)"12345"
to!JSONValue(obj) or cast(JSONValue)obj
cast(string)obj <- appears to be a primitive cast operator, communicates
nothing to me about the expected format of the string produced
The cast approach feel really wrong to me...
I need to do conversion between some fairly complex types. to! feels
appropriate, but cast() just seems weird...
Have I missed something?
--20cf302074baacbe5204c1e21e7a
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
Seriously?<div><br></div><div>I perceive to!T and cast(T) as fundamentally =
different operations. How can opCast correctly perform the role of to! ?</d=
iv><div>cast() is a low level type cast, to! implies a conversion of some k=
ind. If you have a pointer type, I assume cast to operate on the pointer, a=
nd to! to perform a conversion of the thing it represents.</div>
<div><br></div><div>to!int("12345") =C2=A0or =C2=A0cast(int)"=
;12345"</div><div>to!JSONValue(obj) =C2=A0or =C2=A0cast(JSONValue)obj<=
/div><div>cast(string)obj =C2=A0<- appears to be a primitive cast operat=
or, communicates nothing to me about the expected format of the string prod=
uced</div>
<div><br></div><div>The cast approach feel really wrong to me...</div><div>=
<br></div><div>I need to do conversion between some fairly complex types. t=
o! feels appropriate, but cast() just seems weird...</div><div>Have I misse=
d something?</div>
--20cf302074baacbe5204c1e21e7a--
Jun 07 2012








Manu <turkeyman gmail.com>