Re: Native Annotation Syntax
| From: | Rowan Collins | Date: | Tue, 24 Nov 2015 19:05:58 +0000 |
| Subject: | Re: Native Annotation Syntax | ||
| References: | 1 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-89393@lists.php.net to get a copy of this message | ||
On 24/11/2015 16:30, Pedro Cordeiro wrote:
I'd been reading some old RFCs recently, and I found two RFCs on the subject of annotations, both by Guilherme Blanco. The first one, which proposed a native syntax for annotations, is marked as 'declined', and I couldn't find a discussion for it anywhere. The second one, which proposes retrieving annotation from DocBlocks through reflection is 'inactive', with no further explanation. I'd really like to see native annotation support for PHP that doesn't live in comments. Is there a reason those RFCs were dropped, or was it just lack of interest?I think one of the stumbling blocks in recent discussions of annotation support is just how much support should be provided; off the top of my head, this could be: - a few extra functions in reflection classes to parse the items within a docblock (docblocks are already handled in reflection separately from normal comments) - automatic instantiation of a set of standard Annotation objects with the text content above - automatic instantiation of classes based on the annotations provided - built-in support for applying annotations to the objects they appear on, perhaps in the form of full Aspect-Oriented Programming support At first sight, these seem like details which could be tweaked later, but they make a difference to what syntax to standardise: is the annotation name just a string, or a valid class name? is the value of the annotation just a string, or a parseable PHP expression? is it more useful to use the de facto existing syntax in DocBlocks, or to add a new keyword or operator? etc The devil, as ever, is in the detail. Regards, -- Rowan Collins [IMSoP]