Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:53333 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 26610 invoked from network); 16 Jun 2011 15:37:52 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 16 Jun 2011 15:37:52 -0000 Authentication-Results: pb1.pair.com header.from=rquadling@gmail.com; sender-id=pass; domainkeys=bad Authentication-Results: pb1.pair.com smtp.mail=rquadling@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.216.177 as permitted sender) DomainKey-Status: bad X-DomainKeys: Ecelerity dk_validate implementing draft-delany-domainkeys-base-01 X-PHP-List-Original-Sender: rquadling@gmail.com X-Host-Fingerprint: 209.85.216.177 mail-qy0-f177.google.com Received: from [209.85.216.177] ([209.85.216.177:45939] helo=mail-qy0-f177.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id DA/13-32650-E432AFD4 for ; Thu, 16 Jun 2011 11:37:51 -0400 Received: by qyk7 with SMTP id 7so220290qyk.8 for ; Thu, 16 Jun 2011 08:37:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:reply-to:in-reply-to:references :from:date:message-id:subject:to:cc:content-type :content-transfer-encoding; bh=6c+aC4rDpHkveYZ3H1Ad0+qTyXcLoTGPlRuCKOtuycM=; b=VzbMjOVV2hKW53EVcD2WQLAsMGNTjCjKe0blj2yVlxWwHGKOpMUQporlfyeCorByIU 3MQL6Q0dh7PClk9iuQfqXiyiIU7Sq5dmpJsFANVv2biiSKyq6m2GYCqtPWDCuohc4BWI qcb/HlzN3yZ+7rKGi949yYTuQYaqNzBiDcr2k= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:reply-to:in-reply-to:references:from:date:message-id :subject:to:cc:content-type:content-transfer-encoding; b=caV/XpGWwcafUUFwVBuvTFrqruoxJNQEK7hC2T6t4ZIbbSKoH3/T6lJQdZGG3vdXoh cvbq4MDJBJrl2rKf7nNEv/NvbCFl5GzilX4CL+MXXnJ2DGxldrlrRmgAuYvBih2v3gfX 6gAwYePKak+kJXT6B11cZNmNqsRimfVTlZKkk= Received: by 10.229.26.201 with SMTP id f9mr864661qcc.151.1308238665404; Thu, 16 Jun 2011 08:37:45 -0700 (PDT) MIME-Version: 1.0 Received: by 10.229.80.79 with HTTP; Thu, 16 Jun 2011 08:37:24 -0700 (PDT) Reply-To: RQuadling@GMail.com In-Reply-To: References: <4DF8DC94.5060009@sugarcrm.com> Date: Thu, 16 Jun 2011 16:37:24 +0100 Message-ID: To: Martin Scotta Cc: Stas Malyshev , PHP internals Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Subject: Re: [PHP-DEV] Getting a list of registered namespaces. From: rquadling@gmail.com (Richard Quadling) On 16 June 2011 14:03, Martin Scotta wrote: > > =C2=A0Martin Scotta > > > On Thu, Jun 16, 2011 at 9:40 AM, Richard Quadling > wrote: >> >> On 15 June 2011 17:23, Stas Malyshev wrote: >> > Hi! >> > >> >> With pecl/http (DEV-2 branch) and the Functional extension (on github= ) >> >> both creating namespaces within the extension, I think there is a >> >> requirement for a mechanism to allow an extension to record the >> >> namespace(s) that it has, in a similar fashion to how functions and >> >> classes are known to core. >> > >> > There's no such thing as "registered namespaces", at least in the >> > engine. >> > Namespace is just a part of class/function name. You could enumerate >> > classes/functions and split their names, but I'm not sure for what suc= h >> > list >> > will be useful. Could you explain? >> > >> >> But, trawling all the classes and functions, extracting and >> >> aggregating the namespace would really not seem to be the way to go. >> >> And that wouldn't take into account the user defined namespaces. >> > >> > Again, there's no such thing as list of user defined namespaces, at >> > runtime. >> > You'd have to go through all classes/functions and split their names. >> > Again, >> > I'm not sure what would be the use of it. >> >> Currently, I can find the names of functions, classes and interfaces - >> be they from an extension or userland code. >> >> But I can't get namespaces, or their aliases. >> >> >> I'm not totally sure of any other use. That's why I was asking. >> >> As (or if) more extensions start to use namespaces to protect their >> contents from name collision, we are probably going to have namespace >> collision before long. >> > > that's why naming convention are meant for? Maybe, but because of a lack of convention on naming, we have namespaces. It people named their classes/functions/etc with sensible long names, containing something that was unique to their project, after doing plenty of research for similar sounding names, we wouldn't need namespaces. When/if github/functional and/or pecl/http-DEV2 go live, these will be the first 2 namespaces provided by PHP extensions (that could be in general use). Are you all saying that the potential for a naming-collision is negligible? It seems so. As I see it, a namespace is a container. Like a class acts as a container for methods and properties, so a namespaces acts as a container for classes, interfaces and functions, ring-fencing them to avoid name collisions. So it would seem appropriate to have the ability to investigate a namespace to see what it contains and/or if it exists. Why? For exactly the same reasons you have class_exists(), interface_exists(), function_exists(). --=20 Richard Quadling Twitter : EE : Zend : PHPDoc @RQuadling : e-e.com/M_248814.html : bit.ly/9O8vFY : bit.ly/lFnVea