No, we don't need another constructor. Using create is enough. We just define that A(B) is the same operation as (A)B. If the A class needs more than one parameter we can't cast to it anyway, and we'll get a compilation error. If B can't be used as input parameter to A we'll get a compilation error due to type incompatibilities.
/ Martin Nilsson (lambda)
Previous text:
2003-05-06 18:36: Subject: Re: Implicit class construction, _cast() and `=()
On Tue, May 06, 2003 at 04:10:02PM +0200, Martin Nilsson (lambda) @ Pike (-) developers forum wrote:
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).
Not a good idea, IMHO. We need two constructors, then - one usual (called like SomeType()) and one - specially for casting purposes. Say, _create()? It would simplify things a lot.
But definitely, construct like (SomeType)variable should work exactly like (int)variable :)
Regards, /Al
/ Brevbäraren