Re: Re: cvs: php4 /ext/standard basic_functions.c

From: Date: Fri, 12 Oct 2001 11:36:34 +0000
Subject: Re: Re: cvs: php4 /ext/standard basic_functions.c
References: 1  Groups: php.cvs php.dev 
Request: Send a blank email to php-dev+get-67846@lists.php.net to get a copy of this message
On Fri, 12 Oct 2001, Stig S. Bakken wrote: > Jeroen van Wolffelaar wrote: > > > > > On Thu, Oct 11, 2001 at 08:13:18AM +0200, Stig Venaas wrote: > > > > > > > But perhaps version_compare() returning -1, 0, 1 is the best. > > > > > > I think this is the best of the ideas that have been voiced. > > > > That makes 3 of us, I think it's better than a third parameter. It's much > > versatile, and you don't need COMPARE_EQ,NEQ,GT, GE etc constants, which are > > quite hard for people not used to that kind of names... > > You mean "if (version_compare(a, b) == -1)"? You can always do that if > you like. But now you can also do "version_compare(a, b, '<')". > I've > implemented PHP/C, SQL and Perl/sh syntaxes to make everyonen happy, the > third arg can be one of: < lt <= le > gt >= ge = == eq != <> ne Not ==-1 of course, but version_combare() < 0. Passing an operator as a string is introducion a new way of comparing, whilst that's totally unnecessary. What is wrong with normal comparators? I really don't think it's a good idea to add a third parameter, which enables the possibility to do the same in different ways (unnecessary), and would a lot of people require to look up what version_compare(a,b,'ne') means. And it is quite annoying for experienced programmers expecting version_compare() be true (1) on equality, and not 0. *_compare functions are expected to return an integer, either -N, 0 or +N, while *_equals() return booleans. This is common programming practice in all languages I know of (including PHP!, i.e. strcmp...) --Jeroen > > - Stig > Jeroen van Wolffelaar Jeroen@A-Eskwadraat.nl http://www.A-Eskwadraat.nl/~jeroen

« previous php.dev (#67846) next »