Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:103818 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 60847 invoked from network); 24 Jan 2019 11:44:44 -0000 Received: from unknown (HELO relay.alfa-bank.info) (217.12.96.27) by pb1.pair.com with SMTP; 24 Jan 2019 11:44:44 -0000 Received: from localhost (unknown [127.0.0.1]) by IMSVA (Postfix) with SMTP id 263CB6E0BC; Thu, 24 Jan 2019 11:22:49 +0300 (+03) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=alfabank.ru; s=mainstream; t=1548318169; bh=Di9Z8Z0fSlKwWIlWdmrwKOXP47baDdeFmK6A/Dn1Krs=; h=To:From:Date; b=JYKUN4OWLWuerOh4vseazZouxuv8bZrIQRTMpiWToGZouWm7t8O++2BD/QVpR1rSB 5bvzarszP5ZYw5z9N1PnGlbQdSkTwOnhtUjZLCo2ZK4rx//5hHIjIl1AAHrJuZirnH K3XK9Lvq1uLSpwRptNCf1UWMsYX7AQLMlo2WSfe0= Received: from relay.alfa-bank.info (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 2F5A46E096 for ; Thu, 24 Jan 2019 11:22:40 +0300 (+03) Received: from SMTP1.alfaintra.net (unknown [172.28.1.129]) by relay.alfa-bank.info (Postfix) with ESMTP for ; Thu, 24 Jan 2019 11:22:40 +0300 (+03) In-Reply-To: <8575e4a8-2f4b-82ba-11f5-d27b4b79b5a8@gmail.com> References: <8575e4a8-2f4b-82ba-11f5-d27b4b79b5a8@gmail.com> To: smalyshev@gmail.com, Levi Morrison , Bruce Weirdan Cc: internals@lists.php.net MIME-Version: 1.0 X-KeepSent: 764B5833:C08AF5F0-4325838C:002692F7; type=4; name=$KeepSent Message-ID: Date: Thu, 24 Jan 2019 11:22:41 +0300 X-MIMETrack: Serialize by Router on SMTP1/Internet(Release 9.0.1FP7|August 17, 2016) at 24.01.2019 11:22:40, Serialize complete at 24.01.2019 11:22:40 Content-Type: multipart/alternative; boundary="=_alternative 002E062A4325838C_=" X-TM-AS-GCONF: 00 X-TM-AS-Product-Ver: IMSVA-9.1.0.1826-8.2.0.1013-24386.005 X-TMASE-Version: IMSVA-9.1.0.1826-8.2.1013-24386.005 X-TMASE-Result: 10--2.373400-10.000000 X-TMASE-MatchedRID: bvFeJY3zwwQI2bIo3lzBlvp1plqEbuqx9pLnYtQ99xIAhmnHHeGnvW0P 85vpv6mOnFxb34UKoxd7v4oUWzUeu1nG4aMEcT3TVnhTcytb5dKHxi2fvkKUMw2G3vz8l/IEMLS kkhBSIk4Rg/S097PNZ6AakY+Ljk9946cGvcyankZ0BEBFOTiHn0rRgIJiqlrlclfXI71B+38Xdu dYOKS8OnJ7f4jw/1XQ0PmQrEJEG+MmC1NuoSXJFGf5YFI3LLMhCQ3xS+zL6e34JyR+b5tvoDq42 XNuO6dlKd4YMeOBmloGcgtee9l4fpqNmRvxO4tzb/5HBZ6dvRj/j4ZByyZz4gdutxUV809bYID9 Y+Lh/TwVtSBxd0PdMQ+n/iEoeEnz/gYpKALyUUFc/msUC5wFQTlgt2EJ9a2EtFYPjJ0hNhhmKVV GR/lKLu8BtdISrVH6FhyEDOk22xPLsLxqIdU3Y51U1lojafr/Vy7Bi/WAomybKItl61J/yZUdXE /WGn0FxpQ77C1A1toA7WI2V4bLAgCdXl+SSewWgJt9btgRpy/bKvl13aGruyK8Z1yY8bg3ZeUJL X1FcQmBSoe9nNDXinjSLBsUOseS/PL6vc+6PLv/rfq14lN2/uXdkrLRCdljkyfHXU9Twq/Lq2Mi k9IhIiHV08se4J8c5pIhKQVggCAT9E+M3O2ViZ303Hv2OH6zJc3HF048oePyQuD7CIURy0MMprc biest X-TMASE-SNAP-Result: 1.821001.0001-0-2-1:0,12:0,22:0,33:0,34:0-0 Subject: HA: Re: [PHP-DEV] Proposal fo "Code-free constructors declaration" From: AGromov@alfabank.ru (Andrey O Gromov) --=_alternative 002E062A4325838C_= Content-Type: text/plain; charset="US-ASCII" I'm added an illustration. Maybe it more clear for understanding. https://wiki.php.net/_detail/rfc/joined.png?id=rfc%3Acode_free_constructor >> Proposed syntax >> class A($prop) extends B("BlaBla", $prop) { >> } > This looks like unobvious magic. PHP approach has traditionally been to > avoid unobvious magic, and be explicit about what is happening. > This functionality does not seem no be enabling anything different, > and seems to be pretty obscure as to what is going on. There is no magic, just alternative constructor syntax with some default behavior. Additional paragraph in documentation will resolve all obscurity. Vice versa, this syntax make behavior more strict. No need to read constructor's body, because you know exactly what's going on. Also there is no place for typos in boilerplate and refactoring errors. IMHO inheritance also is more clear, because no need to search "parent::__construct" in the middle of class body. > Also, $prop can not be documented this way, and assigning default > value to it may be a bit weird too. Not sure that I understand this remark right way. What did you mean? You can use php-doc similar you used it for functions. Parameters block identical to function parameters block, including types and default values. > I am all for paving the walkways, but this particular case > seems to be a bit too narrow to have a special language syntax for, and > the syntax seems to be not exactly obvious as to what's going on there. Matter of quality of documentation. ---------------------------- To Levi Morrison and Bruce Weirdan. >> Would this work with anonymous classes? If so, how would the syntax look like? > I have the same question. I don't think it would work with them, but I > could be wrong. There is no big problem to add same functionality to anonymous classes. But unfortunately only possible syntax(I think) is not very nice. new class(string $a, int $b, int $c=15)("Hi!", 20) extends SomeClass($a, 115){...} --=_alternative 002E062A4325838C_=--