all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: David Kastrup <dak@gnu.org>
To: help-gnu-emacs@gnu.org
Subject: Re: `compare-strings' style question
Date: Thu, 19 Nov 2009 17:17:22 +0100	[thread overview]
Message-ID: <87einuij59.fsf@lola.goethe.zz> (raw)
In-Reply-To: mailman.11057.1258644880.2239.help-gnu-emacs@gnu.org

tomas@tuxteam.de writes:

> On Thu, Nov 19, 2009 at 12:39:33PM +0100, David Kastrup wrote:
>> tomas@tuxteam.de writes:
>> 
>> > Hi,
>> >
>> > In Elisp, I'm trying to test whether a string is a prefix of another.
>
> [...]
>
>> >   (when (eq (compare-strings foo 0 5 bar 0 5) t)
>> >     ...)
>> >
>> > which looks rather funny. My question: are there better idioms? Am I
>> > barking up the wrong function?
>> 
>> (unless (numberp ...
>> 
>> or
>> 
>> (if (symbolp ...
>
> Thanks. Still looks a bit funna, though :-)

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.

-- 
David Kastrup


  parent reply	other threads:[~2009-11-19 16:17 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 [this message]
2009-11-19 20:54       ` Barry Margolin
2009-11-20  7:00         ` tomas
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

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

  git send-email \
    --in-reply-to=87einuij59.fsf@lola.goethe.zz \
    --to=dak@gnu.org \
    --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.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.