Hi!
1. In Java annotations are a special type of an interface. But due the
lack of type hinting for scalar values we cannot use this construct,
because we cannot put some validation logic in an interface. My proposal
I'm not sure I understand - what scalar type hints have to do with it?
Anyway, annotation can't be interface since you'd have to instantiate it
to get the values. Interface can't have values.
is to create a new "annotation" type. This type should have the same
rules as a class and should contain all features proposed in the
ReflectionAnnotation class. With this construct it should be possible to
use named or unnamed parameters for an annotation.
I think this is very bad idea - to have language construct that is
exactly like class but has different set of features. If named
parameters are needed in PHP, let's add named parameters in PHP. But if
we decide they are not needed in PHP, they shouldn't be in one
particular corner of a particular syntax construct and nowhere else.
This makes the language hard to learn and hard to understand - you never
know what surprise the next syntax construct will bring you. I'm very
strongly against only one construct in the language having named
parameters syntax while other places don't.
2. The syntax for arrays should be the same as in PHP. So we can use the
[] as annotation separator. When we allow expressions in the form
Annotation(array('value' => 4 %2)) or Annotation(array('value' =>
!MY_CONSTANT)) which I think is a valid construct, then we cannot use
the ! or % as annotation separator.
Where this expression would be evaluated, in which context? Where would
the variable values be stored? What happens if they change?
I think with this changes we have a separate language construct like
traits, which does allow a new syntax.
Separate language construct doesn't mean separate rules. We are still in
the same language, so we can't just randomly put arbitrary set of
features together and call it a new construct. There should be some
commonality between different language constructs within the same language.
--
Stanislav Malyshev, Software Architect
SugarCRM: http://www.sugarcrm.com/
(408)454-6900 ext. 227
--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php