unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: "Stephen J. Turnbull" <stephen@xemacs.org>
To: Stefan Monnier <monnier@IRO.UMontreal.CA>
Cc: Eli Zaretskii <eliz@gnu.org>, Nicolas Petton <nicolas@petton.fr>,
	emacs-devel@gnu.org
Subject: Re: map.el and naming
Date: Tue, 03 Mar 2015 12:14:12 +0900	[thread overview]
Message-ID: <87egp6bwmz.fsf@uwakimon.sk.tsukuba.ac.jp> (raw)
In-Reply-To: <jwvegp7e43c.fsf-monnier+emacs@gnu.org>

Stefan Monnier writes:

 > > of these objects: lists, strings, vectors, alists, and hash-tables?
 > 
 > Think of `seq' and `map' as (Java) interfaces, which can be implemented
 > by various low-level representations.
 > 
 > Some representations (e.g. lists or vectors) can implement both interfaces.

Please, let's not go there.  Emacs Lisp is by design, history, and
current practice in Emacs primarily a non-object-oriented language.
It's not object-oriented at the level of Java or Haskell, and
certainly not Smalltalk.  Granted, it is certainly possible to
implement true[1] objects in Lisp, and it's a very valuable technique
in Emacs too (eg, the various components of CEDET).

But the "objects" listed in the quote above are not objects in this
sense.  They don't know their own subclass, and so cannot tell a
function operating on them that "I'm a cons" (Lisp knows that) "which
is the head of a list representing a map using the 'property list'
API" (Lisp can't know that for those objects).  This is a deliberate
design principle; RMS wanted Emacs data structures to be
introspectable, and he chose to do that by avoiding ADTs except where
absolutely necessary for efficiency (buffers, strings, vectors,
hash-tables), and instead building everything out of a few primitive
data types and embedding knowledge of data structures in functions.
This allows a person with access to the source of those functions to
introspect the corresponding data structures.  (How 1970s!  Sure, but
that's when Emacs was designed....)

Certainly it's possible to implement polymorphic functions, too.  But
here, AFAICS we already have the useful ones for sequences (nth, for
one).  I agree that "cons", "car", and "cdr" are not very discoverable
for new learners, but then the ambiguous use of "map" (as a verb, it
either means "iterate over a sequence" or "describe a functional
relationship") is hardly helpful to them.  I really don't see what
benefit these new faux-namespaces (seq.el, map.el) provide, except to
worshippers of consistency.  This is quite different from the
situation with cl-lib, where Common Lisp often uses the same
identifiers as Emacs Lisp with different semantics, and also often
provides rather sophisticated functionality that is not necessary in
"base Emacs" (though extremely expressive and useful in the advanced
applications which make Emacs so powerful).

If you want to build an object-oriented language into Lisp, great.
But first you need objects.  (XEmacs already uses OO implementation
techniques at the C level, but I gather from other threads that in
Emacs such usage is spotty at best.)  We already have EIEIO.  That may
not be appropriate for "promotion" into the core language, or perhaps
people would prefer CLOS or maybe something more appropriate for an
eventual Guile-based Emacs "Lisp".

Footnotes: 
[1]  By which I mean in the conventional sense of "object orientation".




  reply	other threads:[~2015-03-03  3:14 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
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 [this message]
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=87egp6bwmz.fsf@uwakimon.sk.tsukuba.ac.jp \
    --to=stephen@xemacs.org \
    --cc=eliz@gnu.org \
    --cc=emacs-devel@gnu.org \
    --cc=monnier@IRO.UMontreal.CA \
    --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).