Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:31764 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 54386 invoked by uid 1010); 21 Aug 2007 05:33:11 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 54370 invoked from network); 21 Aug 2007 05:33:11 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 21 Aug 2007 05:33:11 -0000 Authentication-Results: pb1.pair.com header.from=greg@chiaraquartet.net; sender-id=unknown Authentication-Results: pb1.pair.com smtp.mail=greg@chiaraquartet.net; spf=permerror; sender-id=unknown Received-SPF: error (pb1.pair.com: domain chiaraquartet.net from 38.99.98.18 cause and error) X-PHP-List-Original-Sender: greg@chiaraquartet.net X-Host-Fingerprint: 38.99.98.18 beast.bluga.net Linux 2.6 Received: from [38.99.98.18] ([38.99.98.18:46661] helo=mail.bluga.net) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id C6/D1-36574-2197AC64 for ; Tue, 21 Aug 2007 01:33:10 -0400 Received: from mail.bluga.net (localhost.localdomain [127.0.0.1]) by mail.bluga.net (Postfix) with ESMTP id 48030C0D498; Mon, 20 Aug 2007 22:33:00 -0700 (MST) Received: from [192.168.0.106] (CPE-76-84-1-170.neb.res.rr.com [76.84.1.170]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mail.bluga.net (Postfix) with ESMTP id 74BEFC0D497; Mon, 20 Aug 2007 22:32:59 -0700 (MST) Message-ID: <46CA7999.8020605@chiaraquartet.net> Date: Tue, 21 Aug 2007 00:35:21 -0500 User-Agent: Thunderbird 1.5.0.12 (X11/20070604) MIME-Version: 1.0 To: Rasmus Lerdorf CC: internals Mailing List References: <46C9F217.8040804@chiaraquartet.net> <46C9F50A.7040009@sci.fi> <46CA6367.9090301@lerdorf.com> <46CA71F4.40205@chiaraquartet.net> <46CA75ED.8060506@lerdorf.com> In-Reply-To: <46CA75ED.8060506@lerdorf.com> Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-Virus-Scanned: ClamAV using ClamSMTP Subject: Re: [PHP-DEV] [PATCH] allowing multiple namespaces per file plus namespaces with brackets From: greg@chiaraquartet.net (Gregory Beaver) Rasmus Lerdorf wrote: > Right, which breaks the single-namespace per file rule. Opcode caches > work on a per-file basis, so I know for a single op_array that I will > never have to worry about a secondary namespace lookup because I know up > front which namespace I am in. By allowing multiple namespaces per file > I have to keep checking or do some other clever trick to figure it out. > > And nested namespaces really make a mess of this if something like this > is allowed: > > foo.inc: > namespace A { > include 'bar.inc'; > } > > > bar.inc: > namespace B { > ... > } > > In this case bar.inc's functions will either be A::B::func() or > B::func() depending on how it is included which again means I can't do > any compile-time optimization. Hi Rasmus, The patch explicitly disallows nested namespaces, the result of your sample above will be two separate namespaces, global and B. Also, the namespace processing is still per-file, it just adds a bit more complexity within a file for APC and company. I didn't realize you were talking about an opcode cache when speaking of moving things to the executor, but I still think by essentially implementing this as macro expansion, you can convert the two files to: foo.inc: include 'bar.inc'; bar.inc: class B::Whatever {...} and in other files, resolve imports in the same manner: another.inc: include 'bar.inc'; import B::Whatever; $a = new Whatever; becomes: another.inc: include 'bar.inc'; $a = new B::Whatever; What else is there here that I'm missing? I was under the impression that all of the namespacing tricks (as implemented) are determinate aliases to class names and function names that contain "::" in the actual CG() hash tables. I don't wish to cause trouble on these points, but I don't yet understand how the patch makes things any worse for APC, as all of the namespacing is still 100% deterministic and is a closed per-file system done at compile-time. Greg