unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Eli Zaretskii <eliz@gnu.org>
To: bruce.connor.am@gmail.com
Cc: nicolas@petton.fr, emacs-devel@gnu.org
Subject: Re: map.el and naming
Date: Mon, 02 Mar 2015 16:49:37 +0200	[thread overview]
Message-ID: <83y4nfqwse.fsf@gnu.org> (raw)
In-Reply-To: <CAAdUY-KC3NzXX7bZPpBi=Dn5fnhB_5XSUQxiE1WvZAu063MCFA@mail.gmail.com>

> Date: Mon, 2 Mar 2015 14:33:14 +0000
> From: Artur Malabarba <bruce.connor.am@gmail.com>
> Cc: Nicolas Petton <nicolas@petton.fr>, emacs-devel <emacs-devel@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).

I thought the object type should give enough information about that.

> 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).

I asked whether it would make sense to have the same APIs for both
groups, and where just the type of the object provides enough
information for choosing how to process it.  If you are saying that
doesn't make a lot of sense, then I guess polymorphism doesn't make
much sense in this case.

> 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').

If there are APIs that make sense for maps, IMO they should be generic
APIs that can handle both objects now handled by seq.el and those in
map.el.  IOW, if only some of the APIs must be map-specific, that
doesn't mean we need to make them all map-specific, IMO.



  reply	other threads:[~2015-03-02 14:49 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
2015-03-02 14:49             ` Eli Zaretskii [this message]
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=83y4nfqwse.fsf@gnu.org \
    --to=eliz@gnu.org \
    --cc=bruce.connor.am@gmail.com \
    --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).