Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:34304 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 62058 invoked by uid 1010); 31 Dec 2007 18:05:49 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 62043 invoked from network); 31 Dec 2007 18:05:49 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 31 Dec 2007 18:05:49 -0000 Authentication-Results: pb1.pair.com header.from=cellog@php.net; sender-id=unknown Authentication-Results: pb1.pair.com smtp.mail=cellog@php.net; spf=unknown; sender-id=unknown Received-SPF: unknown (pb1.pair.com: domain php.net does not designate 38.99.98.18 as permitted sender) X-PHP-List-Original-Sender: cellog@php.net X-Host-Fingerprint: 38.99.98.18 beast.bluga.net Linux 2.6 Received: from [38.99.98.18] ([38.99.98.18:54483] helo=mail.bluga.net) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 10/F6-02434-C7F29774 for ; Mon, 31 Dec 2007 13:05:49 -0500 Received: from mail.bluga.net (localhost.localdomain [127.0.0.1]) by mail.bluga.net (Postfix) with ESMTP id B6774C0FE58; Mon, 31 Dec 2007 11:05:47 -0700 (MST) Received: from [192.168.2.6] (cpe-069-132-221-231.carolina.res.rr.com [69.132.221.231]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mail.bluga.net (Postfix) with ESMTP id C50D4C0FE56; Mon, 31 Dec 2007 11:05:46 -0700 (MST) Message-ID: <47792F73.8030804@php.net> Date: Mon, 31 Dec 2007 12:05:39 -0600 User-Agent: Thunderbird 2.0.0.9 (Windows/20071031) MIME-Version: 1.0 To: Markus Fischer CC: Jessie Hernandez , internals@lists.php.net, dmitry@zend.com, stas@zend.com References: <476878B4.8000200@gmail.com> <4778E18A.3080605@fischer.name> In-Reply-To: <4778E18A.3080605@fischer.name> Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-Virus-Scanned: ClamAV using ClamSMTP Subject: Re: Interfaces name "Interface", was: [PHP-DEV] Re: Idea for namespacelookup resolution From: cellog@php.net (Greg Beaver) Markus Fischer wrote: > Hi, > > I started a scratch project with this patch and working with it seems > intuitive so far. > > My only question at the moment is the following, however I guess it > isn't specific to your NS patch then to Dmitry's: > > My current practice to declare an interface and provide concrete > implementation was like this: > > file: Foo/Bar/Interface.php > interface: Foo_Bar_Interface > > Now this gets problematic: > > file: Foo/Bar/Interface.php > namespace: Foo::Bar; > interface: Interface > > The last one doesn't work, because the source actually looks like: > > interface Interface { > > which gives > > syntax error, unexpected T_INTERFACE, expecting T_STRING > > I tried something like > > namespace Foo; > interface Bar::Interface; > > but that gives another parser error about the :: > > syntax error, unexpected T_PAAMAYIM_NEKUDOTAYIM, expecting '{' > > Is there any chance for Rescue for this, instead of changing the naming > scheme? Hi Markus, It is technically possible to fix this, on first glance it would involve having the lexer return a T_STRING for any non-whitespace following T_INTERFACE or between T_IMPLEMENTS and '{'. It would also need to return T_STRING following T_INSTANCEOF. However, this fix would only apply to interface naming, and would allow bizarre stuff like "interface class" or even "interface foreach" which is fine by me, but could be confusing to others (or so I've been told). Implementation would only touch the zend_language_scanner.l file, but would make it more complex. I've already gone down this road a few times, and you would also end up with inconsistent naming, as the solution could not work for classes because of the need to do ClassName::*. Implementing "ClassName::*" requires a lookahead token returning any whitespace and "::" back, which would slow things down a bit and complicate the lexer considerably, but it can be done. I'd be happy to do it but only if I have some reasonable assurance it would be accepted, it's a fair amount of work to patch the lexer and make sure it doesn't break crap. Greg