On Mon, Feb 16, 2015 at 6:41 PM, Rowan Collins <rowan.coll...@gmail.com <mailto:rowan.coll...@gmail.com>> wrote:

   Is there any value in deciding the initial syntax for 7.0, and
   implementing only non-parameterised annotations, i.e. you can call
   hasAnnotation(string): bool but nothing else?


Dmitry Stogov wrote on 16/02/2015 16:02:
this will work, of course, and robust implementation wouldn't take more than a day :) but it'll require user-level parser again. no big advantage in comparison to doc-block.

No user-level parser would be required (or even possible), because parameters would be illegal, not just unparsed.

So, for example, the following would be legal in 7.0:

<<IsMagic>>
function foo() { }

if ( (new ReflectionFunction('foo'))->hasAnnotation('IsMagic') ) ...


But the following would be illegal, even though a similar syntax would be being prototyped for use in 7.1:

<<HasMagic('Expelliamus!')>>
function foo() { }

$magic = (new ReflectionFunction('foo'))->getAnnotation('HasMagic');


A few use cases would be possible just with boolean flags, and it would give us a base to work with going forward.

It also avoids the situation (as discussed in another thread) of trying to implement every detail of the implementation of the feature before checking for consensus. In this case we can check that people are in favour of:
1) adding annotations as a core feature
2) the basic syntax (<Foo>, <<Foo>>, [Foo], @Foo, etc)

If there's an overwhelming Yes, that's a confidence boost for whoever works on the harder parts over the following months.

Regards,
--
Rowan Collins
[IMSoP]


Reply via email to