Hi,

> On 3 Apr 2015, at 20:46, Dmitry Stogov <dmi...@zend.com> wrote:
> 
> May be you'll also suggest something regarding bitwise shifts with negative 
> offset?
> Allowing negative offsets using opposite directions would fix inconsistency, 
> but I remember, you didn't like it.
> May be keep WARNING (Bit shift by negative number) and then perform shift in 
> another direction?
> + disable negative shifts at compile-time.

I don’t think opposite-direction shifts would work well for a few reasons. I 
don’t believe this is normal behaviour in other languages, for one. Another 
issue is that << and >> are not actually opposites, they have different 
behaviour with respect to signs, so there’d be ambiguity as to what $x << -$y 
means (is it the same as $x >> $y, or does it deal differently with signs?). 
Negative shifts being used are usually the result of mistakes, as well, so you 
want to inform the user.

The main problem, though, is that we previously did something different if the 
shift is negative. Having it now produce a warning, means you’ll see error 
messages when you run existing code. But shifting in the opposite direction 
might change the behaviour of existing code silently

I think the most sensible solution would be to make negative shifts produce an 
exception, since they’re really an error, an unsupported operation. I made them 
be a warning + return FALSE just because it matched division. But that’s not 
ideal and I’d be fine if it was replaced.

Thanks. 

--
Andrea Faulds
http://ajf.me/





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

Reply via email to