Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:50296 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 81065 invoked from network); 17 Nov 2010 09:58:27 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 17 Nov 2010 09:58:27 -0000 Authentication-Results: pb1.pair.com smtp.mail=rquadling@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=rquadling@gmail.com; sender-id=pass; domainkeys=bad 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:58435] helo=mail-qy0-f177.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id E0/F5-40885-247A3EC4 for ; Wed, 17 Nov 2010 04:58:27 -0500 Received: by qyk31 with SMTP id 31so68366qyk.8 for ; Wed, 17 Nov 2010 01:58:24 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:mime-version:received:reply-to :in-reply-to:references:from:date:message-id:subject:to:cc :content-type; bh=NNXrtXhwVY+yhFSLOeUfhCn8RMDkj7EbXSegm44go0o=; b=I1q208GZiM6pbQi6yKOlse1mMsE2Zbo1IabDPMCg1zeRMdNAbmAEgvoARbxXuD6Gyl 2fiKzmEqBfWuR7KdvBdqwB+67RjV2adwwd60bl9OUIVV1dLTxLG1Vwij5DcaDMvC1MWR rd97gFhFODdHZygLvM7zDExWc57VUShcUKDjk= 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; b=iKLuYvCoyeamtnyzPCOSIVtGkax8V6ODy8ryNaBIPbrS34RchdVDOeVGNlxHBcS0rw j1U/2jTWieJOaEAwXCTIwKtNHLguh4JcRfZg1fBE3XwQeSOrdQaeSP5dkDGHUWmZlSzP zPyVJBgmXS/t3Fj9m6E/pKIRwibbl2mPxo/CI= Received: by 10.229.89.208 with SMTP id f16mr7293666qcm.168.1289987904351; Wed, 17 Nov 2010 01:58:24 -0800 (PST) MIME-Version: 1.0 Received: by 10.229.100.84 with HTTP; Wed, 17 Nov 2010 01:58:03 -0800 (PST) Reply-To: RQuadling@googlemail.com In-Reply-To: <4CE335CE.90904@sugarcrm.com> References: <887FE7CFF6F8DE4BB3A9535F53AFD06A2C59B588@il-ex2.zend.net> <887FE7CFF6F8DE4BB3A9535F53AFD06A2C59B6A0@il-ex2.zend.net> <887FE7CFF6F8DE4BB3A9535F53AFD06A2C59D788@il-ex2.zend.net> <4CE335CE.90904@sugarcrm.com> Date: Wed, 17 Nov 2010 09:58:03 +0000 Message-ID: To: Stas Malyshev Cc: Gustavo Lopes , Zeev Suraski , PHP internals Content-Type: text/plain; charset=UTF-8 Subject: Re: [PHP-DEV] PHP 5.4 - Meta attribute (aka. Annotations) support discussion From: rquadling@gmail.com (Richard Quadling) On 17 November 2010 01:54, Stas Malyshev wrote: > Hi! > >> I would have no trouble accepting a rejection of annotations on the actual >> merits, but the interminable sequence of comparisons to phpdoc make it >> clear to me that people just don't realize the potential of annotations. > > People do realize the potential, what you and many "+1" voters seem to not > realize is the cost. You propose to add new syntax into PHP which is > completely different from all other syntax constructs in PHP - different > instantiation syntax, different method parameters syntax. > It's a full micro-language inside PHP. We discussed it already, but somehow > it failed to register. > >> Yes, it is new syntax and by itself that is undesirable. However, I see > > The problem is not new syntax per se. The problem is new syntax for things > that already have old syntax. I'm a +1 in terms of PHP having support for meta data. The issues that seem to be raised so far are: 1 - New syntax / micro-language / etc to learn 2 - Parser performance and new parser to code/develop/test 3 - APC cacheing of meta data. What if the meta data is just more PHP code? We all know PHP. The parser already works. APC already gets it op-codes. Nothing significantly new to learn/develop/test. With DocBlocks, the comments are relative to the element they are describing and are placed immediately before the item in question, with the exception of a file level docblock. Keeping with that, what if there was 1 new keyword; something like annotate or annotation. This keyword would operate in the same was as class. I don't know what the content of the annotation would be, but if I was asked to try and describe what an annotation looks like, based upon what I've seen, it looks like a set of consts. The items don't change, just like a const. Please bear in mind that I've not used annotations beyond docblocks and wsdl generation. So, maybe something like this ... From this, I think there would need to be a few changes. 1 - "annotate" may not be enough, so maybe annotateFile, annotateClass, annotateFunction, annotateXxxxx, where xxxx is the element type being annotated - possibly/probably too much. 2 - Because some of suggestions on what annotations need to support includes nested data, a const would need to be allow for an array to be assigned. Personally, I think supporting a const array is a pretty useful idea. The advantages that I see here are hopefully fairly obvious. 1 - No new significant core changes. Essentially a new type of class. If annotateFile is the preferred route, then this obeys the rules like namespaces. Only 1 per file. As would annotateNamespace. 2 - The syntax is extremely familiar. 3 - There is nothing significantly new in the parser (naive assumption). 4 - APC would get the data in the same way as if it was a class or a namespace. 5 - Adding new elements to the annotation would involve absolutely no changes to core. You want to add meta data describing the COBOL picture format of a parameter or the regex validation rule that will be used, then fine. Nothing in the engine will change. -- Richard Quadling Twitter : EE : Zend @RQuadling : e-e.com/M_248814.html : bit.ly/9O8vFY