all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Drew Adams <drew.adams@oracle.com>
To: Okamsn <okamsn@protonmail.com>,
	"50927@debbugs.gnu.org" <50927@debbugs.gnu.org>
Subject: bug#50927: [External] : bug#50927: Considering only entries with unique keys in map.el?
Date: Fri, 1 Oct 2021 01:56:10 +0000	[thread overview]
Message-ID: <SJ0PR10MB5488B539F2DE97A7CB97B749F3AB9@SJ0PR10MB5488.namprd10.prod.outlook.com> (raw)
In-Reply-To: <9fda32d4-5c09-a047-18aa-a792211ffa06@protonmail.com>

> Some kinds of maps, such as alists and plists, can contain duplicate
> keys.  These duplicates are effectively ignored in functions like
> `map-elt`, but are not ignored in functions like `map-do` or `map-
> length`.
> 
> To me, it would make more sense if these functions only considered the
> valid entries in the map.  For example,
> 
>     (map-pairs '(a 1 b 2 a 3))
> 
> currently returns '((a . 1) (b . 2) (a . 3)), even though '(a . 3) is
> meant to be ignored in actual usage,

But you, yourself, just said that some functions
don't ignore it.  So it's not an "invalid" entry.

This all comes from Lisp being untyped.  The same
list can serve different uses, some of which are
maps that don't allow duplicates (i.e., they're
functions, not relations).

It's not an error that "these functions" (depending
on which you mean) consider all list elements.

> entry with the same key.  This is a misleading behavior.

Actually, it's a handy behavior.  It's one of the
main ideas behind alists.  You can just remove or
skip the first match of a given key to restore or
use the next one.

My comments aren't really for `map-*' functions,
as I'm not familiar with them.  I'm just commenting
on what you said in general.  HTH.

  reply	other threads:[~2021-10-01  1:56 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-10-01  0:55 bug#50927: Considering only entries with unique keys in map.el? Okamsn via Bug reports for GNU Emacs, the Swiss army knife of text editors
2021-10-01  1:56 ` Drew Adams [this message]
2021-10-01  2:17   ` bug#50927: [External] : " Michael Heerdegen
2021-10-01 12:48 ` Lars Ingebrigtsen

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=SJ0PR10MB5488B539F2DE97A7CB97B749F3AB9@SJ0PR10MB5488.namprd10.prod.outlook.com \
    --to=drew.adams@oracle.com \
    --cc=50927@debbugs.gnu.org \
    --cc=okamsn@protonmail.com \
    /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.