RE: [PHP-DEV] [RFC] Internal operator overloading and GMP improvements

2013-06-09 Thread Zeev Suraski
From: Nikita Popov [mailto:nikita@gmail.com] Sent: Sunday, June 09, 2013 5:15 PM To: Zeev Suraski Cc: PHP internals Subject: Re: [PHP-DEV] [RFC] Internal operator overloading and GMP improvements On Sun, Jun 9, 2013 at 3:37 PM, Zeev Suraski wrote: >> What I meant by cumulativity i

Re: [PHP-DEV] [RFC] Internal operator overloading and GMP improvements

2013-06-09 Thread Nikita Popov
On Sun, Jun 9, 2013 at 3:37 PM, Zeev Suraski wrote: > What I meant by cumulativity in that context is really commutativity J > Fixed (and also added transitivity). > > > > In other words, operands that are commutative in PHP (like addition, > multiplication, etc.) – one should not overload for do

RE: [PHP-DEV] [RFC] Internal operator overloading and GMP improvements

2013-06-09 Thread Zeev Suraski
Popov [mailto:nikita@gmail.com] *Sent:* Sunday, June 09, 2013 4:20 PM *To:* Zeev Suraski *Cc:* PHP internals *Subject:* Re: [PHP-DEV] [RFC] Internal operator overloading and GMP improvements On Sun, Jun 9, 2013 at 10:00 AM, Zeev Suraski wrote: It wouldn’t have been the first time that

Re: [PHP-DEV] [RFC] Internal operator overloading and GMP improvements

2013-06-09 Thread Nikita Popov
On Sun, Jun 9, 2013 at 10:00 AM, Zeev Suraski wrote: > It wouldn’t have been the first time that something that seems common > sense, suddenly becomes controversial a few years later J Better safe > than sorry. > > I made some changes to the phrasing of the final paragraph in this section > (ple

RE: [PHP-DEV] [RFC] Internal operator overloading and GMP improvements

2013-06-09 Thread Zeev Suraski
you added is great. Thanks, Zeev *From:* Nikita Popov [mailto:nikita@gmail.com] *Sent:* Saturday, June 08, 2013 3:54 PM *To:* Zeev Suraski *Cc:* Dmitry Stogov; PHP internals *Subject:* Re: [PHP-DEV] [RFC] Internal operator overloading and GMP improvements On Fri, Jun 7, 2013 at 9:45

Re: [PHP-DEV] [RFC] Internal operator overloading and GMP improvements

2013-06-08 Thread Nikita Popov
On Sat, Jun 8, 2013 at 9:49 PM, Stas Malyshev wrote: > Hi! > > > My main interest here is improving the usability of GMP - the operator > > overloading is just a means to that goal. With that in mind, I think it > > I understand that, but operator overloading is not the GMP-only change. > It is a

Re: [PHP-DEV] [RFC] Internal operator overloading and GMP improvements

2013-06-08 Thread Stas Malyshev
Hi! > My main interest here is improving the usability of GMP - the operator > overloading is just a means to that goal. With that in mind, I think it I understand that, but operator overloading is not the GMP-only change. It is a change deep in the core of the engine, and as such should be consi

Re: [PHP-DEV] [RFC] Internal operator overloading and GMP improvements

2013-06-08 Thread Nikita Popov
On Fri, Jun 7, 2013 at 9:45 PM, Zeev Suraski wrote: > I would add that the purpose of this feature would be exclusive to > extensions that implement mathematical concepts, where the operators are > well defined. In other words, arbitrary precision math, vectors, > matrices, etc. - yes; Incremen

Re: [PHP-DEV] [RFC] Internal operator overloading and GMP improvements

2013-06-08 Thread Nikita Popov
On Fri, Jun 7, 2013 at 8:16 PM, Stas Malyshev wrote: > Hi! > > > If there is no more feedback on the RFC, then I'll start voting in a day > or > > two. > > I would suggest splitting this RFC into two - the operator overloading > one and the GMP one. Converting GMP to objects has little to do with

RE: [PHP-DEV] [RFC] Internal operator overloading and GMP improvements

2013-06-07 Thread Zeev Suraski
> -Original Message- > From: Nikita Popov [mailto:nikita@gmail.com] > Sent: Friday, June 07, 2013 8:15 PM > To: Dmitry Stogov > Cc: PHP internals > Subject: Re: [PHP-DEV] [RFC] Internal operator overloading and GMP > improvements > > If there is no more fee

Re: [PHP-DEV] [RFC] Internal operator overloading and GMP improvements

2013-06-07 Thread Stas Malyshev
Hi! > If there is no more feedback on the RFC, then I'll start voting in a day or > two. I would suggest splitting this RFC into two - the operator overloading one and the GMP one. Converting GMP to objects has little to do with overloading (even if needed for GMP to benefit from it) so I think i

Re: [PHP-DEV] [RFC] Internal operator overloading and GMP improvements

2013-06-07 Thread Nikita Popov
On Wed, May 15, 2013 at 7:12 AM, Dmitry Stogov wrote: > According to fast-path execution, I would really like to not introduce the > additional checks. > Especially for concat_function I would change it in the following way: > > if (Z_TYPE_P(op1) != IS_STRING) { > if (Z_TYPE_P(op1) == IS_OBJ

Re: [PHP-DEV] [RFC] Internal operator overloading and GMP improvements

2013-05-14 Thread Dmitry Stogov
Hi Nikita, Thanks for function renaming. I'm agree about INC/DEC and unary operators (!, ~) implementation. A single callback for all operators may not be always good, because classes may overload not all but only few operators, but technically it doesn't make any problems, so let keep it as is.

Re: [PHP-DEV] [RFC] Internal operator overloading and GMP improvements

2013-05-14 Thread Nikita Popov
On Tue, May 14, 2013 at 7:43 AM, Dmitry Stogov wrote: > Hi Nikita, > > Few final notes: > > - I wouldn't change zend_object_compare_t into > zend_object_compare_objects_t. It would be better to name the new function > as zend_object_compare_zvals_t. (It's just for better backward > compatibility)

Re: [PHP-DEV] [RFC] Internal operator overloading and GMP improvements

2013-05-13 Thread Dmitry Stogov
Hi Nikita, Few final notes: - I wouldn't change zend_object_compare_t into zend_object_compare_objects_t. It would be better to name the new function as zend_object_compare_zvals_t. (It's just for better backward compatibility) - Increment and decrement operators in PHP may have different semant

Re: [PHP-DEV] [RFC] Internal operator overloading and GMP improvements

2013-05-13 Thread Nikita Popov
On Mon, May 13, 2013 at 1:09 PM, Dmitry Stogov wrote: > Hi Nikita, > > I didn't get why do we need separate zend_std_compare() function. > May be I just didn't look careful :) > Good point, that was not really necessary. I moved the code back into compare_function. > It would be great to look i

Re: [PHP-DEV] [RFC] Internal operator overloading and GMP improvements

2013-05-13 Thread Dmitry Stogov
Hi Nikita, I didn't get why do we need separate zend_std_compare() function. May be I just didn't look careful :) It would be great to look into the patch between master and current of your branch. It would be more clear than internal patches. Thanks. Dmitry. On Mon, May 13, 2013 at 2:50 PM, N

Re: [PHP-DEV] [RFC] Internal operator overloading and GMP improvements

2013-05-13 Thread Nikita Popov
On Mon, May 13, 2013 at 12:25 PM, Dmitry Stogov wrote: > Would need an additional object handler though (as compare_objects works >> only on objects, so it's currently not possible to support something like >> $gmp == 0). >> > > Or may be we may introduce additional opcode (or even pseudo-opcode)

Re: [PHP-DEV] [RFC] Internal operator overloading and GMP improvements

2013-05-13 Thread Dmitry Stogov
Hi, On Mon, May 13, 2013 at 1:24 PM, Nikita Popov wrote: > On Mon, May 13, 2013 at 7:49 AM, Dmitry Stogov wrote: > >> Hi Nikita, >> >> The patch looks quite good. >> However, it must slow down each comparison operator (even if it compares >> two integers). >> > In most cases it shouldn't, as th

Re: [PHP-DEV] [RFC] Internal operator overloading and GMP improvements

2013-05-13 Thread Nikita Popov
On Mon, May 13, 2013 at 7:49 AM, Dmitry Stogov wrote: > Hi Nikita, > > The patch looks quite good. > However, it must slow down each comparison operator (even if it compares > two integers). > In most cases it shouldn't, as the comparisons usually go through the fast_is_*_functions, which have sp

Re: [PHP-DEV] [RFC] Internal operator overloading and GMP improvements

2013-05-12 Thread Dmitry Stogov
Hi Nikita, The patch looks quite good. However, it must slow down each comparison operator (even if it compares two integers). I would suggest overloading of CMP operator instead of separate <, <=, ==, !=, >, >=. Also it may make sense to think about overloading of unary operators to provide a s

Re: [PHP-DEV] [RFC] Internal operator overloading and GMP improvements

2013-05-12 Thread Sara Golemon
> > > Why would this be confusing? I'd agree if this happened in userland > (people > > could wonder why the operators are swapped), but internally we are > already > > dealing with this anyway. E.g. when you implement compare_objects you > have > > to be aware of this (to understand stuff like the

Re: [PHP-DEV] [RFC] Internal operator overloading and GMP improvements

2013-05-12 Thread Stas Malyshev
Hi! > Why would this be confusing? I'd agree if this happened in userland (people > could wonder why the operators are swapped), but internally we are already > dealing with this anyway. E.g. when you implement compare_objects you have > to be aware of this (to understand stuff like the return 1 t

Re: [PHP-DEV] [RFC] Internal operator overloading and GMP improvements

2013-05-12 Thread Nikita Popov
On Sun, May 12, 2013 at 9:57 PM, Sara Golemon wrote: > Are we ignoring the ZEND_IS_SMALLER issue? > Not ignoring it :) It's mentioned in one sentence: "The operators >, >=, [...] are indirectly supported by the following compiler transformations: [...]" if ($gmp > 123) { ... } > > There's no ZEN

Re: [PHP-DEV] [RFC] Internal operator overloading and GMP improvements

2013-05-12 Thread Sara Golemon
Are we ignoring the ZEND_IS_SMALLER issue? if ($gmp > 123) { ... } There's no ZEND_IS_GREATER opcode, so it gets quietly turned into: if (123 < $gmp) { ... } Which will be confusing. I dealt with this in operator by having the user apply a patch before building: https://github.com/php/pecl-php

Re: [PHP-DEV] [RFC] Internal operator overloading and GMP improvements

2013-05-12 Thread Nikita Popov
On Sun, May 12, 2013 at 9:02 PM, Nikita Popov wrote: > I think this is a misunderstanding. I do not suggest to use GMP for all > arithmetic and also do not suggest to auto-promote to GMP for large numbers. > > The operator overloading only comes into play if one of the operands is > already a GMP

Re: [PHP-DEV] [RFC] Internal operator overloading and GMP improvements

2013-05-12 Thread Nikita Popov
On Sun, May 12, 2013 at 7:50 PM, Antony Dovgal wrote: > On 2013-05-12 19:25, Nikita Popov wrote: > >> Hi internals! >> >> https://wiki.php.net/rfc/**operator_overloading_gmp >> >> This RFC proposes to add operator overloading for INTERNAL classes

Re: [PHP-DEV] [RFC] Internal operator overloading and GMP improvements

2013-05-12 Thread Pierre Joye
On Sun, May 12, 2013 at 7:50 PM, Antony Dovgal wrote: > On 2013-05-12 19:25, Nikita Popov wrote: >> >> Hi internals! >> >> https://wiki.php.net/rfc/operator_overloading_gmp >> >> This RFC proposes to add operator overloading for INTERNAL classes. >> Furthermore it exemplarily implements the new AP

Re: [PHP-DEV] [RFC] Internal operator overloading and GMP improvements

2013-05-12 Thread Antony Dovgal
On 2013-05-12 19:25, Nikita Popov wrote: Hi internals! https://wiki.php.net/rfc/operator_overloading_gmp This RFC proposes to add operator overloading for INTERNAL classes. Furthermore it exemplarily implements the new API for GMP. IMO the proposal B is quite reasonable change, but the propos