develooper Front page | perl.perl5.porters | Postings from January 2001

Re: [PATCH] pod/perlclib.pod - Replacements for C library functions

Thread Previous | Thread Next
Stephen McCamant
January 31, 2001 22:16
Re: [PATCH] pod/perlclib.pod - Replacements for C library functions
Message ID:
>>>>> "RJK" == Ronald J Kimball <> writes:

RJK> On Wed, Jan 31, 2001 at 09:13:04PM +0100, Philip Newton wrote:

SC>  strcmp(s1, s2)        strLE(s1, s2) / strEQ(s1, s2) / strGT(s1,s2)

PN> Is there really the asymmetry LE vs GT? Not LE vs GE or LT vs GT?
PN> Why?

RJK> With EQ, LE, GT you can do all comparisons with a single call,
RJK> just by putting the arguments in the right order.  With EQ, LT,
RJK> GT or EQ, LE, GE, some comparisons would require two calls.

Or probably better in practice, a negation:

ne(a, b) = !eq(a, b)
gt(a, b) =  lt(b, a)
ge(a, b) = !lt(a, b)
le(a, b) = !lt(b, a)

Using an asymmetric pair also gives a more complete overview of the
naming scheme, though anyone who knows perl's string operators would
be unlikely to expect >= to be strGEQ(s1, s2). Of course any selection
of three risks giving people the impression those are all there are.
I'm not sure if it would be better to say something like

  strLT(s1, s2), strEQ(s1, s2), etc.


  str(EQ|NE|LT|LE|GT|GE)(s1, s2)
  str{EQ,NE,LT,LE,GT,GE}(s1, s2)
  strXX(s1, s2), where XX is EQ NE LT LE GT GE

 -- Stephen McC

Thread Previous | Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About