Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:52193 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 70001 invoked from network); 10 May 2011 03:04:13 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 10 May 2011 03:04:13 -0000 Authentication-Results: pb1.pair.com smtp.mail=pierrick@webstart.fr; spf=permerror; sender-id=unknown Authentication-Results: pb1.pair.com header.from=pierrick@webstart.fr; sender-id=unknown Received-SPF: error (pb1.pair.com: domain webstart.fr from 209.85.160.42 cause and error) X-PHP-List-Original-Sender: pierrick@webstart.fr X-Host-Fingerprint: 209.85.160.42 mail-pw0-f42.google.com Received: from [209.85.160.42] ([209.85.160.42:57684] helo=mail-pw0-f42.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 07/78-14908-B2BA8CD4 for ; Mon, 09 May 2011 23:04:12 -0400 Received: by pwj3 with SMTP id 3so3007800pwj.29 for ; Mon, 09 May 2011 20:04:07 -0700 (PDT) MIME-Version: 1.0 Received: by 10.68.65.40 with SMTP id u8mr8730457pbs.229.1304996647300; Mon, 09 May 2011 20:04:07 -0700 (PDT) Received: by 10.68.56.2 with HTTP; Mon, 9 May 2011 20:04:07 -0700 (PDT) In-Reply-To: <4DC8937C.6080609@sugarcrm.com> References: <4DC826B1.4090806@lerdorf.com> <4DC82A36.8090604@lerdorf.com> <4DC85FBE.2060005@lsces.co.uk> <4DC8885C.9090608@sugarcrm.com> <4DC8937C.6080609@sugarcrm.com> Date: Mon, 9 May 2011 23:04:07 -0400 Message-ID: To: Stas Malyshev Cc: "guilhermeblanco@gmail.com" , Lester Caine , PHP internals Content-Type: multipart/alternative; boundary=0015174be4e0986e5704a2e33583 Subject: Re: [PHP-DEV] Please let's not bitch about lazy users not learning C to implement THEIR missing feature. (Was Re: [PHP-DEV] 5.4 again) From: pierrick@webstart.fr (Pierrick Charron) --0015174be4e0986e5704a2e33583 Content-Type: text/plain; charset=ISO-8859-1 Hi, First, the actual patch is working but Implementation and behavior may change following all comments. This is still a work in progress and all comments/contributions from everybody are welcome :) That said : On 9 May 2011 21:23, Stas Malyshev wrote: > Hi! > > > Objects are only instantiated when requested (getAnnotations() or >> getAnnotation()) >> > > So how this happens - does the class store the text of the annotation? Or > expressions in the call are evaluated and stored, but the object is not > instantiated? > What if I call getAnnotation() repeatedly - are they re-instantiated or > stored somewhere, and if so - where? Annotations are stored in a HashTable of zend_annotation. struct _zend_annotation { char *annotation_name; unsigned int aname_len; HashTable *values; zval *instance; /* This is not permanent */ }; Once you call the getAnnotation method the reflection class will evaluate all expressions and instantiate the object. A reference of the object is then saved in the instance member of the structure. However, we have a plan to move this instance somewhere else like in a EG. > > > 2. What is permissible in the arguments of annotation - e.g. can I put any >>> expression there? >>> >> >> You are allowed to use any scalar value + array + any object that >> implements ReflectionAnnotation interface. >> > > By scalar value you mean constant value? Are constants allowed? Yes constants are allowed. Otherwise you can use annotation and static scalar (same thing as default value of class properties for example) > > > 3. What)> actually means and how it is supposed to be parsed? >>> >> >> It would instantiate a class Bar and would pass it as an instance of >> Foo that is also being created when doing getAnnotations() or >> getAnnotation('Foo') >> > > So when exactly Bar is instantiated - when getAnnotations() is called? When you call getAnnotation() the reflection method will instantiate Bar, and then instantiate the Foo object using the Bar instance as first parameter of the constructor. > > > 6. Do we need any special support for bytecode caches? >>> >> >> Yes. Every structure which can be annotated now will have a new member >> in their C structure which is annotations, this structure is populated >> at compile time and store all the metadata information. So if you have >> an opcode cache the compilation will not occur, so the annotations >> will be NULL. That's why the opcode cache will have to store the >> annotations, so that it can be retrieved every time. >> > > This then should be added to the proposal. > > We will add it Thanks for your feedback. Pierrick > -- > Stanislav Malyshev, Software Architect > SugarCRM: http://www.sugarcrm.com/ > (408)454-6900 ext. 227 > > -- > PHP Internals - PHP Runtime Development Mailing List > To unsubscribe, visit: http://www.php.net/unsub.php > > --0015174be4e0986e5704a2e33583--