Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:93326 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 34490 invoked from network); 14 May 2016 02:38:49 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 14 May 2016 02:38:49 -0000 Authentication-Results: pb1.pair.com header.from=kontakt@beberlei.de; sender-id=unknown Authentication-Results: pb1.pair.com smtp.mail=kontakt@beberlei.de; spf=permerror; sender-id=unknown Received-SPF: error (pb1.pair.com: domain beberlei.de from 74.125.82.46 cause and error) X-PHP-List-Original-Sender: kontakt@beberlei.de X-Host-Fingerprint: 74.125.82.46 mail-wm0-f46.google.com Received: from [74.125.82.46] ([74.125.82.46:35626] helo=mail-wm0-f46.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 53/D1-18975-5BF86375 for ; Fri, 13 May 2016 22:38:46 -0400 Received: by mail-wm0-f46.google.com with SMTP id e201so41699303wme.0 for ; Fri, 13 May 2016 19:38:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=beberlei-de.20150623.gappssmtp.com; s=20150623; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc; bh=hRYRtliiFaFRv5OU1aZ9dOAF4MFR0brXLz5CyQlSsQ8=; b=HyXj8+cqaLOs0OZ6GxlAAFOe25HqnTcNJiQUaFje/pUasFrkhd8UtYJnkeUDtN4u9G 434RW4w6bIxTcOFE2xPCxxKthIpIhRIZPww1s0DPI60Hd3MAW0UU1vGBBggaBH2w2TxY 945aBEMHxBemGLZKpONbxpExPRSIwEKTa1Nv77+WCHOJrdgW8R+jDtNTb2A3Kc3JKY1l +n8r38MAYT7Od/ju1q7nYrUJAtNZ9+Os97RIjBq/viv3opaYlX7pwucdVd4j5NHxGvVw 6NijMObdSrYm7znpNAVLvgj0DMnp/pcl2FoNmq3Zd4ulo0U9E/2axmTjV5UkQ7dDYpLB kCtg== 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:date :message-id:subject:from:to:cc; bh=hRYRtliiFaFRv5OU1aZ9dOAF4MFR0brXLz5CyQlSsQ8=; b=N/QT1Rkke5e8LF3RAKNkPCfZwtiJFCUB6H9pvJWJQED1lXB11GgBUDv97tJmjvUa9U ygMSoxbtanSdC9lyJIWFqTjcNvcHACK6Gqrdp/I8wP1oWu8VJtdK7i/tfl1kUOBmmNBW wvAizqbAYlmipdKHJr3RNbFoAwju7DYNSh52VoyJM6n6LUP4wCJbZjX9r8luFL5o/0GU enc/PgKqWYAoz2199xttViCxh/Xqxuifjv000soOh4KLGWJ4yO4rk6z+Q87PklhXlcsr 2RrFM5EGtYEd0ug9uUgDMO+bYBAvBx5JgjAVe0IiVazsQ+r8mgtBVdnKyktqpx92aMDE UrCg== X-Gm-Message-State: AOPr4FUyf9CAS6txdmCFx7W3hf17MtaNww57dGnmu66UMUtEAWzBbSD6J3g6oLR0390D1hJ0XKGM+1J2p1gGIw== MIME-Version: 1.0 X-Received: by 10.194.205.105 with SMTP id lf9mr18349616wjc.25.1463193523025; Fri, 13 May 2016 19:38:43 -0700 (PDT) Received: by 10.194.94.163 with HTTP; Fri, 13 May 2016 19:38:42 -0700 (PDT) X-Originating-IP: [93.129.108.29] In-Reply-To: References: Date: Sat, 14 May 2016 04:38:42 +0200 Message-ID: To: Rasmus Schultz Cc: PHP internals Content-Type: multipart/alternative; boundary=047d7b874c242d94420532c44aa2 Subject: Re: [PHP-DEV] [RFC] Simple Annotations From: kontakt@beberlei.de (Benjamin Eberlei) --047d7b874c242d94420532c44aa2 Content-Type: text/plain; charset=UTF-8 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. > The attributes RFC actually does not specific syntax or arrays, but either a scalar (number, string) or an ast\node. A proposal for arrays *would* actually be "closer to the language" as you describe it. 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. > > Please review and comment. I see you took my question about context from the other thread and defined annotations to be context less. You should add to the RFC examples of what is happening, if you do access context, for example access to undefined variable notices: <<$x>> class Foo {} $refl = new ReflectionClass('Foo'); var_dump($refl->getAttributes(Foo::class)); // PHP Notice: Undefined variable: x in Command line code on line 1 Still this is imho a weak point of your RFC. You already stated that a "simplified annotation" the way you see it is the expression wrapped in a closure: function () { return php-expression; } So if an annotation is a function/closure that belongs to its target (class, property, function, method, ...) then why wouldn't there be a way to specify arguments? The RFC should give an answer to that. The statement you add doesn't make sense without examples. How does dependency injection even work, when you don't have a context? "Annotations that do require context should explicitly ask for that context - for example, you could use an anonymous function, a callable, or an anonymous class, to provide context via dependency injection." greetings Benjamin > Thanks, > Rasmus Schultz > > -- > PHP Internals - PHP Runtime Development Mailing List > To unsubscribe, visit: http://www.php.net/unsub.php > > --047d7b874c242d94420532c44aa2--