I think the cast lfun interface has to be expanded a bit as well. If we do (A)B then the cast method in B should get the program A as second argument, I think.
I agree.
Further, if B has no cast method, should some ``cast (or even create) in A be called? Example: (Gmp.mpz)5 would then result in Gmp.mpz(5).
I don't think it's a good idea to reuse the create lfun for that since that'd mean create() could be used in a situation the class author probably didn't expect. A right-cast operator lfun seems like a logical extension, though. The best would be if proper static functions are implemented so that
(A) b
is tried as the equivalent of
A.``cast (b)
and not
(tmp = A(), tmp->``cast (b), tmp)
That would allow ``cast to return an existing object.
/ Martin Stjernholm, Roxen IS
Previous text:
2003-05-06 16:08: Subject: Re: Implicit class construction, _cast() and `=()
I think the cast lfun interface has to be expanded a bit as well. If we do (A)B then the cast method in B should get the program A as second argument, I think. Further, if B has no cast method, should some ``cast (or even create) in A be called? Example: (Gmp.mpz)5 would then result in Gmp.mpz(5).
/ Martin Nilsson (lambda)