From my reading of delegation, it's really overloading, worded slightly 
differently.. - but not that related to interfaces...

In the example below, which is a php'ized version of a C# demo, the 
advantages of using interfaces (as far as I know) are primarly useful 
for COM or CORBA, where it would be possible to generate all the 
components for a CORBA/COM/.NET, or even java binding by reading the 
interfaces.

A .NET binding would effectively define all the available interfaces and 
classes, with strong typing!, and then when called (from C# or .NET) 
invoke a C call to call_user_function, to run php exectuter.... 
(probably the best way to implement a .NET server in php, - compiling a 
loosely typed language into .NET bytecodes, from reading about 
python,perl etcs. experience is not the way to go..)

Other than being nice for documentation, in pure PHP, I cant really see 
them being much use...

Interesting subject anyway..

Regards
Alan

called from C#

PHP_Celcius c = new PHP_Celcius(12.9);
system.out(c.toFarenheight().toString());




Interface temperature {
     function __construct(float $value);
     float function toCelcius();
     float function toFarenheight();
}

class Celcius {
    Implements temperature;
    var $value=0;
    function __construct($value) {
        $this->value =0;
    }

    function toCelcius() {
        return $this->value;
    }
    function toFarenheight($value) {
        return $this->value * 1.5;
    }
}

class Farenheight{
    Implements temperature;
    var $value=0;
    function __construct($value) {
        $this->value =0;
    }
    function toCelcius() {
        return $this->value / 1.5;
    }
    function toFarenheight($value) {
        return $this->value;
    }
}
Wez Furlong wrote:

>Hi Ben,
>
>ZE2 will implement something that can used much like interfaces;
>Please see this RFC on Delegation; something very similar to the syntax
>described there will be in PHP 5.
>
>http://cvs.php.net/co.php/ZendEngine2/RFCs/004.txt?r=1.2
>
>Also, review the archives for [EMAIL PROTECTED] list for more
>information about the (long) discussion on the subject.
>(http://zend.com/lists/engine2/200206/maillist.html is a rough start).
>
>--Wez.
>
>On 08/20/02, "Ben Dischinger" <[EMAIL PROTECTED]> wrote:
>  
>
>>What are the thoughts on implementing interfaces (as in object) within 
>>PHP?  Does the work outweigh the benefits?
>>
>>Ben Dischinger
>>
>>
>>-- 
>>PHP Development Mailing List <http://www.php.net/>
>>To unsubscribe, visit: http://www.php.net/unsub.php
>>    
>>
>
>
>
>
>  
>




-- 
PHP Development Mailing List <http://www.php.net/>
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to