Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:35591 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 47692 invoked by uid 1010); 19 Feb 2008 12:24:04 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 47677 invoked from network); 19 Feb 2008 12:24:04 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 19 Feb 2008 12:24:04 -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.173 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.173 wf-out-1314.google.com Received: from [209.85.200.173] ([209.85.200.173:5678] helo=wf-out-1314.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id B5/CC-55225-16ACAB74 for ; Tue, 19 Feb 2008 07:24:04 -0500 Received: by wf-out-1314.google.com with SMTP id 27so622645wfd.26 for ; Tue, 19 Feb 2008 04:23:59 -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:sender:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references:x-google-sender-auth; bh=OUY+h5nwfFi9fFmXqrZk9pnj6muQ06YeXQzp9XotJVE=; b=WWivytoiu3BQl47Hjpm+m+JxpWJOhSHo8ayl9RssBqgkDRRJd1tK3UIfpxc3QQdUmldsD6utSKxxr7+Hlwx+oWTE3WqlpTlshh3CkeRNzJ0pn2bmGs2rtDmfBnNL4fk62auS8/keUg9UB5xsmlVfOE0DJn2Ozd9BHOGcZdvzo6M= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:sender:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references:x-google-sender-auth; b=SJLCcx+EvOtTIhRDdxkJyHnzd1kjjAnGaRGnBXwyXbaiV6gk0UQ89spAt60yyCXMcADDCywuA07pFSDw5zj3RMY0c+VLKzew98fDTpE/5zxkEDGfubGbGRMjU+cPfEFieNANAy2WANzOEm61uw5GV24wZ8i9XE7P10Kwpo510A8= Received: by 10.142.230.11 with SMTP id c11mr2612816wfh.86.1203423838024; Tue, 19 Feb 2008 04:23:58 -0800 (PST) Received: by 10.142.141.2 with HTTP; Tue, 19 Feb 2008 04:23:57 -0800 (PST) Message-ID: <1e12984d0802190423r6410233ak1d15cfda3941d56f@mail.gmail.com> Date: Tue, 19 Feb 2008 13:23:57 +0100 Sender: stefan.marr.de@gmail.com To: RQuadling@googlemail.com Cc: internals@lists.php.net In-Reply-To: <10845a340802190234m4efbab0fqcf4e36ad3d812853@mail.gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline References: <001c01c87264$3c01b4e0$b4051ea0$@de> <10845a340802190234m4efbab0fqcf4e36ad3d812853@mail.gmail.com> X-Google-Sender-Auth: 3a8fb2d1f3200e7f Subject: Re: [PHP-DEV] RFC: Traits for PHP From: php@stefan-marr.de ("Stefan Marr") Hi Richard, > A question (and again, no idea on feasibility, internals, etc.). > > The above proposal covers adding/overriding internal methods with > external ones. Is it possible to also include additional properties? > > If not, then you would have to override the constructor method (this > could be demoted to documentation rather than code then I suppose). the current proposal does not allow state in your traits. At the moment the solution would be like this: trait A { abstract protected function getFoo(); public function doSomeFoo($bar) { return $this->getFoo().' baz ' . $bar; } } Traits can defined abstract methods to define a required method. This abstract methods can be implemented in the class or in an other trait. There are also notions about stateful traits out there. For instance Scala does implement them, but state is an additional level of complexity and I have tried to avoid it in this implementation, since I have had expected much more complains about the aliasing and exclude operations and its pretended complexity. In my opinion stateful traits are the next logical step, but with the cost for some additional complexity, since you need handle conflicting properties. (The stateful traits approach is to make it private to a traits composition, but this might not be obvious to every user.) Kind Regards Stefan