unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Artur Malabarba <bruce.connor.am@gmail.com>
To: Eli Zaretskii <eliz@gnu.org>
Cc: Nicolas Petton <nicolas@petton.fr>, emacs-devel <emacs-devel@gnu.org>
Subject: Re: map.el and naming
Date: Mon, 2 Mar 2015 14:33:14 +0000	[thread overview]
Message-ID: <CAAdUY-KC3NzXX7bZPpBi=Dn5fnhB_5XSUQxiE1WvZAu063MCFA@mail.gmail.com> (raw)
In-Reply-To: <8361ajsduy.fsf@gnu.org>

> But polymorphism _is_ about using the same APIs for treating different
> objects.

Yes, but associations (or maps) and sequences are not just different
objects, they're different abstractions too. There are many operations
which make sense on both, but even then Emacs has no automatic way of
deciding which version to employ (see below).

> Do any of the operations in seq.el make sense with the
> objects you meant to handle in map.el?  If so, it could make sense to
> have them treated by the same API.

Many certainly do, but the way they must be handled is different for
sequences and associations.
For instance, if you map over a list, you want the function will be
called on each element, but if you map over an association, you want
the function to be called on each key-value pair.

Now, take a plist as an example. If you call `seq-map' on a 2-element
list where the first element happens to be a keyword, `seq.el' has no
way of knowing if you intended to use that as a sequence or as an
association, therefore it just can't handle both cases.
That's why you need two libraries. If you want to map over sequences,
you call seq-map, if you want to map over an association, you call
`map-map' (or whatever it ends up being called).

This won't only happen with mapping, I think it will happen with
enough other functions to warrant a different library. Of course this
library doesn't have to reimplement everything from scratch, it can
and should fallback on seq.el whenever possible (just like seq.el
sometimes falls back on built-ins like `mapcar').



  reply	other threads:[~2015-03-02 14:33 UTC|newest]

Thread overview: 43+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-02-28 12:24 map.el and naming Nicolas Petton
2015-02-28 13:32 ` Bozhidar Batsov
2015-03-03 15:58   ` bburns.km
2015-03-04  7:51     ` Nicolas Petton
2015-03-04  9:38       ` Nic Ferrier
2015-02-28 13:49 ` Eli Zaretskii
2015-02-28 16:21   ` Artur Malabarba
2015-03-02  5:31   ` Stefan Monnier
2015-03-02  7:38   ` Nicolas Petton
2015-03-02 13:20     ` Eli Zaretskii
2015-03-02 13:26       ` Nicolas Petton
2015-03-02 13:55         ` Eli Zaretskii
2015-03-02 14:33           ` Artur Malabarba [this message]
2015-03-02 14:49             ` Eli Zaretskii
2015-03-02 15:08               ` Artur Malabarba
2015-03-02 15:24               ` Stephen J. Turnbull
2015-03-02 16:53       ` Stefan Monnier
2015-03-03  3:14         ` Stephen J. Turnbull
2015-03-03 16:36           ` Stefan Monnier
2015-03-04  2:07             ` Stephen J. Turnbull
2015-03-02  5:29 ` Stefan Monnier
2015-03-02 13:59   ` Nicolas Petton
2015-04-11  0:52 ` Nicolas Petton
2015-04-11 13:53   ` Stefan Monnier
2015-04-11 14:07     ` Nicolas Petton
2015-04-11 13:55   ` Stefan Monnier
2015-04-11 14:11     ` Nicolas Petton
2015-04-11 14:24       ` John Yates
2015-04-11 14:32       ` Dmitry Gutov
2015-04-11 19:54         ` Artur Malabarba
2015-04-12  3:32         ` Stefan Monnier
2015-04-11 14:21     ` Artur Malabarba
2015-04-12  3:25       ` Stefan Monnier
2015-04-11 14:20   ` John Yates
2015-04-11 21:44   ` John Mastro
2015-04-12  3:34     ` Stefan Monnier
2015-04-12  7:12       ` Daniel Colascione
2015-04-12 11:48         ` Stefan Monnier
2015-04-12 11:59           ` Nicolas Petton
2015-04-12 12:53             ` Stefan Monnier
2015-04-12 13:38               ` Stephen J. Turnbull
2015-04-12 14:22                 ` Yuri Khan
2015-04-12 14:52               ` Nicolas Petton

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

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAAdUY-KC3NzXX7bZPpBi=Dn5fnhB_5XSUQxiE1WvZAu063MCFA@mail.gmail.com' \
    --to=bruce.connor.am@gmail.com \
    --cc=eliz@gnu.org \
    --cc=emacs-devel@gnu.org \
    --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 public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).