Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:49210 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 26935 invoked from network); 6 Aug 2010 08:24:46 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 6 Aug 2010 08:24:46 -0000 Authentication-Results: pb1.pair.com header.from=ignas.rudaitis@gmail.com; sender-id=pass; domainkeys=bad Authentication-Results: pb1.pair.com smtp.mail=ignas.rudaitis@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.161.42 as permitted sender) DomainKey-Status: bad X-DomainKeys: Ecelerity dk_validate implementing draft-delany-domainkeys-base-01 X-PHP-List-Original-Sender: ignas.rudaitis@gmail.com X-Host-Fingerprint: 209.85.161.42 mail-fx0-f42.google.com Received: from [209.85.161.42] ([209.85.161.42:34284] helo=mail-fx0-f42.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id EC/25-30659-CC6CB5C4 for ; Fri, 06 Aug 2010 04:24:45 -0400 Received: by fxm17 with SMTP id 17so4183990fxm.29 for ; Fri, 06 Aug 2010 01:24:39 -0700 (PDT) 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=mNEYq6uBmAgSleeq7z23bfoz2ArxruY6Kv2tL683ssg=; b=PYhCBgvUWKpY65usr8BYqVoFc6bsp1H+qXvEcpNh0Jrs1jw9VKg8yWqCb+mjycVsYq z9+/YcSRrV+yc4441CDr+DKI/zZrJVr/B3HrEOasq8UuQPQvWhjZ4rSsF8n0002GsfoY AOllbj1tB61Y+XAGMo7BKU6uruVgd8+Seb/1M= 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=crj2gcQBTkwx6zU3W3Oa7/e2wU095a6me2ivPQcAFUcif0qEyr3fycQ3CG10hujaW/ eJB32MbFplEX+yDE4EhoAQ4L3KA5vP1SUtOFBOCsNHbJMvf3E+bgAHxz2ot9zMRDzKZy 8ul/ahsI7PJyiUDdgnUAPylwx/Zo85wmLY3aU= MIME-Version: 1.0 Received: by 10.204.101.72 with SMTP id b8mr7637421bko.192.1281083079528; Fri, 06 Aug 2010 01:24:39 -0700 (PDT) Received: by 10.204.85.71 with HTTP; Fri, 6 Aug 2010 01:24:39 -0700 (PDT) In-Reply-To: <4C5B3C13.4080107@sugarcrm.com> References: <4C5B3C13.4080107@sugarcrm.com> Date: Fri, 6 Aug 2010 08:24:39 +0000 Message-ID: To: Stas Malyshev Cc: internals@lists.php.net Content-Type: text/plain; charset=ISO-8859-1 Subject: Re: [PHP-DEV] Feature proposal: userland support for name qualification From: ignas.rudaitis@gmail.com (Ignas Rudaitis) Hi, well, my apologies for not making that clear enough. I suppose it wouldn't require any runtime information, as this kind of construct could be expanded at compile time. For example: willUse('LibraryWithAVeryLongName\Cache\FileCache') ->willUse('LibraryWithAVeryLongName\Routing\CachingRouter') ->willUse('LibraryWithAVeryLongName\Parsing\CachingParser'); // tens of similar declarations follow // Mentioning a class name in an exception message throw new \InvalidArgumentException('The first argument must be an array or an instance of LibraryWithAVeryLongName\Collections\List'); ?> Now if there was a COMPILE-TIME construct for expanding unqualified names and "quoting" them, i.e. turning them into string literals, then the 'LibraryWithAVeryLongName' prefix would be redundant, because it's already declared as the current namespace. In Java, there is the Foo.class syntax. C# has typeof(Foo). So something like class(Foo) would be nice to have in PHP. Even if such long namespace names as in the example don't make sense, deeply-nested ones do, so that's hardly an exaggeration. Now, an example using the proposed syntax: willUse(class(Cache\FileCache)) ->willUse(class(Routing\CachingRouter)) ->willUse(class(Parsing\CachingParser)); // and so on use LibraryWithAVeryLongName\Collections\List; throw new \InvalidArgumentException('The first argument must be an array or an instance of ' . class(List)); ?> And of course, class(Foo) doesn't have to be the exact syntax. On 8/5/10, Stas Malyshev wrote: > Hi! > >> unqualified aliases, it would be useful to extend this functionality >> to string references to these classes/functions/constants as well. > > It would require to carry "namespace context" around with every > function/class in runtime and for me the usecase is not clear. Can you > describe more in detail what you try to do and why you need runtime > resolution for it? > -- > Stanislav Malyshev, Software Architect > SugarCRM: http://www.sugarcrm.com/ > (408)454-6900 ext. 227 > -- Sent from my mobile device