Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:92688 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 7451 invoked from network); 24 Apr 2016 12:22:03 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 24 Apr 2016 12:22:03 -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.28.125 cause and error) X-PHP-List-Original-Sender: php@fleshgrinder.com X-Host-Fingerprint: 212.232.28.125 mx204.easyname.com Received: from [212.232.28.125] ([212.232.28.125:36769] helo=mx204.easyname.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id BA/C3-21220-A6ABC175 for ; Sun, 24 Apr 2016 08:22:02 -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 1auJ30-0000UA-UM; Sun, 24 Apr 2016 12:21:59 +0000 Reply-To: internals@lists.php.net References: <571C8E3B.3010105@php.net> <571CB29D.8040208@fleshgrinder.com> To: Benjamin Eberlei , PHP Internals Cc: Zeev Suraski , Sebastian Bergmann Message-ID: <571CBA5D.4020905@fleshgrinder.com> Date: Sun, 24 Apr 2016 14:21:49 +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="QrFUUh6QweNJH2W2hO3SO6RbsdWAPfwRC" X-ACL-Warn: X-DNSBL-BARRACUDACENTRAL Subject: Re: [PHP-DEV] [RFC] PHP Attributes From: php@fleshgrinder.com (Fleshgrinder) --QrFUUh6QweNJH2W2hO3SO6RbsdWAPfwRC Content-Type: multipart/mixed; boundary="oONmbL63daWhVSVKCDV9xENolIKc4UpSm" From: Fleshgrinder Reply-To: internals@lists.php.net To: Benjamin Eberlei , PHP Internals Cc: Zeev Suraski , Sebastian Bergmann Message-ID: <571CBA5D.4020905@fleshgrinder.com> Subject: Re: [PHP-DEV] [RFC] PHP Attributes References: <571C8E3B.3010105@php.net> <571CB29D.8040208@fleshgrinder.com> In-Reply-To: --oONmbL63daWhVSVKCDV9xENolIKc4UpSm Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable On 4/24/2016 1:58 PM, Benjamin Eberlei wrote: > The article *you* reference about attributes lists C# attributes as the= > *first* example. >=20 > And defines an attribute as: >=20 > "For clarity, attributes should more correctly be considered metadata > . An attribute is frequently an= d > generally a property of a property." >=20 > HHVM uses the name attribute, for the same syntax that Dimitry proposes= > here. >=20 > *MUST* is such a strong word in this context, this is not an 0 XOR 1 is= sue. >=20 On 4/24/2016 2:07 PM, Zeev Suraski wrote: > Thanks for the programming 101 lesson :) > > I pointed out to Sebastian, who suggested that 'attributes' are equivalent to 'member variables' or 'properties', that they're very consistently referred to in PHP as 'properties' and that I'm not aware that they were ever referred to as 'attributes'. > > Nothing in your links suggested otherwise, arguably the opposite. According to https://en.wikipedia.org/wiki/Attribute_(computing), "An attribute is frequently and generally a property of a property", and while "the term attribute can and is often treated as equivalent to a property depending on the technology being discussed", when the technology in question is PHP, this is not the case. > > Of course, member visibility modifiers and access modifiers (public/protected/private, static, etc.) are a different thing. Saying member variables are referred to as attributes (incorrect in the context of PHP, AFAIK) is very different from saying these modifiers are referred to as attributes (correct and sensible). > > Last, we're absolutely allowed to have our own definitions of terms as long as they're sensible. Both attributes and annotations are sensible here, and the fact there may be languages that treat attributes as equivalent to properties isn't a strong reason against using that term for something sensible, that is different from these other languages, in PHP. > > Zeev > As I said, unless somebody knows an even better term. It also depends on which source code is going to be allowed to have this kind of additional metadata. If we limit it to functions, classes, properties, and methods: /all good./ Why? We might want to allow adding of metadata to other parts of the source code in the future. I already asked regarding annotating files themselves (as is possible with PhpDoc's file-level docblock) and then it becomes complicated. I am not saying we need this, I am saying we need to clarify this. Using the term attribute without defining what the term means is problematic. I know, Facebook/HHVM/Hack but we are not required to be compliant with them and they are not our benchmark. Using the term annotation is not so problematic because it has a clear definition (not only in computer science) and it does not say anything about the applicability of what it does, it only states the functionality of the feature itself: /adding metadata to data/. You want to avoid writing extensive definitions of terms that are going to be used since people then need to learn these terms. Just think about the normal usage of the word attribute in language, e.g. describe the attributes of this image. The answer could be "it shows a woman with long hair and blue eyes". Hence, /long hair/ and /glue eyes/ are attributes of the woman. However, asking for the annotations of this image would result in a different answer, the asked person, assuming she knows what the word in general means, turns the image and would tell us the date and time it was taken or printed, or maybe the ISO level, ... whatever. Is *public* an attribute of the property? /Yes/ Is *static* an attribute of the method? /Yes/ Is *name* an attribute of a person? /Yes/ Is *__toString* an attribute of the class? /Yes, behavioral/ Is *inattentive* an attribute of the child? /Yes/ =2E.. So, what should `$r->getAttributes()` return? It is to broad, it is to generic, it is too often mixed up. `$r->getAnnotations()` is less ambiguous in the context of programming and thus a better choice. I hope you can follow my /Gedankenspiel/ (mind game) better now. :) --=20 Richard "Fleshgrinder" Fussenegger --oONmbL63daWhVSVKCDV9xENolIKc4UpSm-- --QrFUUh6QweNJH2W2hO3SO6RbsdWAPfwRC 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 iQIcBAEBCAAGBQJXHLpgAAoJEOKkKcqFPVVrKykP/jVIEwinRNsasalaHDlbHk0y KLnD71NXDXCHAlcnQ392vbjkNW8bWAkYOz8LXwXPMRC3RKIRos2L7p+HIpFBBnMN AvDgiyafiQ4hsibslQHG1e3xMesE5xlhq8hmTYpgrrefnbNJjn7ZC8sV+Lvyp2W+ IshJ6v2p1ENRoJlI/Dnz/TmE1OaFOklXF7oQTUMJDzIjV17I0qT4HzLVcQ8qTgtx g4xT+UoruwYhN650gO7KLGU1/6quZlgTGKQr5yguBIMQzdYnU8sRMeSd55JCXpKD 6dTogpALQQHtfeyHeL3vD+nn+/wZ1bsBoarDDZSzgEhQyGoRX+eaJab4B7OlL24Y XPjcqLI6+GMz37ZA+hLMI33tmBsbS0kIrYwmgvk+uYdx23CGy1lYFfUwiOXLlWZD qaRe6uDWBzxyTW7guQIdKZLqbSWBNSMAHFzUn48IncUwvOOgPMOg0b6505q3c6ww 7Aiwh//z5Z45RUva/+H5wHCHICQ8n3gZ/OzopZ8GMMdq80UZMtWSOBqHH4Ggvpa6 n/ExSNsGGg3v+QkV/yrs3A1JhXNYKrXLQOSE411qGQimPVaGcEYaFA0WsKwJStUh /ylB10/aXPWsHD7xQSkmRZHGAnvCt/olBlvT8ovAm0HiRtRKEy8gVQyd8NiVtlAF dsPAbDAYqsaqtAweHwo9 =MdYI -----END PGP SIGNATURE----- --QrFUUh6QweNJH2W2hO3SO6RbsdWAPfwRC--