Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:50993 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 13020 invoked from network); 10 Dec 2010 17:16:01 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 10 Dec 2010 17:16:01 -0000 Authentication-Results: pb1.pair.com smtp.mail=m4rw3r@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=m4rw3r@gmail.com; sender-id=pass; domainkeys=bad Received-SPF: pass (pb1.pair.com: domain gmail.com designates 74.125.83.54 as permitted sender) DomainKey-Status: bad X-DomainKeys: Ecelerity dk_validate implementing draft-delany-domainkeys-base-01 X-PHP-List-Original-Sender: m4rw3r@gmail.com X-Host-Fingerprint: 74.125.83.54 mail-gw0-f54.google.com Received: from [74.125.83.54] ([74.125.83.54:41832] helo=mail-gw0-f54.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id EC/79-59644-050620D4 for ; Fri, 10 Dec 2010 12:16:00 -0500 Received: by gwj21 with SMTP id 21so3278611gwj.13 for ; Fri, 10 Dec 2010 09:15:57 -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=rf/74JtePtfFX24glqoxlGGlBFCvUF899d5p4DxJRvY=; b=ScWCvQuhYrWkcfrBtRaQd+x2pG50dhDDHJg6KdxjzAskFrenmSpc6xveRHXXeSuTVI yULxzyD/uDt4nV4Ut1eJU32vnO2zeq/tdxdCPeXsQTw6EAlbKvUvT0TLv0ochgVLECDA 1l/+O7Fdp00PB5cfpqLcCHlKooxTnGHEuo2z0= 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=U30N8owhTYwdFKY1hMwxdHWJWaTBJk0DELCIuVX31IidZO/FMaZQTGzzILobEnpoey gR51W5CIJs8Gsd6pr+S/uUUKTUuJdJGclOTNK2+UHYw4CEUwvc839paJnOzXEDWwj9ez U5DuSUdz3K/a7ZKtsLqLeTKc/vZEOtPVYdlL4= MIME-Version: 1.0 Received: by 10.100.119.5 with SMTP id r5mr652674anc.88.1292001356273; Fri, 10 Dec 2010 09:15:56 -0800 (PST) Received: by 10.100.212.14 with HTTP; Fri, 10 Dec 2010 09:15:56 -0800 (PST) In-Reply-To: References: <9CD87200-33CB-40BE-A81C-36FD7471F59C@stefan-marr.de> <9A31F2F9-ED6B-4BE5-A6E2-EB4536E8667F@stefan-marr.de> Date: Fri, 10 Dec 2010 18:15:56 +0100 Message-ID: To: Stefan Marr Cc: Nathan Nobbe , internals@lists.php.net Content-Type: multipart/alternative; boundary=0016364edb1ee3d89f0497118126 Subject: Re: [PHP-DEV] Traits expecting interfaces implicitly leads to expensive runtime checks From: m4rw3r@gmail.com (Martin Wernstahl) --0016364edb1ee3d89f0497118126 Content-Type: text/plain; charset=ISO-8859-1 First i have to say that I am not a PHP internals developer, but as a user I think it would maybe be better to just let the trait use the implements keyword, and "copy" that to the classes utilizing the trait? Or does that seem illogical when the trait does not implement all of the methods specified by the interface? (Because I think "expects" might be a common name in APIs for some kind of validation.) Best Regards Martin Wernstahl On Fri, Dec 10, 2010 at 18:09, Stefan Marr wrote: > Hi Nathan: > > On 10 Dec 2010, at 17:49, Nathan Nobbe wrote: > > Def not :D, however, I still think this paradigm is lacking. Don't you > think it makes more sense if I write a trait that expects a given interface > or class to be able to specify said interface/class in it's entirety with > just a single identifier rather than listing out all the methods? > > > > For example, I think this would be ugly > > > trait IteratorHelper{ > > abstract public current(); > > abstract public key(); > > abstract public next(); > > abstract public rewind(); > > abstract public valid(); > > } > > ?> > > > > essentially you're redeclaring the entire interface in the trait, the > same would be true of the public interface of an expected class. i think it > would be much more elegant to allow a specification on the trait declaration > itself, something like > > > > > trait IteratorHelper expects Iterator { > > ... > > } > > ?> > :D That was exactly my thought when I was writing my first answer. > My second thought was, damn, not another keyword... > > But since you also seem to see the need, we should give it a thought. > > Anyone else with an opinion on that? > > Best regards > Stefan > > > -- > 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 > > > -- > PHP Internals - PHP Runtime Development Mailing List > To unsubscribe, visit: http://www.php.net/unsub.php > > --0016364edb1ee3d89f0497118126--