Re: [PHP-DEV] RFC Operator Overloading in Userspace

2016-01-05 Thread Bob Weinand
> Am 05.01.2016 um 15:29 schrieb Alexander Lisachenko : > > 2016-01-05 2:04 GMT+03:00 Andrea Faulds : > >> I agree that we could do something with interfaces. I would like to point >> out that we actually already have an example of this, in the form of the >> \ArrayAccess interface, which requir

Re: [PHP-DEV] RFC Operator Overloading in Userspace

2016-01-04 Thread Bob Weinand
> Am 4.1.2016 um 20:39 schrieb Johannes Schlüter : > > On Sat, 2016-01-02 at 18:14 -0800, Sara Golemon wrote: >> https://wiki.php.net/rfc/operator-overloading > > Back in the days when I created the first implementation of operator > overloading in the engine[1] I didn't see it fit for the langua

Re: [PHP-DEV] RFC Operator Overloading in Userspace

2016-01-04 Thread Johannes Schlüter
On Sat, 2016-01-02 at 18:14 -0800, Sara Golemon wrote: > https://wiki.php.net/rfc/operator-overloading Back in the days when I created the first implementation of operator overloading in the engine[1] I didn't see it fit for the language. Meanwhile we have more type hints and stuff making it a bit

Re: [PHP-DEV] RFC Operator Overloading in Userspace

2016-01-04 Thread François Laupretre
Hi, I did consider that as an alternate option. function overload_register($op, $lhtype, $rhtype, $callback); overload_type(ZEND_ADD, 'Complex', 'any', 'Complex::add'); This would get pretty expensive in terms of large lookup tables though, so I'm hesitant there. This is much better, IMO, as

Re: [PHP-DEV] RFC Operator Overloading in Userspace

2016-01-04 Thread Derick Rethans
On Sat, 2 Jan 2016, Sara Golemon wrote: > Patricio Tarantino has asked me to help him propose Operator > Overloading in PHP 7.1 (based in part on my operator extension in > PECL). I think we can expose this to usespace as magic methods with > very little overhead (the runtime check and dispatch i

Re: [PHP-DEV] RFC Operator Overloading in Userspace

2016-01-03 Thread Larry Garfield
On 01/02/2016 08:14 PM, Sara Golemon wrote: Patricio Tarantino has asked me to help him propose Operator Overloading in PHP 7.1 (based in part on my operator extension in PECL). I think we can expose this to usespace as magic methods with very little overhead (the runtime check and dispatch is a

Re: [PHP-DEV] RFC Operator Overloading in Userspace

2016-01-03 Thread Sara Golemon
> On Jan 3, 2016, at 02:11, Nikita Popov wrote: > Thanks for the proposal, Sara! A few questions to clarify: > One point of order. It's Patricio's peoposal, I'm just helping him move it along. > 1. If an object implements __add__, will $a += $b be equivalent to $a = > $a->__add($b) and ++$a

Re: [PHP-DEV] RFC Operator Overloading in Userspace

2016-01-03 Thread Mark Baker
On 03/01/2016 02:14, Sara Golemon wrote: Patricio Tarantino has asked me to help him propose Operator Overloading in PHP 7.1 (based in part on my operator extension in PECL). I think we can expose this to usespace as magic methods with very little overhead (the runtime check and dispatch is alre

Re: [PHP-DEV] RFC Operator Overloading in Userspace

2016-01-03 Thread Nikita Popov
On Sun, Jan 3, 2016 at 3:14 AM, Sara Golemon wrote: > Patricio Tarantino has asked me to help him propose Operator > Overloading in PHP 7.1 (based in part on my operator extension in > PECL). I think we can expose this to usespace as magic methods with > very little overhead (the runtime check a

Re: [PHP-DEV] RFC Operator Overloading in Userspace

2016-01-02 Thread Sara Golemon
> BTW, I don't think for GMP right now += modifies existing object. > I guess it may be possible to implement it the other way (not sure). > It doesn't. As seen below, we get a new, second object on the assign_add. Wrong behavior IMO, but something to fix separately from this. $g = gmp_init(123)

Re: [PHP-DEV] RFC Operator Overloading in Userspace

2016-01-02 Thread Stanislav Malyshev
Hi! > Hilarious to hear you cite that as the already existing inconsistency > between += and ++ with non-numeric strings came up only last week. > > $x = 'foo'; > $x++; // $x === 'fop' > $x += 1; // $x === 1 Exactly, because on strings ++ and += 1 are not the same operator. And, as you noted, it

Re: [PHP-DEV] RFC Operator Overloading in Userspace

2016-01-02 Thread Levi Morrison
On Sat, Jan 2, 2016 at 7:14 PM, Sara Golemon wrote: > Patricio Tarantino has asked me to help him propose Operator > Overloading in PHP 7.1 (based in part on my operator extension in > PECL). I think we can expose this to usespace as magic methods with > very little overhead (the runtime check an

Re: [PHP-DEV] RFC Operator Overloading in Userspace

2016-01-02 Thread John Bafford
Hi Sara, On Jan 2, 2016, at 21:14, Sara Golemon wrote: > > Patricio Tarantino has asked me to help him propose Operator > Overloading in PHP 7.1 (based in part on my operator extension in > PECL). I think we can expose this to usespace as magic methods with > very little overhead (the runtime c

Re: [PHP-DEV] RFC Operator Overloading in Userspace

2016-01-02 Thread Sara Golemon
On Sat, Jan 2, 2016 at 6:59 PM, Stanislav Malyshev wrote: >> Patricio Tarantino has asked me to help him propose Operator >> Overloading in PHP 7.1 (based in part on my operator extension in >> PECL). I think we can expose this to usespace as magic methods with >> very little overhead (the runtim

Re: [PHP-DEV] RFC Operator Overloading in Userspace

2016-01-02 Thread Stanislav Malyshev
Hi! > Patricio Tarantino has asked me to help him propose Operator > Overloading in PHP 7.1 (based in part on my operator extension in > PECL). I think we can expose this to usespace as magic methods with > very little overhead (the runtime check and dispatch is already there, > after all). We c

Re: [PHP-DEV] RFC Operator Overloading in Userspace

2016-01-02 Thread Bishop Bettini
Hi Sara and Patricio, On Sat, Jan 2, 2016 at 9:14 PM, Sara Golemon wrote: > Patricio Tarantino has asked me to help him propose Operator > Overloading in PHP 7.1 (based in part on my operator extension in > PECL). I think we can expose this to usespace as magic methods with > very little overhe

Re: [PHP-DEV] RFC Operator Overloading in Userspace

2016-01-02 Thread Davey Shafik
I would love to see all of the is_* methods implemented in the initial implementation, these are far more useful to me than the basic math operators. As for interfaces, I'm generally pro-interfaces as programmatic documentation if nothing else — however, none of the magic methods have implemented

[PHP-DEV] RFC Operator Overloading in Userspace

2016-01-02 Thread Sara Golemon
Patricio Tarantino has asked me to help him propose Operator Overloading in PHP 7.1 (based in part on my operator extension in PECL). I think we can expose this to usespace as magic methods with very little overhead (the runtime check and dispatch is already there, after all). I do think that the