Thread overview
Suggestion re opCast
May 30, 2004
Arcane Jill
Jun 01, 2004
Ivan Senji
Jun 01, 2004
Derek Parnell
May 30, 2004
Dunno what you think of this, but I suggest that opCast take a dummy argument. Like this:

>       int opCast(int dummy) { /+ stuff +/ }
>       double opCast(double dummy) { /+ stuff +/ }
>       char[] opCast(char[] dummy) { /+ stuff +/ }

You get the idea. When the expression cast(T) is encountered applying to some
object of class A, then A.opCast(T.init) is called. (The implementation of the
function will ignore the dummy value).

This would allow us to override opCast more than once, for multiple types. This would be very useful.

Jill


June 01, 2004
"Arcane Jill" <Arcane_member@pathlink.com> wrote in message news:c9dm4r$11mt$1@digitaldaemon.com...
>
> Dunno what you think of this, but I suggest that opCast take a dummy
argument.

opCast!!? I should be reading the change log more carefully!

> Like this:
>
> >       int opCast(int dummy) { /+ stuff +/ }
> >       double opCast(double dummy) { /+ stuff +/ }
> >       char[] opCast(char[] dummy) { /+ stuff +/ }
>

This would be nice to be able to have more of them.

> You get the idea. When the expression cast(T) is encountered applying to
some
> object of class A, then A.opCast(T.init) is called. (The implementation of
the
> function will ignore the dummy value).
>
> This would allow us to override opCast more than once, for multiple types.
This
> would be very useful.
>
> Jill
>
>


June 01, 2004
On Sun, 30 May 2004 22:10:35 +0000 (UTC), Arcane Jill wrote:

> Dunno what you think of this, but I suggest that opCast take a dummy argument. Like this:
> 
>>       int opCast(int dummy) { /+ stuff +/ }
>>       double opCast(double dummy) { /+ stuff +/ }
>>       char[] opCast(char[] dummy) { /+ stuff +/ }
> 
> You get the idea. When the expression cast(T) is encountered applying to some
> object of class A, then A.opCast(T.init) is called. (The implementation of the
> function will ignore the dummy value).
> 
> This would allow us to override opCast more than once, for multiple types. This would be very useful.
> 
> Jill

Agreed. When a coder enters 'cast(whatever)A', the author of the class that A belongs to needs to know how to convert an instance of the class into the requested type.


-- 
Derek
1/Jun/04 3:37:27 PM