Fleshgrinder wrote on 28/04/2016 18:33:
Actually Microsoft got it exactly right and they are explaining in depth
what I wrote as well. The result of an annotation is an attribute. So it
is only natural to call the classes attributes.
public class Customer {
[DataType(DataType.EmailAddress)]
public string EmailAddress { get; set; }
}
The `[DataType(DataType.EmailAddress)]` is the annotation and the
attribute that we add to the property is a DataTypeAttribute of DataType
EmailAddress.
Interesting; do you have a link to where this terminology is explained?
Most of the articles I've seen just refer to "attributes", and the link
you have doesn't really explain that at all, it has namespaces with
"annotation" in the name, but uses the word "attribute" everywhere in
the actual text.
According to this page, the syntax which applies an attribute to some
code is called an "attribute specification":
https://msdn.microsoft.com/en-us/library/aa664616.aspx
Here public and EmailAddress are attributes of the instance variable
email and hence properties of a property that together result in a class
or instance attribute.
Again, I've not seen anything saying that .net refers to the "public"
keyword as an "attribute", or in any way treats it as equivalent to the
attribute (or, if you insist, annotation) syntax. In fact, the article I
quoted earlier explicitly distinguishes the two, referring to "public"
etc as "method-modifiers", and seems clear to me that they are not the
same thing as attributes:
https://msdn.microsoft.com/en-us/library/aa664611%28v=vs.71%29.aspx
The name they chose is okay because Perl does not offer any other way of
adding attributes to any kind of data in any way (at least none that I
am aware off but I am not a Perl programmer). Hence, it is not too
dangerous to call this functionality attributes as it would be in our
context where many other attributes are already available.
Surely under your definition scope modifiers like "local"/"global" and
"my"/"our" would be "attributes"? I think you're really clutching at
straws to distinguish this case from any of the others, just because it
doesn't agree with your assumptions.
I haven't looked through any of your other links to see if you've fallen
foul of similar confirmation bias, but am satisfied in my mind that
there are plenty of people outside Hack who call them "attributes".
No confirmation bias
By "confirmation bias", I meant that you'd gone out looking for
confirmation that people called them "annotations", rather than
researching what each language calls them.
For instance, you linked to a Rust page, which happened to contain the
word "annotation", but on closer inspection is actually using the terms
in exactly the opposite way from you: the "lifetime annotation" here is
a specific syntax to do with lifetimes, and is an "annotation" in the
loose sense of "you are annotating the source code". Meanwhile, in the
menu on the left, we can see a section on "Attributes", which look much
more like arbitrary metadata of the sort we are discussing right now:
http://rustbyexample.com/attribute.html
I think a survey of what different languages call their metadata
features would be interesting, but so far, I'm not seeing a clear bias
in favour of one or the other.
Like I say, I personally prefer the term "annotations", but I'm not
going to discount the evidence that major languages like C#/.net, Perl,
and Rust have chosen the name "attributes" instead.
Regards,
--
Rowan Collins
[IMSoP]
--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php