Hi everybody,
This topic was discussed once here, but...
Why _cast() is called only for builtin data types? When I do:
(int)something;
then something->_cast("int") gets called, but when I do
(SomeType)something;
then SomeType(something) gets called? I just can't understand why,
it seems a bit unlogical (if there is some logic behind - please
explain). Additionally, there is no way to distinguish between
regular constructor call and when type is casted...
And concerning assignment operator overloading. I believe that this
will be very useful feature, and it should not be [too] difficult to
implement. Well, there will be some problems when target (lvalue)
may have more than one type, but in case when it is not multi-type,
it should be quite simple.
So... If, and only if, the object (class) defines `=() and ``=(), then:
* If variable is of type SomeObject, and it is undefined, the
function ``=() will be called and it should play constructor's
role (we can't simply call constructor here since in this case we
can't distinguish between regular constructor call and a call from
assignment).
* If variable is defined and contains object of type SomeObject,
then the function `=() will be called.
When there is ambiguity, standard behavior should be used (or exception
raised, or compiler error, etc).
This way, IMHO, we can keep compatibility, and use very nice and
useful feature same time.
Any opinions, suggestions, idea, flames? :)
Regards,
/Al