Generally speaking, the functionality to have more control of the object returned by a clone operation makes sense to me: It's useful to return already created objects for caching purposes or in cases where it's important to avoid multiple instances. In such cases it's not wrong to hide the implementation detail whether or not new objects are returned. It's also useful for compatibility/refactoring, as in this case.
Ideally it should be accomplished through a true static function which is named something else than "create". If it exists, it's called for a clone operation before any object instance is created, and it always return the object that should be the result of the clone operation.
But since true static functions aren't likely to happen anytime soon, I think a slight misuse of the return value from create() is passable. It's easy to deprecate when a cleaner solution exists, and keeping support for it doesn't get in the way of that solution afaics.
Having both an Sql.Sql and an Sql.DB doesn't make sense to me. It's Sql.Sql that defines the common interface, ergo it should be the class all the db variant inherits. I also don't particularly like muddling the distinction between modules and classes. It might work ok to inherit Sql.Sql and use it as a type even though it is a module, but inheriting the `() function isn't meaningful. But the worst is that it might give other users the impression that that sort of thing is a good idea, especially those who don't have a clear understanding of the distinction between classes and modules.
/ Martin Stjernholm, Roxen IS
Previous text:
2004-10-14 00:03: Subject: Re: MySQL big_query in 7.7
The Sql.Sql object will however be created only once, while the wrapper acts for every call, so that trade off is easy. The question is however if we want the possibility to return different objects from create methods.
It would be possible to let Sql.pike/Sql.pmod inherit Sql.DB and add an optional `() that returns the actual objects. Also ugly, but doesn't require any language changes.
/ Martin Nilsson (DivX Networks)