Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:50256 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 35925 invoked from network); 16 Nov 2010 15:02:16 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 16 Nov 2010 15:02:16 -0000 Authentication-Results: pb1.pair.com header.from=glopes@nebm.ist.utl.pt; sender-id=unknown Authentication-Results: pb1.pair.com smtp.mail=glopes@nebm.ist.utl.pt; spf=permerror; sender-id=unknown Received-SPF: error (pb1.pair.com: domain nebm.ist.utl.pt from 193.136.128.21 cause and error) X-PHP-List-Original-Sender: glopes@nebm.ist.utl.pt X-Host-Fingerprint: 193.136.128.21 smtp1.ist.utl.pt Linux 2.6 Received: from [193.136.128.21] ([193.136.128.21:57617] helo=smtp1.ist.utl.pt) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 60/00-35759-DEC92EC4 for ; Tue, 16 Nov 2010 10:02:14 -0500 Received: from localhost (localhost.localdomain [127.0.0.1]) by smtp1.ist.utl.pt (Postfix) with ESMTP id 4068770003CB; Tue, 16 Nov 2010 15:01:43 +0000 (WET) X-Virus-Scanned: by amavisd-new-2.6.4 (20090625) (Debian) at ist.utl.pt Received: from smtp1.ist.utl.pt ([127.0.0.1]) by localhost (smtp1.ist.utl.pt [127.0.0.1]) (amavisd-new, port 10025) with LMTP id CUFFyFvL8CYH; Tue, 16 Nov 2010 15:01:42 +0000 (WET) Received: from mail2.ist.utl.pt (mail2.ist.utl.pt [IPv6:2001:690:2100:1::c]) by smtp1.ist.utl.pt (Postfix) with ESMTP id 8FEE570003C6; Tue, 16 Nov 2010 15:01:42 +0000 (WET) Received: from cataphract-old (195.61.136.95.rev.vodafone.pt [95.136.61.195]) (Authenticated sender: ist155741) by mail2.ist.utl.pt (Postfix) with ESMTPSA id 6D13C20073B3; Tue, 16 Nov 2010 15:01:42 +0000 (WET) Content-Type: text/plain; charset=iso-8859-15; format=flowed; delsp=yes To: "Zeev Suraski" Cc: "PHP internals" References: <887FE7CFF6F8DE4BB3A9535F53AFD06A2C59B588@il-ex2.zend.net> <887FE7CFF6F8DE4BB3A9535F53AFD06A2C59B6A0@il-ex2.zend.net> <887FE7CFF6F8DE4BB3A9535F53AFD06A2C59D788@il-ex2.zend.net> Date: Tue, 16 Nov 2010 15:01:39 -0000 MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Organization: =?iso-8859-15?Q?N=FAcleo_de_Eng=2E_Biom=E9dica_?= =?iso-8859-15?Q?do_IST?= Message-ID: In-Reply-To: <887FE7CFF6F8DE4BB3A9535F53AFD06A2C59D788@il-ex2.zend.net> User-Agent: Opera Mail/10.63 (Win32) Subject: Re: [PHP-DEV] PHP 5.4 - Meta attribute (aka. Annotations) support discussion From: glopes@nebm.ist.utl.pt ("Gustavo Lopes") On Tue, 16 Nov 2010 07:06:27 -0000, Zeev Suraski wrote: >> From: Pierre Joye [mailto:pierre.php@gmail.com] >> Sent: Tuesday, November 16, 2010 1:45 AM >> To: Zeev Suraski >> Cc: guilhermeblanco@gmail.com; PHP internals >> Subject: Re: [PHP-DEV] PHP 5.4 - Meta attribute (aka. Annotations) >> support discussion >> >> On Tue, Nov 16, 2010 at 12:39 AM, Zeev Suraski wrote: >> > Suggesting phpdoc is used for the purposes mentioned does not mean we >> don't understand what we're talking about. >> >> I feel like you never used annotations in other languages, did you? > > You got me... But as an intelligent human being I'd like to think I can > evaluate the merits of a feature without having to actually use it. > > I'm not saying that annotations don't give you any value. Sure they > do. I'm saying that they come at a great price of adding an obscure > branch of syntax into a language that's already grown significantly in > complexity, and the bang for the buck isn't worth it. Those advanced > developers needing that feature can make do with phpdoc. > 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. First, can docblock comments substitute the current proposal of annotations? YES, they can. Leave everything the same in the current annotations implementation and just tweak the grammar so that docblock comments are parsed for annotations. Of course, no one is actually proposing this, because at this point people usually realize it would be crazy to do such a thing. So the "alternative" they actually propose is a watered-down-to-nothing version of annotations, put as "add an API to parse docblock comments". This homeopathic version of annotations solves only a small subset of what you can actually do with annotations, as I've explained in the past (see http://news.php.net/php.internals/49674 ). Yes, it is new syntax and by itself that is undesirable. However, I see annotations has actually saving us from having to had new syntax for new functionality in the future. The ability of using annotations to sort-of extend a language is one thing that has actually mitigated the lack of new language features in Java in the last few years. Want to add support for AOP? We can use annotations to define joint points, pointcuts and advice. Define properties as non-null, having a certain type or being read-only? We can use annotations instead of adding new keywords. More general forms of design by contract? Etc etc. It must be said at this point that annotations are not perfect. Too many annotations can make the code unreadable and they can make the program flow non-obvious. Despite their versatility, they still have a relatively rigid structure. A more interesting option would be to allow either extensions or scripts to extend the grammar to better reflect the domain of the application (this could then also be used to implemented annotations). However, I think that, at this point, adding annotations directly to the language would be a fair trade-off. -- Gustavo Lopes