unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Drew Adams <drew.adams@oracle.com>
To: "Herring, Davis" <herring@lanl.gov>
Cc: Stefan Monnier <monnier@iro.umontreal.ca>, emacs-devel@gnu.org
Subject: RE: `read--expression' and `read-minibuffer'
Date: Wed, 7 Sep 2016 09:02:03 -0700 (PDT)	[thread overview]
Message-ID: <b91b1d27-6802-4199-b693-5524d32bcdc7@default> (raw)
In-Reply-To: <B393F5AD12955C48A84FFB08032CD04F6C5C0A34@ECS-EXG-P-MB01.win.lanl.gov>

> > You spoke of intention to evaluate, as I said.  I didn't,
> > and still don't, see how such an intention enters into what
> > `read--expression' does.  I don't even know what such
> > intention means, operationally.
> 
> It affects completion, as has already been stated: given
> (comment-c as a _form_ (hopefully less ambiguous than "expression"),

(No less ambiguous.)

> the only completion is `comment-choose-indent'; as a general s-exp, 
> `comment-column' is probably more likely.

All of that has already been said, by each of us.  I said it at
the outset.  It's clear that the completion it provides is for
function names after `('.  No one disputes that.

What `read--expression' reads and returns says nothing about any
particular intention to evaluate.  And what it reads and returns 
is not limited by the (handy, for some expressions) completion it
provides.  And even that completion says nothing about the
intended use of what is read, in particular about any intention
to evaluate it.

This has all been said before in this thread.

> > But if you bring in evaluation to further classify Lisp
> > objects then please tell us exactly how those that you
> > call "expression" differ with respect to evaluation.
> 
> They have a structure that could possibly evaluate without error?

Is that really how you want to define "expression"?  So `(/ 3 0)'
is not an expression, _because_ it raises an arithmetic error?
Or do you want to backtrack a bit, and settle on just syntax
errors?  Or on some other kind of error?  See my previous message
about this.

> Of course, nothing can check that an evaluation completes without error
> (without actually evaluating it, which might never complete).  So `read--
> expression' doesn't bother checking at all.

Of course.  And where does that leave your attempt to define
"expression" in terms of evaluation non-error?

And what makes you assume that it would if it could, that is,
that it even cares only about expressions that could be evaluated
without error?  Why not accept it for what it is - characterize
it by its actual behavior (which is to read any syntactically
valid sexp).

What it does is similar to what `read' does.  The difference is
that it reads from the minibuffer, providing handy completion,
in particular for some kinds of expressions.

And note that the doc of `read' too talks about reading a "Lisp
expression".  It does not exclude `((a . b) (c . d))' or any
other syntactically valid sexp from the class of "expressions".

In fact, the behavior of `read' - the behavior of the Lisp reader,
_defines_ syntactic validity.  It defines what is an "expression",
aka "sexp", and what is not, I think.

> > Does `read--expression' complain that what it read here is
> > not an "Elisp expression"?  (Nope.)
> 
> It is better to interpret `read--expression' not as "read and return a
> form" but rather as "read an s-exp from the user, helping them type a
> form".

So you say.  But why is it better to interpret things as you
choose to interpret them?  A better interpretation is based on
what the function actually does, I think: what it reads without
error and what it returns.

> It really is a question of intent: the caller intends to get a
> form, so they make it easy for the user (who is hopefully also
> intending to enter a form) to do so.  ["they" are
> "expression"/"form" and "sexp"]

So you say, with nothing but hand-waving to back it up.  That's
presumptuous about what a caller wants to get from the user and
what it wants to do with what it gets.

Instead, look at what the function actually reads (without error)
and what it actually returns.  There is no such limitation in its
_behavior_ as what you propose/intend.

`read-expression' is handy for reading lots of sexps that do not
fit your characterization of intent - simply because that's what
it actually does: reads and returns a sexp.

> > Apparently, in Emacs-Speak, they are the same.  They are
> > distinguished from the more general category of Lisp "objects".
> 
> Be careful with the map and the territory: a string for the Lisp reader
> isn't itself a (Lisp) object unless it also exists as a string object in
> Lisp.  An object results from a read of an s-exp; the words "expression"
> and "form" are commonly applied both to the object read (if it "seems"
> evaluable) and to the read syntax for it, but the word "object" is not.

We're not (so far, but if you insist then we can also go down that
path) distinguishing representation from represented, here.

Is a sexp or an expression text on paper, characters in a buffer
or in a string?  Is it something that only _represents_ a Lisp
object?  Or is it a Lisp object?

Is what is read by `read--expression' (or by any read) a
sexp/expression?  Or is that what is returned by it?  Or both?
Is this a string: "abc"?  Or does a string result only from
reading that text?

It's not necessary to make this representation/represented
distinction _here_, but if you insist, then go for it.  Stake
out clearly what is representation and what is represented, and
relate what you come up with to the behavior of `read-expression'.

_My_ question is only about `read--expression'.  To me, it is
handy for ordinary user-programmers, not just for Emacs developers,
and it should not be considered "internal".

To me, even though it provides function-name completion after `('
and both function- and variable-name completion otherwise, it is
useful not only for reading function applications and other forms
that can be evaluated without error, but also other sexps that
cannot.

You can limit yourself to using it only for the former, if you
like, but that's not what the function does, so its users are not
limited to any such "intention".



  reply	other threads:[~2016-09-07 16:02 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-09-03 18:20 `read--expression' and `read-minibuffer' Drew Adams
2016-09-04  4:40 ` Stefan Monnier
2016-09-04  5:53   ` Drew Adams
2016-09-04  6:27     ` Stefan Monnier
2016-09-04 15:39       ` Drew Adams
2016-09-05  2:36         ` Stefan Monnier
2016-09-06 19:02         ` Davis Herring
2016-09-06 20:29           ` Drew Adams
2016-09-07  0:04             ` Stefan Monnier
2016-09-07  3:01               ` Drew Adams
2016-09-07  3:46                 ` Stefan Monnier
2016-09-07  5:54                   ` Drew Adams
2016-09-07 12:12                     ` Stefan Monnier
2016-09-09 21:41                       ` Drew Adams
2016-09-07 13:25                     ` Herring, Davis
2016-09-07 16:02                       ` Drew Adams [this message]
2016-09-07 17:01                         ` Davis Herring
2016-09-07 21:01                           ` Drew Adams
2016-09-07 22:17               ` Michael Heerdegen
2016-09-07 22:30                 ` Stefan Monnier
2016-09-07 22:50                   ` Michael Heerdegen
2016-09-08  0:19                     ` Stefan Monnier
2016-09-06 21:05           ` Stefan Monnier
2016-09-06 21:35             ` Drew Adams

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=b91b1d27-6802-4199-b693-5524d32bcdc7@default \
    --to=drew.adams@oracle.com \
    --cc=emacs-devel@gnu.org \
    --cc=herring@lanl.gov \
    --cc=monnier@iro.umontreal.ca \
    /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).