Kevan Benson wrote: > Should there not be a way to define object constructors with custom > signatures that can be usefully invoked like a normal constructor? > > Currently, defining a BUILD method for a class with a specific signature > doesn't seem to allow for the object to be invoked by new with that > signature and be correctly passed to the right BUILD method. It seems a > whole chain of new -> bless -> BUILDALL -> BUILD would need to be > defined with specific signatures just to get a custom constructor.
No. It's enough to write a method .new that calls bless, which in turn calls BUILDALL (which re-dispatches to BUILD) (sorry if I got the order wrong in that IRC conversation). Let's assume we define default new() method with signature (*...@p, *%n) that passes positional arguments to BUILD as BUILD(|@p, |%n), then we might not be able to call BUILD submethods from superclasses (because they don't expect any positional parameters), so you basically loose compatibility with any super classes by introducing positional parameters. Not a good idea. It seems much more sane as it is now, that is to modify only the signature of new new() methods, not of BUILD methods. Cheers, Moritz