Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:92875 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 47928 invoked from network); 28 Apr 2016 17:33:36 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 28 Apr 2016 17:33:36 -0000 Authentication-Results: pb1.pair.com header.from=php@fleshgrinder.com; sender-id=unknown Authentication-Results: pb1.pair.com smtp.mail=php@fleshgrinder.com; spf=permerror; sender-id=unknown Received-SPF: error (pb1.pair.com: domain fleshgrinder.com from 212.232.25.162 cause and error) X-PHP-List-Original-Sender: php@fleshgrinder.com X-Host-Fingerprint: 212.232.25.162 mx206.easyname.com Received: from [212.232.25.162] ([212.232.25.162:44228] helo=mx206.easyname.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id FF/D3-28296-E6942275 for ; Thu, 28 Apr 2016 13:33:34 -0400 Received: from cable-81-173-133-226.netcologne.de ([81.173.133.226] helo=[192.168.178.20]) by mx.easyname.com with esmtpsa (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.84_2) (envelope-from ) id 1avpoh-0007w9-8Q; Thu, 28 Apr 2016 17:33:31 +0000 Reply-To: internals@lists.php.net References: <57211D05.6020002@fleshgrinder.com> To: Rowan Collins , internals@lists.php.net Message-ID: <57224957.8090504@fleshgrinder.com> Date: Thu, 28 Apr 2016 19:33:11 +0200 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:38.0) Gecko/20100101 Thunderbird/38.7.2 MIME-Version: 1.0 In-Reply-To: Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="xOg20kMMG90G1tShEH32kuQ1Fg4bUNM9q" X-ACL-Warn: X-DNSBL-BARRACUDACENTRAL Subject: Re: [PHP-DEV] [RFC] PHP Annotations VS Attributes From: php@fleshgrinder.com (Fleshgrinder) --xOg20kMMG90G1tShEH32kuQ1Fg4bUNM9q Content-Type: multipart/mixed; boundary="tGwJw4XHVS3tnjVH3MmlAHhN4Hol0cbfc" From: Fleshgrinder Reply-To: internals@lists.php.net To: Rowan Collins , internals@lists.php.net Message-ID: <57224957.8090504@fleshgrinder.com> Subject: Re: [PHP-DEV] [RFC] PHP Annotations VS Attributes References: <57211D05.6020002@fleshgrinder.com> In-Reply-To: --tGwJw4XHVS3tnjVH3MmlAHhN4Hol0cbfc Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable On 4/28/2016 11:36 AM, Rowan Collins wrote: > While I personally prefer the name "annotations", I don't see it as > particularly urgent, or nearly as clear-cut as you claim. >=20 That's okay and why we are discussing things. ;) On 4/28/2016 11:36 AM, Rowan Collins wrote: > I clicked through on your MSDN link [1] because I was pretty sure .net > referred to them as "attributes", and am amused to find sentences like > this: >=20 >> The System.ComponentModel.DataAnnotations namespace contains the > classes that are used as data attributes. >=20 > In other words, the implementer of that particular library preferred th= e > word "annotations", but the language/framework itself calls them > "attributes"; here's a nice summary [2]: >=20 >> For example, the accessibility of a method in a class is specified by > decorating it with the /method-modifiers/ |public|, |protected|, > |internal|, and |private|. C# enables programmers to invent new kinds o= f > declarative information, called attributes. >=20 > So, that's one rather large ecosystem that calls them "attributes". >=20 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. https://msdn.microsoft.com/en-us/library/system.componentmodel.dataannota= tions.datatypeattribute%28v=3Dvs.95%29.aspx Note that you could achieve the above in PHP with the property type RFC: class Customer { public EmailAddress $email; } 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. On 4/28/2016 11:36 AM, Rowan Collins wrote: > Your claims for Perl also don't make much sense: >=20 >> Last but not least, Perl has/attribute/ support. However, Perl actual= ly >> uses it for interaction with*all* attributes that can be set. Hence, >> this is what attributes really do. >> >> http://perldoc.perl.org/attributes.html >=20 > None of the built-in attributes mentioned in that manual are standard > syntax used in the majority of Perl programs; in fact, they are all > marked as experimental, and most of the examples are of defining custom= > attributes. As far as I can see, this is Perl's version of precisely th= e > feature that is being proposed for PHP. >=20 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. The fact that it is experimental does not add anything to this discussion= =2E On 4/28/2016 11:36 AM, Rowan Collins wrote: > I haven't looked through any of your other links to see if you've falle= n > foul of similar confirmation bias, but am satisfied in my mind that > there are plenty of people outside Hack who call them "attributes". >=20 >=20 > [1] https://msdn.microsoft.com/en-us/library/dd901590%28VS.95%29.aspx > [2] https://msdn.microsoft.com/en-us/library/aa664611%28v=3Dvs.71%29.as= px >=20 > Regards, No confirmation bias and as I said, Microsoft got it completely right. To give you an analogy, Microsoft is calling the egg an egg and the chicken a chicken. We would be calling a chicken an egg because it is able to create eggs. In other words: an *annotation* allows you to add additional custom *attributes* to data that cannot be added by other means. :) --=20 Richard "Fleshgrinder" Fussenegger --tGwJw4XHVS3tnjVH3MmlAHhN4Hol0cbfc-- --xOg20kMMG90G1tShEH32kuQ1Fg4bUNM9q Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 iQIcBAEBCAAGBQJXIklgAAoJEOKkKcqFPVVrQMoQAMwftt7PMnBlL4FnGvgHNHR+ 67DFS4/cH+keovgBwEeiUtM/C+Luq/xNXoXvhtAw3ip/NTfStpO/7yApcoTFbSJP wlcQVV5x7ROhugzBnwZp3Ts+iEM5Ubg4UhR2WiVoaBA1n4oDEyC4v1YzUV4U7rRb 0JyIX+2/P3XhSqVDKK20uDviCny3gf9rrsJpHTDFqHkM3F65cX9LihkQIjXMqkLI r9YZU2wFyxpvIVHhwnzkb2Vi2jJl1JNVC81bZlvxk23OS5FkpOabp2k6Uzp4y06e Zm7vA56AJmsfpxYuyla0iWrYN3te6pp0m0i1oHWbh4bUIpvw2FWDSAfUG10J9wp+ lNSrv0NOouGiyLKzDf/hC2RseqBEEdOlOwqvYW4rX/P/5CUYCN1XsRRq/LkLVKMo BkhogRkoVb42r5BZwZOePB/OOufiryVULqEuD6o+hkfi9bkwRZodEJOHffBN7VJV gd5FS+Sh2cI3oY3GtB+Mg+KL+CZAT566dbLKj1lWlIvnswH/rTIl0j9YPD0MaL1O Mj4DZO4e2Qpe/hwXyHI50OivSNsUEuBEXDe3G536f7O3WGj7pDafgowwff/tZuQJ cyQe7fe/a7UUriwgrBn/wSF0cfWeH8kbZFlhPnNuWTbOzPW9V8N6Il0ikORT/VxD VPu8OkRx5ylqJBtyoKQN =I0i1 -----END PGP SIGNATURE----- --xOg20kMMG90G1tShEH32kuQ1Fg4bUNM9q--