bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#50927: [External] : bug#50927: Considering only entries with unique


From: Drew Adams
Subject: bug#50927: [External] : bug#50927: Considering only entries with unique keys in map.el?
Date: Fri, 1 Oct 2021 01:56:10 +0000

> 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 via email to

[Prev in Thread] Current Thread [Next in Thread]