On Tue, May 06, 2003 at 03:00:06PM +0200, Martin Nilsson (lambda) @ Pike (-) developers forum wrote:
You are wrong. (SomeType)something; doesn't call SomeType with someting.
It does:
Pike v7.4 release 10 running Hilfe v3.5 (Incremental Pike Frontend)
class SomeType { void create(mixed ... args) { write("SomeType(%O)\n", args); } void _cast(mixed ... args) { write("SomeType_cast(%O)\n", args); } }; int x = 5; string y = "13"; (SomeType)x;
SomeType(({ /* 1 element */ 5 })) (1) Result: HilfeInput()->SomeType()
(SomeType)y;
SomeType(({ /* 1 element */ "13" })) (2) Result: HilfeInput()->SomeType()
(SomeType)(x);
SomeType(({ /* 1 element */ 5 })) (3) Result: HilfeInput()->SomeType()
(SomeType)(y);
SomeType(({ /* 1 element */ "13" })) (4) Result: HilfeInput()->SomeType()
So I am right :)
(SomeType)(something) however does.
As you can see - both do.
If it was possible to cast things into arbitrtary types, how would you know if (SomeType)(something) really means SomeType(something) or (SomeType)something?
I know because (TypeName) is a typecast operator. Type (class) name by itself is not used. So, the construct (SomeType)someobj must actually call someobj->_cast("SomeType") (as it does in case of simple types).
At least, this is logical. Or? :)
Regards, /Al