Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:93324 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 24740 invoked from network); 13 May 2016 22:45:21 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 13 May 2016 22:45:21 -0000 Authentication-Results: pb1.pair.com smtp.mail=ocramius@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=ocramius@gmail.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 74.125.82.49 as permitted sender) X-PHP-List-Original-Sender: ocramius@gmail.com X-Host-Fingerprint: 74.125.82.49 mail-wm0-f49.google.com Received: from [74.125.82.49] ([74.125.82.49:38034] helo=mail-wm0-f49.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id FC/C0-18975-00956375 for ; Fri, 13 May 2016 18:45:21 -0400 Received: by mail-wm0-f49.google.com with SMTP id g17so51154031wme.1 for ; Fri, 13 May 2016 15:45:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=N54ayrBt9Fn2On6Y58OLxy2K2SbfszaXJkwK0RFsgec=; b=I8iF/ylatkNQRJO8jiTNbJbAXCHaNkBwZQDkxFugDhIwf5+wdt0f3TIfFelOE/2+K4 97IYaklEVFjFJnmvclAP+hT1UyudAOSBeda5QN4FyOJbRkcC5IfImcphVUc3JjhSI3OX IDmiuKnuPTiGaVj7reIYYs0x2f04YJC3tVevNOPHcCgiY2GZcflO7h2Te+iU7yloLt31 GXNxwwludtGpcYC7bE4S5l1Cy3VOsx1d9prHditR9LMprv0MAMlHUOi/KmSXrbUfs627 EHiMGTTcrEX/+ntXCrrELC4GcvPufssGCHFM1NhohsEChy46eQEvRwgJslCgQaeUyWsp UXaw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=N54ayrBt9Fn2On6Y58OLxy2K2SbfszaXJkwK0RFsgec=; b=cTdLz6Jtp+4U2xfVPid4OjPVN9l31O0+iqXs0FfatkNnQ/PadIN1XtBFSGLLizaB4w 5Vacds7jKwVSx1ybND9MxHY46dJgUapytsD6k5mtXN3pO/8CyeztcbjSUbW9mKnsQFh7 /d/AZKxSFroUIqBSZCfHVA7GAupsn3N6xdZXP9Hqi5qTqW2RUB5J/Bul60bgtTR/YEAA to/SSyICfqE5W3eRlXamr9KcgPnIYHs2wVY89XcpAB3pruRLYiZfKvbElm9Vxzyu+01P iuGxLvgIIU71quDRcG7RCAwNCy1aozj9/RwfftsX2TUTwXvKrORPw8WbzrW90F5D/Kq6 o5Zw== X-Gm-Message-State: AOPr4FUJNkDmH72wg6Xx35L1uuQtU2zAoEL7NWBd3DA6LvvIAiRpMh/TXadpIbWTLQFK4kaP09qcFC9DjYz7AA== X-Received: by 10.28.152.212 with SMTP id a203mr5908694wme.95.1463179518206; Fri, 13 May 2016 15:45:18 -0700 (PDT) MIME-Version: 1.0 Received: by 10.194.170.167 with HTTP; Fri, 13 May 2016 15:44:58 -0700 (PDT) In-Reply-To: <50ca8a6b-ab74-370a-a767-a2d2e334289b@texthtml.net> References: <50ca8a6b-ab74-370a-a767-a2d2e334289b@texthtml.net> Date: Sat, 14 May 2016 00:44:58 +0200 Message-ID: To: Mathieu Rochette Cc: Davey Shafik , Rasmus Schultz , PHP internals Content-Type: multipart/alternative; boundary=001a114b97746ce6d70532c107b0 Subject: Re: [PHP-DEV] [RFC] Simple Annotations From: ocramius@gmail.com (Marco Pivetta) --001a114b97746ce6d70532c107b0 Content-Type: text/plain; charset=UTF-8 Love the simplicity of the RFC, but I can already see people doing terrible things with it: << new DateTimeImmutable() >> << log(get_instance('logger')) >> And other global-state related stuff. TBH, I'd rather just allow a constant array (with constant expressions only), and that would be good enough :-) Cheers, Marco Pivetta http://twitter.com/Ocramius http://ocramius.github.com/ On 13 May 2016 at 15:15, Mathieu Rochette wrote: > > > 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 > > --001a114b97746ce6d70532c107b0--