digitalmars.D - Casting syntax
- Jeroen van Bemmel (3/3) Jun 07 2004 Since casting can be considered as invoking a function on an object,
- Ant (4/8) Jun 07 2004 obviously,
- J C Calvarese (7/20) Jun 07 2004 It has been mentioned before. It looks like a fine suggestion to me, but...
- Arcane Jill (6/10) Jun 08 2004 That to me is the ultimate in simplicity, and it might even call a const...
- Norbert Nemec (5/9) Jun 09 2004 The problem of this is that it looks like a function call that takes a t...
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?
Jun 07 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
Jun 07 2004
Ant wrote:On Tue, 08 Jun 2004 07:58:01 +0200, Jeroen van Bemmel wrote: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/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
Jun 07 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
Jun 08 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.
Jun 09 2004