Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:52204 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 11906 invoked from network); 10 May 2011 08:45:22 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 10 May 2011 08:45:22 -0000 Authentication-Results: pb1.pair.com smtp.mail=rasmus@lerdorf.com; spf=permerror; sender-id=unknown Authentication-Results: pb1.pair.com header.from=rasmus@lerdorf.com; sender-id=unknown Received-SPF: error (pb1.pair.com: domain lerdorf.com from 74.125.83.170 cause and error) X-PHP-List-Original-Sender: rasmus@lerdorf.com X-Host-Fingerprint: 74.125.83.170 mail-pv0-f170.google.com Received: from [74.125.83.170] ([74.125.83.170:63047] helo=mail-pv0-f170.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 97/B1-01064-F1BF8CD4 for ; Tue, 10 May 2011 04:45:21 -0400 Received: by pvg16 with SMTP id 16so3115627pvg.29 for ; Tue, 10 May 2011 01:45:16 -0700 (PDT) Received: by 10.68.35.165 with SMTP id i5mr11017459pbj.449.1305017116288; Tue, 10 May 2011 01:45:16 -0700 (PDT) Received: from [192.168.200.140] (c-76-126-236-132.hsd1.ca.comcast.net [76.126.236.132]) by mx.google.com with ESMTPS id b4sm4672447pbo.80.2011.05.10.01.45.15 (version=TLSv1/SSLv3 cipher=OTHER); Tue, 10 May 2011 01:45:15 -0700 (PDT) Message-ID: <4DC8FB1A.7040206@lerdorf.com> Date: Tue, 10 May 2011 01:45:14 -0700 User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.17) Gecko/20110424 Thunderbird/3.1.10 MIME-Version: 1.0 To: Jordi Boggiano CC: Lars Schultz , internals@lists.php.net References: <4DC826B1.4090806@lerdorf.com> <4DC82A36.8090604@lerdorf.com> <4DC83401.2090202@sugarcrm.com> <4DC8D122.3050507@lsces.co.uk> <4DC8F125.2010503@toolpark.com> In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [PHP-DEV] annotations again From: rasmus@lerdorf.com (Rasmus Lerdorf) On 05/10/2011 01:10 AM, Jordi Boggiano wrote: > On Tue, May 10, 2011 at 10:02 AM, Lars Schultz >> To explain what I mean, I'll use the example provided in the RFC. Could >> anyone please explain the advantages of having "passive" annotations over >> "active" PHP Code. > > I think your example shows very well why annotations are good, it's > much more concise. By concise, you mean shorter, easier to read? I have a really hard time looking at: class User { protected $Phonenumbers; } as a PHP user and instantly understanding what this does. It looks completely foreign from a PHP syntax point of view. Whereas: class User_EntityAnnotation { public function getEntityName() { return 'users'; } public function getColumnInfo($property) { switch($property) { case 'id': return array( 'column'=>'integer', 'isPrimary'=>true, 'autoIncrement'=>true ); case 'Phonenumbers': return array( 'manytomany'=>'Phonenumber' ); } } } is way more verbose, but I can instantly grok what is going on without learning a new syntax, without waiting for my opcode cache to support it, and without waiting for my editor to understand the new syntax. Don't underestimate the difficulty in getting opcode cache support for something like this. If you think the engine code is complex, try digging into the opcode cache code. It will be much much harder to write the opcode cache support than it was to write the engine code for it. I also have a personal problem with code that needs to introspect on every web request in order to run. But that is likely because I am old and gray and used to stare sceptically at the assembly output of the first C compilers to see if I could come up with an alternative that would take fewer cycles. -Rasmus