From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: dalanicolai Newsgroups: gmane.emacs.bugs Subject: bug#47368: 28.0.50; map-elt returns nil without "deprecated" TESTFN Date: Thu, 25 Mar 2021 15:48:01 +0100 Message-ID: References: <87sg4kyw1q.fsf@tcd.ie> <87lfacvtwt.fsf@web.de> Mime-Version: 1.0 Content-Type: multipart/alternative; boundary="00000000000039ad6005be5d812c" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="27751"; mail-complaints-to="usenet@ciao.gmane.io" Cc: "Basil L. Contovounesios" , 47368@debbugs.gnu.org To: Michael Heerdegen Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Thu Mar 25 15:49:11 2021 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1lPRIM-00077z-LD for geb-bug-gnu-emacs@m.gmane-mx.org; Thu, 25 Mar 2021 15:49:10 +0100 Original-Received: from localhost ([::1]:57144 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lPRIL-0000lp-M3 for geb-bug-gnu-emacs@m.gmane-mx.org; Thu, 25 Mar 2021 10:49:09 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:57824) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lPRIE-0000kc-93 for bug-gnu-emacs@gnu.org; Thu, 25 Mar 2021 10:49:02 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:55889) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lPRIE-0004eQ-1J for bug-gnu-emacs@gnu.org; Thu, 25 Mar 2021 10:49:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1lPRID-0001Yj-Ut for bug-gnu-emacs@gnu.org; Thu, 25 Mar 2021 10:49:01 -0400 X-Loop: help-debbugs@gnu.org Resent-From: dalanicolai Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 25 Mar 2021 14:49:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 47368 X-GNU-PR-Package: emacs Original-Received: via spool by 47368-submit@debbugs.gnu.org id=B47368.16166837015934 (code B ref 47368); Thu, 25 Mar 2021 14:49:01 +0000 Original-Received: (at 47368) by debbugs.gnu.org; 25 Mar 2021 14:48:21 +0000 Original-Received: from localhost ([127.0.0.1]:39202 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lPRHY-0001Xb-IE for submit@debbugs.gnu.org; Thu, 25 Mar 2021 10:48:20 -0400 Original-Received: from mail-vs1-f45.google.com ([209.85.217.45]:47087) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lPRHW-0001XL-Cw for 47368@debbugs.gnu.org; Thu, 25 Mar 2021 10:48:19 -0400 Original-Received: by mail-vs1-f45.google.com with SMTP id r11so1006236vsj.13 for <47368@debbugs.gnu.org>; Thu, 25 Mar 2021 07:48:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=iYUPel/AAlHhX15K0LCGlaydFi3QCZnI2i+HpPm6O9s=; b=cEvhR8NLiHB2KfvdpSZUA5+xcTX4k7jDhWQQ/AGCgB3i7MvWN431NgugwahcMLEfJf lqeu+2FoCnp52DAdD+TtJ1qI1HWdfyfo+0IO4A2fH9uq8uOesuOzrsdHe9tMlxZ0VGb1 i1rsfl3MUknJCBVIlJeHm1KolvYd9hx7NxCwehciC4A+Kwt0j8tMQcbcYDOU48KNILlc ScshxTZIUnhqZGC70x2DdAiFtEHonveRhIm/3dsL/mh4lYQtTxM+i/hKxwPGxcBjrYF6 +KMQCwpC0QOTS3j2cFyy1ex7wleUClOy81d/KAzawNJZGhQ+Rzf5SEbgrRCK2vnQbb02 xF2g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=iYUPel/AAlHhX15K0LCGlaydFi3QCZnI2i+HpPm6O9s=; b=Ipn2qcK3/yDCtIgNJ+n60OVWlETzXNsHTdZDJp+IvQS9rnu2yTXulep3fmYrGSfw7+ aTWkfBEnb6Yh7TIa5f86x4zuCPI6R6Q437SgF7VM6+1aYVLVrI1D79DIf/8eylxR5LhT RTS/yi28MxKVsG715F7HiDKXUzuR0sI1Ai6ag9sP0xBhqoQ8dEQ6SxZmPdQvQh9GbbQh W66kT+lO9dX7NwJsA7L4KBDuMLSGlMpXyxbCVdaiamEH0lTPMSug3kQ3/hhXfzEmkQsd DlPwl+eW9HlH+7m+2ladyizIBywpkmMYFGgb2Ovk8AIlfzRsh5rgUXDk+jlI6EEQdcS0 Gu6Q== X-Gm-Message-State: AOAM532hs9poH3ROnNG6gpR5woiZlrQDfacUtveOepnh8gdZU1CwnMbJ gtDRLq+kb/FJCaxJPS5qkVa4x77x8vjqwz5T4pI= X-Google-Smtp-Source: ABdhPJxBa6x4AhtqMSgxx94I3Wweh3KT60tID0atfQTtpTFgQAenG3UNE+fiSZIwewNPQ3mNsU25JZUAaY8O/pFFjBk= X-Received: by 2002:a05:6102:323b:: with SMTP id x27mr5380939vsf.0.1616683692829; Thu, 25 Mar 2021 07:48:12 -0700 (PDT) In-Reply-To: <87lfacvtwt.fsf@web.de> X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.io gmane.emacs.bugs:203001 Archived-At: --00000000000039ad6005be5d812c Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable For clarity I will insert the first lines of the docstrings here: map-elt is a Lisp closure in =E2=80=98map.el=E2=80=99. > > (map-elt MAP KEY &optional DEFAULT) > > Probably introduced at or before Emacs version 26.1. > > Lookup KEY in MAP and return its associated value. > If KEY is not found, return DEFAULT which defaults to nil. > > TESTFN is deprecated. Its default depends on the MAP argument. > > In the base definition, MAP can be an alist, plist, hash-table, > or array. > First I agree with Michael that this docstring assumes a lot of knowledge from the programmer. The sentence "its default depends on the MAP argument" could be more explicit, to make the docstring friendly to new elisp programmers. e.g. mention eq for alists (and also the TESTFN's for the other ones) Second calling the TESTFN deprecated is misleading if it a basic requirement for the basic thing I am trying to achieve (i.e. matching a string). So it should probably mention that it is not required if you want to use the MAP's default TESTFN, but otherwise it is required (while deprecated sounds to me like there shouldn't be a need to use it) Thanks for your answer! On Thu, 25 Mar 2021 at 03:39, Michael Heerdegen wrote: > "Basil L. Contovounesios" writes: > > > dalanicolai writes: > > > > > The docstring of the map-elt function from the map.el package (versio= n > > > 3.0) mentions that TESTFN is deprecated because "its default depends = on > > > the MAP argument". However when I try e.g. > > > > > > (map-elt '(("A1" . 3)) "A1") > > > > > > it returns nil. > > > > This is expected, as alist keys are tested with eq by default. > > > > That's what the docstring is trying to warn about: alists default to > > testing with eq, but can also use eql, equal, or anything else. > > Is it that obvious? We have `assoc' and `assq' built-in - to me it's > not obvious that "alist keys are tested with eq by default". It's the > default for `alist-get', ok, which is used by the implementation, but > not everybody will know that. I would add a sentence about that. > > Michael. > --00000000000039ad6005be5d812c Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
For clarity I will insert the first lines of the docs= trings here:

map-elt is a Lisp closure in =E2=80=98map.el=E2=80=99.

= (map-elt MAP KEY &optional DEFAULT)

=C2=A0 Probably introduced a= t or before Emacs version 26.1.

Lookup KEY in MAP and return its ass= ociated value.
If KEY is not found, return DEFAULT which defaults to nil= .

TESTFN is deprecated.=C2=A0 Its default depends on the MAP argumen= t.

In the base definition, MAP can be an alist, plist, hash-table,or array.

First I agree with Mi= chael that this docstring assumes a lot of knowledge from the programmer.
The sentence "its default depends on the MAP argument&quo= t; could be more explicit, to make the docstring friendly to new elisp prog= rammers.
e.g. mention eq for alists (and also the TESTFN's fo= r the other ones)

Second calling the TESTFN d= eprecated is misleading if it a basic requirement for the basic thing I am = trying to achieve (i.e. matching a string).
So it should prob= ably mention that it is not required if you want to use the MAP's defau= lt TESTFN, but otherwise it is required (while deprecated sounds to me like= there shouldn't be a need to use it)

Thanks f= or your answer!




On Th= u, 25 Mar 2021 at 03:39, Michael Heerdegen <michael_heerdegen@web.de> wrote:
"Basil L. Contovounesios"= <contovob@tcd.ie> writes:

> dalanicolai <
dalanicolai@gmail.com> writes:
>
> > The docstring of the map-elt function from the map.el package (ve= rsion
> > 3.0) mentions that TESTFN is deprecated because "its default= depends on
> > the MAP argument". However when I try e.g.
> >
> > (map-elt '(("A1" . 3)) "A1")
> >
> > it returns nil.
>
> This is expected, as alist keys are tested with eq by default.
>
> That's what the docstring is trying to warn about: alists default = to
> testing with eq, but can also use eql, equal, or anything else.

Is it that obvious?=C2=A0 We have `assoc' and `assq' built-in - to = me it's
not obvious that "alist keys are tested with eq by default".=C2= =A0 It's the
default for `alist-get', ok, which is used by the implementation, but not everybody will know that.=C2=A0 I would add a sentence about that.

Michael.
--00000000000039ad6005be5d812c--