Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:35652 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 75802 invoked by uid 1010); 20 Feb 2008 18:00:56 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 75787 invoked from network); 20 Feb 2008 18:00:56 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 20 Feb 2008 18:00:56 -0000 Authentication-Results: pb1.pair.com header.from=stefan.marr.de@gmail.com; sender-id=pass; domainkeys=bad Authentication-Results: pb1.pair.com smtp.mail=stefan.marr.de@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.200.169 as permitted sender) DomainKey-Status: bad X-DomainKeys: Ecelerity dk_validate implementing draft-delany-domainkeys-base-01 X-PHP-List-Original-Sender: stefan.marr.de@gmail.com X-Host-Fingerprint: 209.85.200.169 wf-out-1314.google.com Received: from [209.85.200.169] ([209.85.200.169:3853] helo=wf-out-1314.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 2A/FC-30965-7DA6CB74 for ; Wed, 20 Feb 2008 13:00:56 -0500 Received: by wf-out-1314.google.com with SMTP id 27so887372wfd.26 for ; Wed, 20 Feb 2008 10:00:53 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from:reply-to:sender:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references:x-google-sender-auth; bh=bJRXdwLZPXvS56cGH1mxUEwEJL0lTmW5ILyVCtTyxkA=; b=MBZqzKifV8yVOIA9GGrS5cuxIrzsRFomHb7gefCR+e1M5yGv3xWdNTN75d8zndYLgQ5OaIIoJXQCUyNPDVWYSWW0LEsH1XnwFy8YZiNCOg4ldpMMdQ7+PgfGm4zSp+r9wvDVrV3L18+FjciEwS2owBd9Y/mxpLk1OQ4Ex1ALt+c= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:reply-to:sender:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references:x-google-sender-auth; b=qmddwRrgV5agylxX6xWxX49/ko4Xa2GgIBIR1ed5UBfgWS9HI9jEAsVpRLJk/Gjw5JGr9+RCsem/7fHEqZTGR3Zo3sgg5o78/pLdyldC/Oslnkjdgz3F4xD5EUZ/48TFSFVnUEbeA1kWzoRsDbSXvnNGb2QZ/5WW4COBezW9+a0= Received: by 10.142.49.4 with SMTP id w4mr161647wfw.185.1203530452668; Wed, 20 Feb 2008 10:00:52 -0800 (PST) Received: by 10.142.141.2 with HTTP; Wed, 20 Feb 2008 10:00:52 -0800 (PST) Message-ID: <1e12984d0802201000s22a16ee0u6825018443171498@mail.gmail.com> Date: Wed, 20 Feb 2008 19:00:52 +0100 Reply-To: php@stefan-marr.de Sender: stefan.marr.de@gmail.com To: internals@lists.php.net Cc: "=?ISO-8859-1?Q?Marcus_B=F6rger?=" , "=?ISO-8859-1?Q?Johannes_Schl=FCter?=" , "Sebastian Bergmann" , "Alexandre Bergel" , "Falko Menge" , "Sara Golemon" , derick@php.net In-Reply-To: <001c01c87264$3c01b4e0$b4051ea0$@de> MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline References: <001c01c87264$3c01b4e0$b4051ea0$@de> X-Google-Sender-Auth: 5407fb4433ef577e Subject: Re: RFC: Traits for PHP From: php@stefan-marr.de ("Stefan Marr") Hi, I've updated the RFC on several sections to reflect the discussion on this list. The following parts have been changed or added: - introduced explicit description of abstract methods to be used as requirements specification for traits (useful to access state) - moved part about interface propagation to the section of rejected features - added a section about common misconceptions i.e. aliasing is not renaming - added various syntax proposals The important parts are included below. The new version of the RFC is available at http://www.stefan-marr.de/rfc-traits-for-php.txt and http://www.stefan-marr.de/artikel/rfc-traits-for-php.html Some people proposed to implement only a subset of the proposed features, especially !renaming! and abstract methods and visibility changes has been mentioned to postpone on a later version. I disagree on some of them. At first, there is no renaming :) Hope, we could get this clear in the next few days. May be I should change the way of explaining it, but I've added the part about misconceptions in the first place. Second, abstract methods is a really common concept, the have the same semantics like for classes. So I expect them to be used the same way. Third, the changes of visibility. Ok, they are nice but not essentially. Would be ok to leave them out for now. The next step could be to try to agree on one of the proposed notations? Kind Regards Stefan Express Requirements by Abstract Methods """""""""""""""""""""""""""""""""""""""" Since Traits do not contain any state/properties, there is a need to describe the requirements a Trait will rely on. In PHP it would be possible to utilize the dynamic language features, but it is a common practice to give this requirements explicitly. This is possible with abstract methods like it is used for abstract classes. :: getWorld(); } abstract public function getWorld(); } class MyHelloWorld { private $world; use Hello; public function getWorld() { return $this->world; } public function setWorld($val) { $this->world = $val; } } ?> The usage of abstract methods allows to state not always obvious relation ships and requirements explicitly. It is favored over the implicit usage of the dynamic method resolution and property creation in the context of complex projects for the sake of readability. Common Misconceptions ===================== Aliasing vs. Renaming --------------------- The presented aliasing operation has not a semantic of renaming. Instead it does only provide a new name to be able to invoke the original method with this new name even if the original name was excluded. :: b(); } public function b() { echo 'b'; } } class Foo { use A { c => b } } $foo = new Foo(); $foo->a(); //echos ab $foo->b(); //echos b $foo->c(); //echos b ?> Since it is not renaming the original method b is still available and has not been influenced at all. Alternative Keywords for use """""""""""""""""""""""""""" The keyword use is already reserved for the new namespace feature. Thus, alternative keywords already proposed on the mailing list are listed here:: [1] exhibit class Foo { exhibit Bar; } [2] possess class Foo { possess Bar; } Alternative Expression of Exclusion """"""""""""""""""""""""""""""""""" Some people do not like the notation with the exclamation mark. Possible alternatives:: [1] not keyword use Trait { not foo1, foo2; bar => foo1 } [2] without keyword use Trait { without foo1, foo2; bar => foo1 } Alternatives for the Aliasing Notation """""""""""""""""""""""""""""""""""""" Aliasing is often misunderstood as renaming. May be some of the following notations will help:: [1] is keyword instead of the arrow use Trait { bar is foo1; //methodAlias is method } Interpretation: ``is`` state something about ``bar``, there is nothing stated about ``foo1``. Alternative keyword:: [2] from use Trait { bar from foo1; //methodAlias from method } Or an very explicit variation:: [3] from use Trait { alias bar as foo1; }