unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
From: tomas@tuxteam.de
To: help-gnu-emacs@gnu.org
Subject: Re: `compare-strings' style question
Date: Fri, 20 Nov 2009 08:00:39 +0100	[thread overview]
Message-ID: <20091120070039.GC30194@tomas> (raw)
In-Reply-To: <barmar-3DA3D6.15542019112009@nothing.attdns.com>

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On Thu, Nov 19, 2009 at 03:54:20PM -0500, Barry Margolin wrote:
> In article <87einuij59.fsf@lola.goethe.zz>, David Kastrup <dak@gnu.org> 
> wrote:

[...]

> > In my opinion, t was the wrong choice for a match.  nil would have been
> > much better because you can't use the result of compare-strings as a
> > condition.
> > 
> > But I suppose there is not much one can do now because of compatibility.
> 
> That would still be weird, because
> 
> (not (compare-strings ...))
> 
> would be the way to tell if they're equivalent.  C has the same problem 
> with its strcmp() function, which returns negative, 0, or positive, 
> where 0 is C's falsehood.

Yes, that would be a similar problem as C, where zero's alter ego is
false. It still looks a bit funny to say

  if(!strcmp(foo, bar)) ...

...but at least, it's just a problem of name choice (more appropriate
would have been something along the lines of strdiff).

> The basic problem is that IF is designed to work with binary predicates, 
> and this operation is trinary.
> 
> Maybe compare-strings should have been defined like strcmp, returning 0 
> for the middle case.  Then you wouldn't be tempted to think of it as a 
> predicate.  (zerop (compare-strings ...)) doesn't seem as weird as (not 
> (compare-strings ...)).

Yes, I would have preferred this choice (but nil would have been fine
too).

Thanks
- -- tomás
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (GNU/Linux)

iD8DBQFLBj6XBcgs9XrR2kYRAsz/AJ47RD83WcbAmKNJ3zDVO2RLorOEXwCePi9z
q0SAJuLd7lCI6MHoi2ShLlw=
=D4Be
-----END PGP SIGNATURE-----




  reply	other threads:[~2009-11-20  7:00 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <mailman.11037.1258628274.2239.help-gnu-emacs@gnu.org>
2009-11-19 11:39 ` `compare-strings' style question David Kastrup
2009-11-19 15:27   ` tomas
2009-11-19 19:55     ` Andreas Politz
2009-11-20  6:47       ` tomas
     [not found]   ` <mailman.11057.1258644880.2239.help-gnu-emacs@gnu.org>
2009-11-19 16:17     ` David Kastrup
2009-11-19 20:54       ` Barry Margolin
2009-11-20  7:00         ` tomas [this message]
2009-11-20  8:13           ` Andreas Politz
2009-11-20  6:53       ` tomas
2009-11-19 10:50 tomas
2009-11-20  3:08 ` Kevin Rodgers
2009-11-20  7:03   ` tomas
2009-11-20 10:34     ` Kevin Rodgers
2009-11-24  9:32       ` tomas

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20091120070039.GC30194@tomas \
    --to=tomas@tuxteam.de \
    --cc=help-gnu-emacs@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).