Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:51017 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 11033 invoked from network); 12 Dec 2010 21:33:25 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 12 Dec 2010 21:33:25 -0000 Authentication-Results: pb1.pair.com header.from=quickshiftin@gmail.com; sender-id=pass; domainkeys=bad Authentication-Results: pb1.pair.com smtp.mail=quickshiftin@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.214.45 as permitted sender) DomainKey-Status: bad X-DomainKeys: Ecelerity dk_validate implementing draft-delany-domainkeys-base-01 X-PHP-List-Original-Sender: quickshiftin@gmail.com X-Host-Fingerprint: 209.85.214.45 mail-bw0-f45.google.com Received: from [209.85.214.45] ([209.85.214.45:33223] helo=mail-bw0-f45.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 7E/01-09585-4AF350D4 for ; Sun, 12 Dec 2010 16:33:25 -0500 Received: by bwz16 with SMTP id 16so6396520bwz.32 for ; Sun, 12 Dec 2010 13:33:20 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:received:in-reply-to :references:date:message-id:subject:from:to:cc:content-type; bh=FUB9/wP7MZcOz/fF13ulD42wU5XkYMYz7vF4435gg3o=; b=QLM44d0ywhexTb+POeDcmBb35P01mzqJFs8ce53hdcxkVkw8BWzfNWfkYSZfZPh0or xn2+cSuM5Erp+oMdzylwAPL5uyzlxiQii8jxSwVCr5nTOxgn+J2NBvxmGrg1uor+3Ido cNDs/TCiDccddI36tPEwO/FpiwO+RVW4sjKSY= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; b=Dq42zflCBQmt6Kp+0P3rnFXBx3ZFk/6cXY8h92yZLKubVhdNPX/lhBIafH5R1JNbY8 z8k4j0DmahN614U7PgEMH7qb87xiV/FAPP0dNvgEQGFV6HH6bsiiWkYjHRYSuLgkWp67 e4NPlKmtHDYFnx1e7xjGI4UlIdjGJdr20lsok= MIME-Version: 1.0 Received: by 10.204.48.86 with SMTP id q22mr3023932bkf.141.1292189599951; Sun, 12 Dec 2010 13:33:19 -0800 (PST) Received: by 10.204.112.208 with HTTP; Sun, 12 Dec 2010 13:33:19 -0800 (PST) In-Reply-To: <002101cb9a08$7b7ebb30$727c3190$@com> References: <002101cb9a08$7b7ebb30$727c3190$@com> Date: Sun, 12 Dec 2010 14:33:19 -0700 Message-ID: To: Jonathan Bond-Caron Cc: Stefan Marr , internals@lists.php.net Content-Type: multipart/alternative; boundary=0016e6d7e101166c7b04973d56ae Subject: Re: [PHP-DEV] Traits expecting interfaces implicitly leads to expensive runtime checks From: quickshiftin@gmail.com (Nathan Nobbe) --0016e6d7e101166c7b04973d56ae Content-Type: text/plain; charset=UTF-8 On Sun, Dec 12, 2010 at 7:25 AM, Jonathan Bond-Caron wrote: > On Sat Dec 11 10:25 AM, Stefan Marr wrote: > > > > http://wiki.php.net/rfc/horizontalreuse#requiring_composing_class_to_impleme > nt_interface > > > > > > Are there any objections to implementing this? > > > > It's not a bad idea, though I haven't found a strong need for it in the way > I plan to use traits. > Do you intend to use traits as reusable implementations of interfaces? If not, I could see why this feature isn't of interest to you :) > It also turns a trait into something more complex 'copy & paste' code with > requirements/dependencies. > I think copy & paste is a good way to conceptualize traits, but feel, practically, they're a bit more complex than that w/ conflict resolution, traits composed of traits, and the issue w/ attributes Stefan has brought up. Essentially, there are already rules being added around the copy & paste concept. Also, this feature is mostly an extension of the abstract keyword concept in traits, which they already support. > -1 on using 'require' (T_REQUIRE token), an option could be 'within' > > trait IteratorUser within Iterator { > function foo() { > $next = $this->next(); > ... > } > } > > class MyIterator implements Iterator { > with IteratorUser; > } > > So the 'with/within' tokens would apply to traits. > I feel 'expect', 'need', 'require' etc sound better, matter of opinion really, but it sounds like from an internals perspective it's preferred to reuse existing keywords if possible. Overall I feel -1, more use cases around "Trait expresses a requirement for > the composing class" would help, it seems like useful theory... not > convinced it's worth the trouble. If you see the value in the abstract keyword in abstract classes or moreover interfaces in general, I'd consider the value of this feature equal. Of course not everyone uses abstract classes or interfaces :D -nathan --0016e6d7e101166c7b04973d56ae--