From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Bozhidar Batsov Newsgroups: gmane.emacs.devel Subject: Re: string> missing? Date: Thu, 4 Jun 2015 09:02:05 +0200 Message-ID: References: <87oakxkvqw.fsf@petton.fr> <83zj4grgkc.fsf@gnu.org> <87sia8n8b5.fsf@petton.fr> <87zj4gu821.fsf@gnu.org> <83sia8rdkm.fsf@gnu.org> <83pp5crbfd.fsf@gnu.org> <83mw0gr4eh.fsf@gnu.org> <83d21cqj9y.fsf@gnu.org> <87vbf4dldj.fsf@gnu.org> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: multipart/alternative; boundary=001a11c3ecfedb63370517abc06f X-Trace: ger.gmane.org 1433401342 27985 80.91.229.3 (4 Jun 2015 07:02:22 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Thu, 4 Jun 2015 07:02:22 +0000 (UTC) To: Eli Zaretskii , Stefan Monnier , nandryshak@gmail.com, Nicolas Petton , emacs-devel Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Thu Jun 04 09:02:22 2015 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1Z0PAR-0003dg-CS for ged-emacs-devel@m.gmane.org; Thu, 04 Jun 2015 09:02:19 +0200 Original-Received: from localhost ([::1]:40470 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Z0PAQ-0006Ha-N6 for ged-emacs-devel@m.gmane.org; Thu, 04 Jun 2015 03:02:18 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:47011) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Z0PAI-00068z-V9 for emacs-devel@gnu.org; Thu, 04 Jun 2015 03:02:15 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Z0PAH-0000bt-QB for emacs-devel@gnu.org; Thu, 04 Jun 2015 03:02:10 -0400 Original-Received: from mail-la0-x22d.google.com ([2a00:1450:4010:c03::22d]:34574) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Z0PAF-0000ZO-S8; Thu, 04 Jun 2015 03:02:08 -0400 Original-Received: by laew7 with SMTP id w7so24920795lae.1; Thu, 04 Jun 2015 00:02:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:sender:in-reply-to:references:date:message-id:subject :from:to:content-type; bh=hNK8hnMYHuCKc5TRg1cukI1XDQ3tdz0K+gpnFGIx5IU=; b=ZkAUgjDR0/cHs1NOQyI6UeWUQSVmX5c+7Bd1E6hFaMT5IBolOizX+bqkMLsVcuzphf ZC91IBN/TPAYm6tFB1vJ140iU403NYAkft/oHFPfW1v39yZ4xNKpbQOH+IxkDRvxn7JY vjr9tCnR8F0Visw+Tte/O2XMSmtKlnv9kopYNMtgCnofqFMTIVExi1ksA2MLEjeM8aqT CvSdO5v2kmmdnNaLt01jPk3LUVm7FF7vi/WV13zO4xWRbjPvsgDAzkoO6Exkl56a6fHo gG3JeXNSDyxW3r1UhCTgp903EAO12A7GudiUFu6V0KQjBtLeG2iOlI6myhMm588iFHAv N8iQ== X-Received: by 10.112.54.225 with SMTP id m1mr36532950lbp.34.1433401326000; Thu, 04 Jun 2015 00:02:06 -0700 (PDT) Original-Received: by 10.112.172.164 with HTTP; Thu, 4 Jun 2015 00:02:05 -0700 (PDT) In-Reply-To: <87vbf4dldj.fsf@gnu.org> X-Google-Sender-Auth: PN3uUguu9yMICgzYZcMb4n5xGgo X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2a00:1450:4010:c03::22d X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:187014 Archived-At: --001a11c3ecfedb63370517abc06f Content-Type: text/plain; charset=UTF-8 Way too much bikeshedding for something super trivial. Let's add the function(s) and be done with it. On 4 June 2015 at 08:43, Tassilo Horn wrote: > Eli Zaretskii writes: > > >> Emacs is inconsistent. That's part of its inheritance. > >> If someone wants to add string>, I'm perfectly OK with it. > > > > Why not _remove_ string< and use compare-strings for both jobs? > > Oh yes, please. Everybody wants to use a function of 6-7 arguments! ;-) > > Fun aside: aside from the reason of symmertry/consistency, I can see at > least two practical advantages of having `string>'. Whenever it should > be used as predicate of a higher-order function, > > (sort coll #'string>) > > is more concise than > > (sort coll (lambda (a b) (string< b a))) > > and it is also better to edebug because you are usually not > interested in edebugging the lambda. (What can possibly go wrong > there?!?) > > However, this is true for any other simple predicate aside from number > or string comparison. So I'd suggest to have a `complement' function > which simply returns a function negating the value of some predicate, > e.g., > > (defun complement (fn) > "Returns a function calling FN and returning FN's negated value." > (lambda (&rest args) > (not (apply fn args)))) > > Then you can do > > (sort coll (complement #'string<)) > > which looks like a good compromise wrt conciseness and edebuggability. > Of course, (complement #'string<) is string>= which will work fine for > `sort' but probably not for other higer-order functions. > > Grepping the emacs source code, there are indeed at least three > occurrences of (nreverse (sort coll predicate)) which could make use of > that. And I can also find occurrences of (lambda (a b) (string< b a)). > However, when the number of definitions is what makes a function which > is currently not provided by Elisp important, than it looks to me that > there should be a function for > > (lambda (a b) (string< (car a) (car b))) > > For that, `rgrep' delivers 40 matches in the elisp repositories I have > on my disk, and I only searched for > > "(lambda (. .) (string< (car .) (car .)))" > > so it has to occur on one line with the exact spacing and 1-char wide > arguments. So that suggests we want to have a > `car-string-less-than-car' (or indeed want to have the numerical > comparison functions work for strings, too, as Stefan suggested because > there's already `car-less-than-car'). > > Bye, > Tassilo > > --001a11c3ecfedb63370517abc06f Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable
Way too much bikeshedding for something super trivial. Let= 's add the function(s) and be done with it.

On 4 June 2015 at 08:43, Tassilo Horn <= span dir=3D"ltr"><tsdh= @gnu.org> wrote:
Eli Zaretskii <eliz@gnu.org= > writes:

>> Emacs is inconsistent.=C2=A0 That's part of its inheritance. >> If someone wants to add string>, I'm perfectly OK with it.<= br> >
> Why not _remove_ string< and use compare-strings for both jobs?

Oh yes, please.=C2=A0 Everybody wants to use a function of 6-7 argum= ents! ;-)

Fun aside: aside from the reason of symmertry/consistency, I can see at
least two practical advantages of having `string>'.=C2=A0 Whenever i= t should
be used as predicate of a higher-order function,

=C2=A0 (sort coll #'string>)

is more concise than

=C2=A0 (sort coll (lambda (a b) (string< b a)))

and it is also better to edebug because you are usually not
interested in edebugging the lambda.=C2=A0 (What can possibly go wrong
there?!?)

However, this is true for any other simple predicate aside from number
or string comparison.=C2=A0 So I'd suggest to have a `complement' f= unction
which simply returns a function negating the value of some predicate,
e.g.,

(defun complement (fn)
=C2=A0 "Returns a function calling FN and returning FN's negated v= alue."
=C2=A0 (lambda (&rest args)
=C2=A0 =C2=A0 (not (apply fn args))))

Then you can do

=C2=A0 (sort coll (complement #'string<))

which looks like a good compromise wrt conciseness and edebuggability.
Of course, (complement #'string<) is string>=3D which will work f= ine for
`sort' but probably not for other higer-order functions.

Grepping the emacs source code, there are indeed at least three
occurrences of (nreverse (sort coll predicate)) which could make use of
that.=C2=A0 And I can also find occurrences of (lambda (a b) (string< b = a)).
However, when the number of definitions is what makes a function which
is currently not provided by Elisp important, than it looks to me that
there should be a function for

=C2=A0 (lambda (a b) (string< (car a) (car b)))

For that, `rgrep' delivers 40 matches in the elisp repositories I have<= br> on my disk, and I only searched for

=C2=A0 "(lambda (. .) (string< (car .) (car .)))"

so it has to occur on one line with the exact spacing and 1-char wide
arguments.=C2=A0 So that suggests we want to have a
`car-string-less-than-car' (or indeed want to have the numerical
comparison functions work for strings, too, as Stefan suggested because
there's already `car-less-than-car').

Bye,
Tassilo


--001a11c3ecfedb63370517abc06f--