Thread overview
Casting syntax
Jun 08, 2004
Jeroen van Bemmel
Jun 08, 2004
Ant
Jun 08, 2004
J C Calvarese
Jun 08, 2004
Arcane Jill
Jun 09, 2004
Norbert Nemec
June 08, 2004
Since casting can be considered as invoking a function on an object, wouldn't it make sense to allow:

x.cast( int ) where x can be any object or scalar value?


June 08, 2004
On Tue, 08 Jun 2004 07:58:01 +0200, Jeroen van Bemmel wrote:

> Since casting can be considered as invoking a function on an object, wouldn't it make sense to allow:
> 
> x.cast( int ) where x can be any object or scalar value?

obviously,
but this was discussed before and rejected.

Ant

June 08, 2004
Ant wrote:
> On Tue, 08 Jun 2004 07:58:01 +0200, Jeroen van Bemmel wrote:
> 
> 
>>Since casting can be considered as invoking a function on an object, wouldn't it make sense to allow:
>>
>>x.cast( int ) where x can be any object or scalar value?
> 
> 
> obviously,
> but this was discussed before and rejected.
> 
> Ant

It has been mentioned before. It looks like a fine suggestion to me, but I don't care enough about it to fight for it. I like the cast(int) x syntax. I think that's good enough.

-- 
Justin (a/k/a jcc7)
http://jcc_7.tripod.com/d/
June 08, 2004
In article <ca3kiu$2r17$1@digitaldaemon.com>, Jeroen van Bemmel says...
>
>Since casting can be considered as invoking a function on an object, wouldn't it make sense to allow:
>
>x.cast( int ) where x can be any object or scalar value?

Sure. Another nice one is (one of the many ways that) C++ does it:

>        int(x)

That to me is the ultimate in simplicity, and it might even call a constructor in the case of a class. However, I, too, like Walter's approach, so I'm happy to leave things as they are.

Jill


June 09, 2004
Jeroen van Bemmel wrote:

> Since casting can be considered as invoking a function on an object, wouldn't it make sense to allow:
> 
> x.cast( int ) where x can be any object or scalar value?

The problem of this is that it looks like a function call that takes a type as argument. As long as types cannot be handled like that in D in general, I think it is a good idea to leave the cast syntax as it is without trying to make it look similar to something that is fundamentally different.