Re: Opinion on function/method name overloading

From: Date: Mon, 06 Jun 2016 11:06:19 +0000
Subject: Re: Opinion on function/method name overloading
References: 1 2 3 4  Groups: php.internals 
Request: Send a blank email to internals+get-93838@lists.php.net to get a copy of this message
In your example, the output may be: 0 3 float, int and string all share the same row on an upside down pyramid, with $bar, being dynamic, at the bottom. With regards to union types, it could work exactly like the latest Multi-Catch feature. On 6 Jun 2016 11:57 a.m., "Rowan Collins" <rowan.collins@gmail.com> wrote: > On 06/06/2016 11:32, Christoph Becker wrote: > >> And we would run into similar issues as with the union types with regard >> to weak typing. >> > > This is probably the biggest hurdle, IMO - regardless of the internal > implementation, you've got to define exactly how the feature would work in > the language itself. > > A quick example off the top of my head (there are many other edge cases to > cover): > > class A { > public function foo($bar) { echo 0; } > public function foo(string $bar) { echo 1; } > public function foo(int $bar) { echo 2; } > } > class B extends A { > public function foo(float $bar) { echo 3; } > } > > (new A)->foo(1.5); > (new B)->foo(1.5); > > > Regards, > -- > Rowan Collins > [IMSoP] > > -- > PHP Internals - PHP Runtime Development Mailing List > To unsubscribe, visit: http://www.php.net/unsub.php > >

« previous php.internals (#93838) next »