Re: [PHP-DEV] Attributes/Annotations Case Study: Drupal

2016-05-08 Thread Fleshgrinder
On 5/6/2016 8:02 AM, Dmitry Stogov wrote: > On 05/06/2016 05:06 AM, Jesse Schalken wrote: >> If you're going to say "do what you want" with regards to annotations, >> then >> just let them be a text string. Parsing the annotation as PHP but not >> evaluating it as PHP seems a very strange and

Re: [PHP-DEV] Attributes/Annotations Case Study: Drupal

2016-05-06 Thread Dmitry Stogov
On 05/06/2016 05:06 AM, Jesse Schalken wrote: If you're going to say "do what you want" with regards to annotations, then just let them be a text string. Parsing the annotation as PHP but not evaluating it as PHP seems a very strange and arbitrary half-way point. If the thing consuming the AST

Re: [PHP-DEV] Attributes/Annotations Case Study: Drupal

2016-05-05 Thread Jesse Schalken
If you're going to say "do what you want" with regards to annotations, then just let them be a text string. Parsing the annotation as PHP but not evaluating it as PHP seems a very strange and arbitrary half-way point. If the thing consuming the AST is expected to eval() it, then why didn't PHP do

Re: [PHP-DEV] Attributes/Annotations Case Study: Drupal

2016-05-05 Thread Dan Ackroyd
On 5 May 2016 at 15:24, Larry Garfield wrote: > because it doesn't define "right way". Good. > I could easily see, for instance, Doctrine annotations building the > first, PHPUnit the second, and Zend the 3rd. Good! It's not the job of PHP core to tell people how to

Re: [PHP-DEV] Attributes/Annotations Case Study: Drupal

2016-05-05 Thread Rowan Collins
Larry Garfield wrote on 05/05/2016 15:24: <> Translator)>> <> <> I could easily see, for instance, Doctrine annotations building the first, PHPUnit the second, and Zend the 3rd. Those would all be legal-ish, but

Re: [PHP-DEV] Attributes/Annotations Case Study: Drupal

2016-05-05 Thread Larry Garfield
On 05/05/2016 02:07 AM, Dmitry Stogov wrote: Maybe that's what we want to have here - freedom for everybody to invent their own languages - but I fear the danger of fragmentation here and also people implementing tons of slightly different incompatible parsers for ASTs that are generated.

Re: [PHP-DEV] Attributes/Annotations Case Study: Drupal

2016-05-05 Thread Rowan Collins
Stanislav Malyshev wrote on 05/05/2016 07:48: The key idea of RFC was not to invite another language for meta-data, >but use PHP language itself. This is a good way to avoid handling a lot of issue, but what I am afraid of is that with this solution, what would happen that people start doing

Re: [PHP-DEV] Attributes/Annotations Case Study: Drupal

2016-05-05 Thread Lester Caine
On 05/05/16 08:34, Dmitry Stogov wrote: >> I think this way can give a good start point with possibility to >> standardize handling of attributes in the future. From the PHP engine >> side, all attributes are AST nodes that can be processed later on the >> userland side. >> > Something like this

Re: [PHP-DEV] Attributes/Annotations Case Study: Drupal

2016-05-05 Thread Dmitry Stogov
On 05/05/2016 10:24 AM, Alexander Lisachenko wrote: Hello, internals! 2016-05-05 9:48 GMT+03:00 Stanislav Malyshev >: Maybe that's what we want to have here - freedom for everybody to invent their own languages - but I fear the

Re: [PHP-DEV] Attributes/Annotations Case Study: Drupal

2016-05-05 Thread Alexander Lisachenko
Hello, internals! 2016-05-05 9:48 GMT+03:00 Stanislav Malyshev : > Maybe that's what we want to have here - freedom for everybody to invent > their own languages - but I fear the danger of fragmentation here and > also people implementing tons of slightly different

Re: [PHP-DEV] Attributes/Annotations Case Study: Drupal

2016-05-05 Thread Dmitry Stogov
On 05/05/2016 09:48 AM, Stanislav Malyshev wrote: Hi! It's also possible to write: <> you don't need to split your annotation into many attributes. You should just adopt its

Re: [PHP-DEV] Attributes/Annotations Case Study: Drupal

2016-05-05 Thread Stanislav Malyshev
Hi! > It's also possible to write: > > < "id" = "system_branding_block", > "admin_label" = @Translation("Site branding") > ]))>> > > > you don't need to split your annotation into many attributes. You should > just adopt its syntax to become a valid PHP

Re: [PHP-DEV] Attributes/Annotations Case Study: Drupal

2016-05-05 Thread Dmitry Stogov
On 05/01/2016 10:47 PM, Larry Garfield wrote: On 04/30/2016 06:21 PM, Rowan Collins wrote: On 30/04/2016 23:45, Stanislav Malyshev wrote: Oh, of course you can have methods, but then it is strange conceptually - you have a normal class, which some other part of the language just uses for

Re: [PHP-DEV] Attributes/Annotations Case Study: Drupal

2016-05-05 Thread Dmitry Stogov
On 04/30/2016 02:47 AM, Larry Garfield wrote: Most of the examples that have been given so far are either trivial boolean flags or data validation rules to be evaled. In practice, very little of Drupal's use of annotations in Drupal 8 fit either category. Rather, they're used primarily as,

Re: [PHP-DEV] Attributes/Annotations Case Study: Drupal

2016-05-04 Thread Jesse Schalken
On 4 May 2016 10:41 pm, "Rowan Collins" wrote: > > > You could either think of this as "setting lots of variables": > > new Foo { $bar = 1, $baz = 2 } > > or you could think of it as "an object literal like an array literal": > > new Foo { 'bar' => 1, 'baz' => 2 } > I

Re: [PHP-DEV] Attributes/Annotations Case Study: Drupal

2016-05-04 Thread Rowan Collins
Jesse Schalken wrote on 04/05/2016 13:20: (maybe there should be a $ before the property names, not sure) And there's the rub! :P When named parameters have been discussed before, there was a lot of bikeshedding over what the syntax should look like, and this is arguably a very similar

Re: [PHP-DEV] Attributes/Annotations Case Study: Drupal

2016-05-04 Thread Jesse Schalken
On Sat, Apr 30, 2016 at 9:47 AM, Larry Garfield wrote: > 3) Some way to provide a data definition for the annotation that can be > checked at compile time. This could be classes, a la Doctrine. It could be > a new Annotation type as others have suggested. It could be

Re: [PHP-DEV] Attributes/Annotations Case Study: Drupal

2016-05-02 Thread Marco Pivetta
Hey Stas, On 1 May 2016 at 00:14, Stanislav Malyshev wrote: > > $def instanceof MyAnnotation; //TRUE > > That looks fine, however the problem is that if MyAnnotation is a class, > then PHP does not have multiple inheritance, so it's the only class it > can be. And given

Re: [PHP-DEV] Attributes/Annotations Case Study: Drupal

2016-05-01 Thread Stanislav Malyshev
Hi! > It would never occur to me to not have it regenerated on each access. If I want to cache it I will do so myself, thanks. Not sure why would you care. These should be value objects, so they should keep no state and as such it shouldn't matter when they are generated and how many of them. >

Re: [PHP-DEV] Attributes/Annotations Case Study: Drupal

2016-05-01 Thread Larry Garfield
On 04/30/2016 06:21 PM, Rowan Collins wrote: On 30/04/2016 23:45, Stanislav Malyshev wrote: Oh, of course you can have methods, but then it is strange conceptually - you have a normal class, which some other part of the language just uses for something else that classes are not routinely used

Re: [PHP-DEV] Attributes/Annotations Case Study: Drupal

2016-04-30 Thread Rowan Collins
On 30/04/2016 23:45, Stanislav Malyshev wrote: Oh, of course you can have methods, but then it is strange conceptually - you have a normal class, which some other part of the language just uses for something else that classes are not routinely used for. I.e., does it call a constructor? When?

Re: [PHP-DEV] Attributes/Annotations Case Study: Drupal

2016-04-30 Thread Stanislav Malyshev
Hi! > What would prevent the class from having methods? > > class MyAnnotation > { > public $foo; > public $bar; > public function doStuff() { ... } > } Oh, of course you can have methods, but then it is strange conceptually - you have a normal class, which some other part of the language just

Re: [PHP-DEV] Attributes/Annotations Case Study: Drupal

2016-04-30 Thread Rowan Collins
On 30/04/2016 23:14, Stanislav Malyshev wrote: $def instanceof MyAnnotation; //TRUE That looks fine, however the problem is that if MyAnnotation is a class, then PHP does not have multiple inheritance, so it's the only class it can be. And given that your class has no methods, $def has no

Re: [PHP-DEV] Attributes/Annotations Case Study: Drupal

2016-04-30 Thread Stanislav Malyshev
Hi! > <> Here you have essentially created a named parameter syntax. That may be a problem later, especially if we do implement named parameters and this won't be the syntax we choose. > $def instanceof MyAnnotation; //TRUE That looks fine, however the

Re: [PHP-DEV] Attributes/Annotations Case Study: Drupal

2016-04-30 Thread Larry Garfield
On 04/30/2016 04:12 PM, Stanislav Malyshev wrote: Hi! That you for bringing real usage examples. This is an interesting point to consider. Reading through it, however, I can't help but wonder why these things are not just data? I mean, why they are kept in the comments? If there are reasons

Re: [PHP-DEV] Attributes/Annotations Case Study: Drupal

2016-04-30 Thread Stanislav Malyshev
Hi! That you for bringing real usage examples. This is an interesting point to consider. Reading through it, however, I can't help but wonder why these things are not just data? I mean, why they are kept in the comments? If there are reasons like performance, there could be solutions developed,

Re: [PHP-DEV] Attributes/Annotations Case Study: Drupal

2016-04-30 Thread Larry Garfield
On 04/29/2016 11:54 PM, Pierre Joye wrote: Hi Larry, On Apr 30, 2016 6:48 AM, "Larry Garfield" wrote: Most of the examples that have been given so far are either trivial boolean flags or data validation rules to be evaled. In practice, very little of Drupal's use of

Re: [PHP-DEV] Attributes/Annotations Case Study: Drupal

2016-04-29 Thread Pierre Joye
Hi Larry, On Apr 30, 2016 6:48 AM, "Larry Garfield" wrote: > > Most of the examples that have been given so far are either trivial boolean flags or data validation rules to be evaled. In practice, very little of Drupal's use of annotations in Drupal 8 fit either