On 02/10/2007, David Zülke <[EMAIL PROTECTED]> wrote:
> would it be possible to overload final classes?
>
> - David
>
>
> Am 02.10.2007 um 11:32 schrieb Sebastian Bergmann:
>
> >  From [1]:
> >
> >    Objective-C permits a class to wholly replace another class
> > within a
> >    program. The replacing class is said to "pose as" the target class.
> >    All messages sent to the target class are then instead received by
> >    the posing class.
> >
> >    There are several restrictions on which classes can pose:
> >
> >      * A class may only pose as one of its direct or indirect
> >        superclasses.
> >
> >      [The other restrictions do not apply to PHP]
> >
> >  Earlier this year, Johannes implemented class posing for PHP as
> > follows:
> >
> >    <?php
> >    class Foo {}
> >    class Bar extends Foo {}
> >
> >    function new_overload($className)
> >    {
> >        if ($className == 'Foo') {
> >            return new Bar;
> >        }
> >
> >        // ...
> >    }
> >
> >    $o = new Foo;
> >    // $o is an object of Foo.
> >
> >    register_new_overload('new_overload');
> >
> >    $o = new Foo;
> >    // $o is an object of Bar.
> >    ?>
> >
> >  We (Johannes, Marcus, Sara, and myself) then discussed where to
> > put this
> >  functionality. Outside of core, there were two places that both make
> >  sense: pecl/operator and pecl/runkit.
> >
> >  However, to make this a viable mechanism that can be used in tools
> > such
> >  as PHPUnit (for which I could really use this functionality), we
> > agreed
> >  that it actually belongs into the core.
> >
> >  Opinions? Needless to say that I would love to see this in PHP
> > 5.3 ;-)
> >
> >  --
> >  [1] http://en.wikipedia.org/wiki/Objective_C#Posing

You're code looks like a factory. Is that your intention? Maybe
__factory would be a more obvious name?



-- 
-----
Richard Quadling
Zend Certified Engineer : http://zend.com/zce.php?c=ZEND002498&r=213474731
"Standing on the shoulders of some very clever giants!"

Reply via email to