Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:93312 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 87510 invoked from network); 13 May 2016 13:16:14 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 13 May 2016 13:16:14 -0000 Authentication-Results: pb1.pair.com smtp.mail=mathieu@texthtml.net; spf=unknown; sender-id=unknown Authentication-Results: pb1.pair.com header.from=mathieu@texthtml.net; sender-id=unknown Received-SPF: unknown (pb1.pair.com: domain texthtml.net does not designate 62.210.206.189 as permitted sender) X-PHP-List-Original-Sender: mathieu@texthtml.net X-Host-Fingerprint: 62.210.206.189 texthtml.net Received: from [62.210.206.189] ([62.210.206.189:36162] helo=texthtml.net) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 82/D2-01216-C93D5375 for ; Fri, 13 May 2016 09:16:13 -0400 Received: by texthtml.net (Postfix, from userid 65534) id 21AE42A3; Fri, 13 May 2016 13:16:10 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on b7ba30992c3e X-Spam-Level: X-Spam-Status: No, score=-1.0 required=5.0 tests=ALL_TRUSTED,HTML_MESSAGE autolearn=ham autolearn_force=no version=3.4.1 Received: from [192.168.1.18] (stunnel_mail_1.mail_default [172.27.0.8]) (Authenticated sender: mathieu@texthtml.net) by texthtml.net (Postfix) with ESMTPA id 0465A2A1; Fri, 13 May 2016 13:15:53 +0000 (UTC) To: Davey Shafik , Rasmus Schultz References: Cc: PHP internals Message-ID: <50ca8a6b-ab74-370a-a767-a2d2e334289b@texthtml.net> Date: Fri, 13 May 2016 15:15:52 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:47.0) Gecko/20100101 Thunderbird/47.0a2 MIME-Version: 1.0 In-Reply-To: Content-Type: multipart/alternative; boundary="------------6431C812812802E714022C34" Subject: Re: [PHP-DEV] [RFC] Simple Annotations From: mathieu@texthtml.net (Mathieu Rochette) --------------6431C812812802E714022C34 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit On 05/13/2016 02:57 PM, Davey Shafik wrote: > On Fri, May 13, 2016 at 2:11 PM, Rasmus Schultz wrote: > >> Dear Internals, >> >> I'm announcing a simplified RFC for annotations: >> >> https://wiki.php.net/rfc/simple-annotations >> >> It's an alternative to the proposed Attributes RFC and the (2010) >> Annotations RFC. >> >> I'm attempting with this to describe a feature that is closer to the >> language than what is proposed by the Attributes RFC, by permitting >> the use of any valid PHP expression as an annotation value. >> >> Where the Attributes RFC proposes new syntax for what is essentially >> arrays, this proposal instead permits you to use actual arrays, e.g. >> without inventing any new syntax. It also allows you to use values of >> any other type, including objects. This makes the proposed feature >> more immediately useful, with a minimal learning curve. >> >> Compared with the old Annotations RFC (and Doctrine Annotations, etc.) >> this proposal does not attempt to define or enforce any rules about >> what annotations are, permitted usage, inheritance rules, etc. - >> instead it adds a very simple language feature upon which the >> community may choose to build (and evolve) facilities that implement >> additional rules and logic. >> >> My hope is that, if we can agree on something very small and simple, >> we can defer the more opinionated discussions about rules and logic to >> the community. >> >> In my opinion, language features should be simple, and consistent with >> the language - I believe the way to do that, is to avoid discussions >> about how such as facility should be used, and instead focus on how it >> should work. There is a lot of opinion built into the old Annotations >> RFC, and into Doctrine - features that attempt to dictate how the >> feature should be used. I don't believe the language should dictate >> what is or isn't correct or appropriate use. > > I think I like this, however a couple of simple questions: > > 1) Any chance for (optionally) _naming_ annotations? It would be nice to be > able to do: ->getAnnotation('table') and not have to handle unnecessary > annotations not sure you need that, you can do this instead: ->getAnnotations(Table::class) however it won't throw an error if you have more than one "Table::class annotation" whereas I supposed you would expect so with a named annotation > > 2) I like the idea of Hacks memoize for example, how do you see those being > implemented? Or don't you? if Rasmus goal is to that "we can agree on something very small and simple" I guess it would best be left for another rfc > > 3) When are annotations executed? On ->getAnnotations()? Every time? given they are context free, I suppose they would be executed on the first call only but what about this kind of annotation classes? : class Counter { private static $i = 0; private $n; function __construct() { $this->n = self::$i++; } function get() { return $this->n; } } both the getAnnotations() calls order and whether or not annotations are executed every time would make a difference > > Thanks, > -- Mathieu Rochette --------------6431C812812802E714022C34--