[PHP-DEV] Re: [Zend Engine 2] RFC: Conversion patch

2002-11-27 Thread Derick Rethans
On Wed, 27 Nov 2002, Andi Gutmans wrote:

 At 04:41 PM 11/26/2002 -0500, Daniel Cowgill wrote:
 So why do the conversion in arithmetic? This seems bizarrely inconsistent to
 me:
 
 ?
 print (int)  0xA + 0;   // prints 0
 print (int) (0xA + 0);  // prints 10
 ?
 
 I think it's reasonable to expect those expressions to return the same value.
 
 
 Hmm, this is definitely interesting. The result of the second expression 
 should be 0 too. I haven't had time to check why this happens as all 
 conversions in zend_operators.c are with base 10. I vaguely remember 
 someone changing something in this area a while ago.
 BTW in PHP 4.0.4 this prints out 1 (the second expression) which doesn't 
 make much sense.
 The reason for this is that is_numeric_string() which is used in 
 add_function() does convert hexadecimals whereas all other code in 
 zend_operators.c doesn't.
 This is a pretty bad inconsistency which should be addressed.

And I like to see it addresses so that above examples both print 10.

Derick

-- 

-
 Derick Rethans http://derickrethans.nl/ 
 JDI Media Solutions http://www.jdimedia.nl/
 PHP Magazine - PHP Magazine for Professionals   http://php-mag.net/
-


-- 
PHP Development Mailing List http://www.php.net/
To unsubscribe, visit: http://www.php.net/unsub.php




[PHP-DEV] Re: [Zend Engine 2] RFC: Conversion patch

2002-11-27 Thread Zeev Suraski
At 07:27 27/11/2002, Andi Gutmans wrote:

At 04:41 PM 11/26/2002 -0500, Daniel Cowgill wrote:

So why do the conversion in arithmetic? This seems bizarrely inconsistent to
me:

?
print (int)  0xA + 0;   // prints 0
print (int) (0xA + 0);  // prints 10
?

I think it's reasonable to expect those expressions to return the same value.


Hmm, this is definitely interesting. The result of the second expression 
should be 0 too. I haven't had time to check why this happens as all 
conversions in zend_operators.c are with base 10. I vaguely remember 
someone changing something in this area a while ago.
BTW in PHP 4.0.4 this prints out 1 (the second expression) which doesn't 
make much sense.
The reason for this is that is_numeric_string() which is used in 
add_function() does convert hexadecimals whereas all other code in 
zend_operators.c doesn't.
This is a pretty bad inconsistency which should be addressed.

I think that the patch is ok.  I think you might be mixing it with the 
overloading that I implemented for objects a while ago, which was a bad 
idea.  Here - we're already converting the string to a number.  If it 
doesn't 'look like a number', we end up having it at 0, which is the 
useless default.  Getting it to work with a few extra cases doesn't hurt us 
in any way that I can tell.  Standard disclaimers apply - I might be 
missing something.

Zeev


--
PHP Development Mailing List http://www.php.net/
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP-DEV] Re: [Zend Engine 2] RFC: Conversion patch

2002-11-26 Thread Derick Rethans
On Tue, 26 Nov 2002, Andi Gutmans wrote:

 I remember having a long conversation on this issue quite a long time ago. 
 I think it was on php-dev. The bottom line was that we only want conversion 
 in the scanner and not within PHP.

Too bad, because the following thing is totally uninituitive:

echo (int)0x200;

(prints 0)

And I searched for a discussion on this, but couldnt' find it. I wonder 
why it was decided to be like this.

Derick

-- 

-
 Derick Rethans http://derickrethans.nl/ 
 JDI Media Solutions http://www.jdimedia.nl/
 PHP Magazine - PHP Magazine for Professionals   http://php-mag.net/
-


-- 
PHP Development Mailing List http://www.php.net/
To unsubscribe, visit: http://www.php.net/unsub.php




[PHP-DEV] Re: [Zend Engine 2] RFC: Conversion patch

2002-11-26 Thread Andi Gutmans
http://marc.theaimsgroup.com/?l=php-devm=90279104406287w=2
I'm sure there's some other stuff too.
Andi

At 10:21 PM 11/26/2002 +0100, Derick Rethans wrote:

On Tue, 26 Nov 2002, Andi Gutmans wrote:

 I remember having a long conversation on this issue quite a long time ago.
 I think it was on php-dev. The bottom line was that we only want 
conversion
 in the scanner and not within PHP.

Too bad, because the following thing is totally uninituitive:

echo (int)0x200;

(prints 0)

And I searched for a discussion on this, but couldnt' find it. I wonder
why it was decided to be like this.

Derick

--

-
 Derick Rethans http://derickrethans.nl/
 JDI Media Solutions http://www.jdimedia.nl/
 PHP Magazine - PHP Magazine for Professionals   http://php-mag.net/
-


--
PHP Development Mailing List http://www.php.net/
To unsubscribe, visit: http://www.php.net/unsub.php




[PHP-DEV] Re: [Zend Engine 2] RFC: Conversion patch

2002-11-26 Thread Andi Gutmans
http://marc.theaimsgroup.com/?l=php-devm=90279104406264w=2

There's more...

Andi

At 10:21 PM 11/26/2002 +0100, Derick Rethans wrote:

On Tue, 26 Nov 2002, Andi Gutmans wrote:

 I remember having a long conversation on this issue quite a long time ago.
 I think it was on php-dev. The bottom line was that we only want 
conversion
 in the scanner and not within PHP.

Too bad, because the following thing is totally uninituitive:

echo (int)0x200;

(prints 0)

And I searched for a discussion on this, but couldnt' find it. I wonder
why it was decided to be like this.

Derick

--

-
 Derick Rethans http://derickrethans.nl/
 JDI Media Solutions http://www.jdimedia.nl/
 PHP Magazine - PHP Magazine for Professionals   http://php-mag.net/
-


--
PHP Development Mailing List http://www.php.net/
To unsubscribe, visit: http://www.php.net/unsub.php




[PHP-DEV] Re: [Zend Engine 2] RFC: Conversion patch

2002-11-26 Thread Daniel Cowgill
So why do the conversion in arithmetic? This seems bizarrely inconsistent to
me:

?
print (int)  0xA + 0;   // prints 0
print (int) (0xA + 0);  // prints 10
?

I think it's reasonable to expect those expressions to return the same value.


On Tue, 26 Nov 2002, Andi Gutmans wrote:

 http://marc.theaimsgroup.com/?l=php-devm=90279104406264w=2
 
 There's more...
 
 Andi
 
 At 10:21 PM 11/26/2002 +0100, Derick Rethans wrote:
 On Tue, 26 Nov 2002, Andi Gutmans wrote:
 
   I remember having a long conversation on this issue quite a long time ago.
   I think it was on php-dev. The bottom line was that we only want 
  conversion
   in the scanner and not within PHP.
 
 Too bad, because the following thing is totally uninituitive:
 
 echo (int)0x200;
 
 (prints 0)
 
 And I searched for a discussion on this, but couldnt' find it. I wonder
 why it was decided to be like this.
 
 Derick
 
 --
 
 -
   Derick Rethans http://derickrethans.nl/
   JDI Media Solutions http://www.jdimedia.nl/
   PHP Magazine - PHP Magazine for Professionals   http://php-mag.net/
 -
 
 



-- 
PHP Development Mailing List http://www.php.net/
To unsubscribe, visit: http://www.php.net/unsub.php




[PHP-DEV] Re: [Zend Engine 2] RFC: Conversion patch

2002-11-26 Thread Andi Gutmans
At 04:41 PM 11/26/2002 -0500, Daniel Cowgill wrote:

So why do the conversion in arithmetic? This seems bizarrely inconsistent to
me:

?
print (int)  0xA + 0;   // prints 0
print (int) (0xA + 0);  // prints 10
?

I think it's reasonable to expect those expressions to return the same value.



Hmm, this is definitely interesting. The result of the second expression 
should be 0 too. I haven't had time to check why this happens as all 
conversions in zend_operators.c are with base 10. I vaguely remember 
someone changing something in this area a while ago.
BTW in PHP 4.0.4 this prints out 1 (the second expression) which doesn't 
make much sense.
The reason for this is that is_numeric_string() which is used in 
add_function() does convert hexadecimals whereas all other code in 
zend_operators.c doesn't.
This is a pretty bad inconsistency which should be addressed.
Andi


On Tue, 26 Nov 2002, Andi Gutmans wrote:

 http://marc.theaimsgroup.com/?l=php-devm=90279104406264w=2

 There's more...

 Andi

 At 10:21 PM 11/26/2002 +0100, Derick Rethans wrote:
 On Tue, 26 Nov 2002, Andi Gutmans wrote:
 
   I remember having a long conversation on this issue quite a long 
time ago.
   I think it was on php-dev. The bottom line was that we only want
  conversion
   in the scanner and not within PHP.
 
 Too bad, because the following thing is totally uninituitive:
 
 echo (int)0x200;
 
 (prints 0)
 
 And I searched for a discussion on this, but couldnt' find it. I wonder
 why it was decided to be like this.
 
 Derick
 
 --
 
 -
   Derick Rethans http://derickrethans.nl/
   JDI Media Solutions http://www.jdimedia.nl/
   PHP Magazine - PHP Magazine for Professionals   http://php-mag.net/
 -




--
PHP Development Mailing List http://www.php.net/
To unsubscribe, visit: http://www.php.net/unsub.php