GNU bug report logs - #76618
30.1.50; need an -unzip-lists function?

Previous Next

Package: emacs;

Reported by: Christopher Howard <christopher <at> librehacker.com>

Date: Thu, 27 Feb 2025 22:28:02 UTC

Severity: normal

Found in version 30.1.50

Done: Stefan Kangas <stefankangas <at> gmail.com>

Bug is archived. No further changes may be made.

Full log


View this message in rfc822 format

From: "Basil L. Contovounesios" <basil <at> contovou.net>
To: Christopher Howard <christopher <at> librehacker.com>
Cc: 76618 <at> debbugs.gnu.org
Subject: bug#76618: 30.1.50; need an -unzip-lists function?
Date: Tue, 04 Mar 2025 23:44:55 +0100
Christopher Howard [2025-02-27 13:27 -0900] wrote:

> -zip has the strange behavior that it always returns lists of lists, unless you provide it with two lists, in which case it returns cons cells instead.

Yes, this is an unfortunate historical accident.
For a while Dash's README included:

  ### Upcoming breaking change!

  - For backward compatibility reasons, `-zip` when called with two
    lists returns a list of cons cells, rather than a list of proper
    lists.  This is a clunky API, and may be changed in a future release
    to always return a list of proper lists, as `-zip-lists` currently
    does.

    **N.B.:** Do not rely on the current behavior of `-zip` for two
    lists.  Instead, use `-zip-pair` for a list of cons cells, and
    `-zip-lists` for a list of proper lists.

> Okay, fine, but the documentation for -unzip says
>
> ```
> Unzip LISTS.
>
> This works just like ‘-zip’ but takes a list of lists instead of
> a variable number of arguments, such that
>
>   (-unzip (-zip L1 L2 L3 ...))
>
> is identity (given that the lists are the same length).
> ```

This is an older version of the docstring.
The latest version clarifies further:

  ... (given that the lists are of the same length, and
  that `-zip' is not called with two arguments, because of the
  caveat described in its docstring).

  Note in particular that calling `-unzip' on a list of two lists
  will return a list of dotted pairs.

  Since the return value changes form depending on the number of
  LISTS, it is generally recommended to use `-unzip-lists' instead.

> But if you try zipping and unzipping two lists, like
>
> (-unzip (-zip '(1 a) '(2 b)))
>
> this throws an error, because -unzip only deals with lists.

This is https://github.com/magnars/dash.el/issues/400,
which is fixed in the latest version of Dash (since 2023-03-04).

> Maybe we just need an -unzip-lists function?

Also added as part of issue #400.

So I think the only bug here is that Dash hasn't had a version bump
since 2021-08-26.  I should get to that soon.

Thanks,
-- 
Basil




This bug report was last modified 67 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.