Re: [PHP-DEV] Concept: constructor overloading syntax sugar

2025-02-18 Thread Larry Garfield
On Tue, Feb 18, 2025, at 2:00 AM, Rowan Tommins [IMSoP] wrote: > On 17 February 2025 14:39:42 GMT, Viktor Khramov > wrote: >>Hi! >> >>The point is here: >>https://gist.github.com/vhood/665418835e65be26d5a818fded92ab75 > > >>Static functions look awful and break the object's API. > > Personally, I

Re: [PHP-DEV] Concept: constructor overloading syntax sugar

2025-02-18 Thread Lynn
On Tue, Feb 18, 2025 at 10:27 AM Viktor Khramov wrote: > Decision::createFromId($uuid, $comment); > Decision::createFromMail($subject, $body); > Decision::createFromSome($a, $b, $c); > Decision::createFromAnother($a); > > This doesn't look like constructors. It will be hard to read the > class, i

Re: [PHP-DEV] Concept: constructor overloading syntax sugar

2025-02-18 Thread Tim Düsterhus
Hi Am 2025-02-18 09:00, schrieb Rowan Tommins [IMSoP]: Personally, I think quite the opposite: named constructors make a lot more sense than type-based overloads. For instance, you might have both createFromJson and createFromYaml; their inputs are both going to be "string" as far as the type

Re: [PHP-DEV] Concept: constructor overloading syntax sugar

2025-02-18 Thread Valentin Udaltsov
On Tue, 18 Feb 2025 at 12:45, Sebastian Bergmann wrote: > Am 18.02.2025 um 09:00 schrieb Rowan Tommins [IMSoP]: > > named constructors make a lot more sense than type-based overloads > > +1 > Hi, Viktor. I agree with others that named static constructors are much better than overloading of the

Re: [PHP-DEV] Concept: constructor overloading syntax sugar

2025-02-18 Thread Sebastian Bergmann
Am 18.02.2025 um 09:00 schrieb Rowan Tommins [IMSoP]: named constructors make a lot more sense than type-based overloads +1

Re: [PHP-DEV] Concept: constructor overloading syntax sugar

2025-02-18 Thread Viktor Khramov
Decision::createFromId($uuid, $comment); Decision::createFromMail($subject, $body); Decision::createFromSome($a, $b, $c); Decision::createFromAnother($a); This doesn't look like constructors. It will be hard to read the class, it will take time to come up with a name, it's not right. I have differ

Re: [PHP-DEV] Concept: constructor overloading syntax sugar

2025-02-18 Thread Rowan Tommins [IMSoP]
On 17 February 2025 14:39:42 GMT, Viktor Khramov wrote: >Hi! > >The point is here: >https://gist.github.com/vhood/665418835e65be26d5a818fded92ab75 >Static functions look awful and break the object's API. Personally, I think quite the opposite: named constructors make a lot more sense than

Re: [PHP-DEV] Concept: constructor overloading syntax sugar

2025-02-17 Thread Alexandru Pătrănescu
Hi Viktor, On Mon, Feb 17, 2025 at 4:42 PM Viktor Khramov wrote: > Hi! > > The point is here: > https://gist.github.com/vhood/665418835e65be26d5a818fded92ab75 > > Is it possible? May I create an RFC for this? > Already possible like this: class Decision { #[Main] public function __cons

Re: [PHP-DEV] Concept: constructor overloading syntax sugar

2025-02-17 Thread Tim Düsterhus
Hi Related to overloading, that is binding to the correct function in Java/C# at compile time, and IMO is not matching with the dynamic nature of PHP. Indeed. See: https://github.com/php/php-src/issues/17813 Best regards Tim Düsterhus