Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:42009 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 95722 invoked from network); 21 Nov 2008 16:27:22 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 21 Nov 2008 16:27:22 -0000 Authentication-Results: pb1.pair.com smtp.mail=sv_forums@fmethod.com; spf=permerror; sender-id=unknown Authentication-Results: pb1.pair.com header.from=sv_forums@fmethod.com; sender-id=unknown Received-SPF: error (pb1.pair.com: domain fmethod.com from 69.16.228.148 cause and error) X-PHP-List-Original-Sender: sv_forums@fmethod.com X-Host-Fingerprint: 69.16.228.148 unknown Linux 2.4/2.6 Received: from [69.16.228.148] ([69.16.228.148:40145] helo=host.fmethod.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 9B/E4-05441-A61E6294 for ; Fri, 21 Nov 2008 11:27:22 -0500 Received: from [83.228.56.37] (port=1575 helo=pc) by host.fmethod.com with esmtpa (Exim 4.69) (envelope-from ) id 1L3Xn4-0003L7-4P for internals@lists.php.net; Fri, 21 Nov 2008 09:19:26 -0600 Message-ID: <689612B775E44BF5A70991B2C9E8B82F@pc> To: Date: Fri, 21 Nov 2008 17:18:42 +0200 MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_NextPart_000_00AF_01C94BFD.34045CC0" X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 6.00.2900.5512 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.5579 X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - host.fmethod.com X-AntiAbuse: Original Domain - lists.php.net X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - fmethod.com Subject: Proposal for "nameof" functionality without new keyword... From: sv_forums@fmethod.com ("Stan Vassilev | FM") ------=_NextPart_000_00AF_01C94BFD.34045CC0 Content-Type: text/plain; charset="windows-1251" Content-Transfer-Encoding: quoted-printable Hi, Earlier I proposed this construct which fell on deaf ears, maybe since = it means a new keyword "nameof": namespace Foo\Bar; class Baz {} $name =3D nameof Baz; // 'Foo\Bar\Baz' The same expansion to FQN happens for imports/aliases with "use XXX". I want to suggest an alternative approach which could work just the same = internally, but without a new keyword: namespace Foo\Bar; class Baz {} $name =3D Baz::__NAME__; // 'Foo\Bar\Baz' [IMPORTANT] Baz::__NAME__ should be replaced at parse time (like the = magic constants), so that class Baz is not autoloaded (we don't need it = autoloaded just for the name). Why is this good: 1) Would cover our basic needs for this feature when passing class names = around for factories, callbacks, strategies, handlers and so on. 2) Doesn't introduce a new keyword, and apparently class constant = __NAME__ is very rarely used by anyone, if at all (Google Code Search = shows 0 hits on PHP code). 3) It's intuitive as it follows the conventions established by the other = magic constants, and serves a very similar purpose. Regards,=20 Stan Vassilev ------=_NextPart_000_00AF_01C94BFD.34045CC0--