all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Augusto Stoffel <arstoffel@gmail.com>
To: Michael Heerdegen <michael_heerdegen@web.de>
Cc: "Basil L. Contovounesios" <contovob@tcd.ie>,
	Nicolas Petton <nicolas@petton.fr>,
	62068@debbugs.gnu.org
Subject: bug#62068: 29.0.60; map-elt and map-insert for nested structures
Date: Sat, 11 Mar 2023 08:51:33 +0100	[thread overview]
Message-ID: <87356bvi7u.fsf@gmail.com> (raw)
In-Reply-To: <87r0twt1js.fsf@web.de> (Michael Heerdegen's message of "Sat, 11 Mar 2023 04:22:15 +0100")

On Sat, 11 Mar 2023 at 04:22, Michael Heerdegen wrote:

> Augusto Stoffel <arstoffel@gmail.com> writes:
>
>> How did I miss that?  In any case the more interesting bit is the other
>> function, which should then be renamed to `map-nested-insert'.
>
> Is that something one will really need often (honest question, I'm
> really curious)?

I think it's very useful when you need it :-).  Actually, I wouldn't use
map-elt in any code, because I always know what type I'm dealing with.
I would just turn to this library for special maneuvers that the basic
API doesn't offer.

>  If yes, I wonder if we should make it work as a
> generalized variable.

Maybe, but that's a separate story.  First and most importantly, in my
opinion, the library should work right on values (as opposed to places).

>> Now, `map-nested-elt' has an inconsistency regarding the DEFAULT
>> argument which needs to be fixed.
>>
>> (map-nested-elt '(a nil) '(a) 1)
>> 1
>> (map-nested-elt '((a . nil)) '(a) 1)
>> 1
>> etc.
>>
>> While in the other hand:
>> (map-elt '(a nil) 'a 1)
>> nil
>> (map-elt '((a . nil)) 'a 1)
>> nil
>> etc.
>> [...]
>
> That's a good point indeed.  However, `map-nested-elt' exists since the
> beginning of the library in 2015, so it could be that existing code
> relies on the behavior (maybe that's why you wanted to add a new
> function?).

(No, the reason was just pure oversight.  Maybe "elt" is a weird word?
Why isn't it `map-get' and `map-nested-get'?)

>  But it's a terrible inconsistency.

There are more consistency issues in this library, see bug#62067 and
bug#62117.  Emacs has its quirks and one of the selling points of map.el
is to be a more consistent layer on top of the basic APIs, so I'd say
this need to be fixed.





      reply	other threads:[~2023-03-11  7:51 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-03-09  8:16 bug#62068: 29.0.60; map-elt and map-insert for nested structures Augusto Stoffel
2023-03-10  1:18 ` Michael Heerdegen
2023-03-10  7:09   ` Augusto Stoffel
2023-03-11  3:22     ` Michael Heerdegen
2023-03-11  7:51       ` Augusto Stoffel [this message]

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=87356bvi7u.fsf@gmail.com \
    --to=arstoffel@gmail.com \
    --cc=62068@debbugs.gnu.org \
    --cc=contovob@tcd.ie \
    --cc=michael_heerdegen@web.de \
    --cc=nicolas@petton.fr \
    /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.