Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:51006 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 58070 invoked from network); 11 Dec 2010 15:25:48 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 11 Dec 2010 15:25:48 -0000 Authentication-Results: pb1.pair.com header.from=php@stefan-marr.de; sender-id=unknown Authentication-Results: pb1.pair.com smtp.mail=php@stefan-marr.de; spf=permerror; sender-id=unknown Received-SPF: error (pb1.pair.com: domain stefan-marr.de from 85.88.12.247 cause and error) X-PHP-List-Original-Sender: php@stefan-marr.de X-Host-Fingerprint: 85.88.12.247 toolslave.net Received: from [85.88.12.247] ([85.88.12.247:43209] helo=uhweb12247.united-hoster.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 4C/B1-42972-AF7930D4 for ; Sat, 11 Dec 2010 10:25:47 -0500 Received: from cust194-138.dsl.as47377.net ([62.166.194.138] helo=[192.168.0.26]) by uhweb12247.united-hoster.com with esmtpsa (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.69) (envelope-from ) id 1PRRJg-0007NY-WF; Sat, 11 Dec 2010 16:24:59 +0100 Mime-Version: 1.0 (Apple Message framework v1082) Content-Type: text/plain; charset=us-ascii In-Reply-To: Date: Sat, 11 Dec 2010 16:25:34 +0100 Cc: internals@lists.php.net Content-Transfer-Encoding: quoted-printable Message-ID: References: To: Nathan Nobbe X-Mailer: Apple Mail (2.1082) Subject: Re: [PHP-DEV] Traits expecting interfaces implicitly leads to expensive runtime checks From: php@stefan-marr.de (Stefan Marr) Hi: I added the proposal to the RFC. See = http://wiki.php.net/rfc/horizontalreuse#requiring_composing_class_to_imple= ment_interface =3D=3D=3D=3D=3D Requiring Composing Class to Implement Interface =3D=3D=3D= =3D=3D Traits are able to express required methods by using abstract method = declarations. An abstract method can be satisfied in varios ways, for instance by = implementing it in the composing class or by bringing it in from another Trait. However, for traits that require complex interfaces to be satisfied, = this approach is tedious and fragile, since it requires the developer to state all used methods = explicitly. Another solution is that a Trait expresses a requirement for the = composing class to implement a certain interface. This is not entirely identical to using abstract = methods, however. First, it imposes a requirement on interface level and thus will have = the same fragility with respect to interface changes as all other clients of an interface. On the other hand, it avoids duplications of abstract method definitions = and makes the interface the main entity of responsibility as for normal = client-interface uses in current code. next(); ... } } // composed into a class that needs to implement the interface class Example implements Iterator { use IteratorUser; } Are there any objections to implementing this? Thanks Stefan --=20 Stefan Marr Software Languages Lab Vrije Universiteit Brussel Pleinlaan 2 / B-1050 Brussels / Belgium http://soft.vub.ac.be/~smarr Phone: +32 2 629 2974 Fax: +32 2 629 3525