all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* Terminology question
@ 2016-04-26 10:20 Jean-Christophe Helary
  2016-04-26 14:48 ` John Wiegley
  2016-04-27  1:58 ` Richard Stallman
  0 siblings, 2 replies; 5+ messages in thread
From: Jean-Christophe Helary @ 2016-04-26 10:20 UTC (permalink / raw)
  To: emacs-devel

I am working on a personal project in/on emacs lisp and I have a terminology question for which I could not find a definitive answer in the elisp reference or in Chassell's introduction.

I cannot find a clear definition of "form", "expression", "symbolic expression", "sexp" and whether the terms are equivalent or not.

According to the Elisp Reference, 1.3.3 a "form" is an expression that you can evaluate. Are there expressions that one cannot evaluate ? The first occurence of "expression" is in the above sentence.

Then there is an explanation in 2.1: "In Lisp, an expression is primarily a Lisp object and only secondarily the text that is the object's read syntax." So, are there lisp objects that cannot be evaluated ?

There is no reference to "symbolic expression" in the Elisp Reference.

In chapter 9.1 there is "A Lisp object that is intended for evaluation is called a form or expression[4]." It is not clear what a Lisp obect not intended for evaluation is. The footnote [4] says "It is sometimes also referred to as an S-expression or sexp, but we generally do not use this terminology in this manual." still, sexp is found in 98 occurrences in the manual mostly in function names and also in error messages.

The second occurence of the term s-expression is in the index and points at that 9.1 section footnote. The index lists that 9.1 section as the place to find info on "expression" "form" "s-expression" and "sexp"...

In Chassell's Introduction on page 2 paragraph 4, it says that atoms and lists are called symbolic expressions, or more concisely s-expressions, the word expression can either refer to the printed representation or to the object held internally in the computer, the term expression is often used indiscriminately and form is used as a synonym.

In the end it is not clear whether the terms are equivalent or not.

Jean-Christophe Helary 


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Terminology question
  2016-04-26 10:20 Terminology question Jean-Christophe Helary
@ 2016-04-26 14:48 ` John Wiegley
  2016-04-27  4:05   ` Jean-Christophe Helary
  2016-04-27 12:46   ` Stefan Monnier
  2016-04-27  1:58 ` Richard Stallman
  1 sibling, 2 replies; 5+ messages in thread
From: John Wiegley @ 2016-04-26 14:48 UTC (permalink / raw)
  To: Jean-Christophe Helary; +Cc: emacs-devel

>>>>> Jean-Christophe Helary <jean.christophe.helary@gmail.com> writes:

> I cannot find a clear definition of "form", "expression", "symbolic
> expression", "sexp" and whether the terms are equivalent or not.

A "form" is a piece of data in Lisp that represents a program, meaning it can
be evaluated without error.

  3       is a simple, self-evaluating form
  (3)     is not a form
  (+ 1 2) is a form

All of these are Lisp expressions, meaning sentences that are legal according
to the grammar of the Lisp language.

> So, are there lisp objects that cannot be evaluated ?

The list '(3) cannot be evaluated, as it will raise an exception about 3
having no definition as a function.

> There is no reference to "symbolic expression" in the Elisp Reference.

A symbolic expression is also called an s-expr, and represents the typical
form of Lisp data that we're used to seeing (here specified in simple BNF):

    sexpr : ATOM | cons
    cons  : (sexpr . sexpr)

In deep history there were also m-exprs (meta expressions), but these are no
longer used, and never were by Emacs Lisp to my knowledge.

> In the end it is not clear whether the terms are equivalent or not.

All forms are representable as s-exprs, but not all s-exprs represent forms.

-- 
John Wiegley                  GPG fingerprint = 4710 CF98 AF9B 327B B80F
http://newartisans.com                          60E1 46C4 BD1A 7AC1 4BA2



^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Terminology question
  2016-04-26 10:20 Terminology question Jean-Christophe Helary
  2016-04-26 14:48 ` John Wiegley
@ 2016-04-27  1:58 ` Richard Stallman
  1 sibling, 0 replies; 5+ messages in thread
From: Richard Stallman @ 2016-04-27  1:58 UTC (permalink / raw)
  To: Jean-Christophe Helary; +Cc: emacs-devel

[[[ To any NSA and FBI agents reading my email: please consider    ]]]
[[[ whether defending the US Constitution against all enemies,     ]]]
[[[ foreign or domestic, requires you to follow Snowden's example. ]]]

  > I cannot find a clear definition of "form", "expression", "symbolic expression", "sexp" and whether the terms are equivalent or not.

I think "form" and "expression" are synonymous; both mean a Lisp object
meant for evaluatoin.

"Sexp" generally refers to text rather than Lisp objets as such.  It
means the textual representation of one object (including nested
objects).

  > In chapter 9.1 there is "A Lisp object that is intended for
  > evaluation is called a form or expression[4]." It is not clear
  > what a Lisp obect not intended for evaluation is.

I don't understand that question.  Every Lisp object is either
intended for evaluation or not.  If it is intended for evaluation,
it is an expression (form).

It would be good to go through the manual to make this consistent and
clear.



-- 
Dr Richard Stallman
President, Free Software Foundation (gnu.org, fsf.org)
Internet Hall-of-Famer (internethalloffame.org)
Skype: No way! See stallman.org/skype.html.




^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Terminology question
  2016-04-26 14:48 ` John Wiegley
@ 2016-04-27  4:05   ` Jean-Christophe Helary
  2016-04-27 12:46   ` Stefan Monnier
  1 sibling, 0 replies; 5+ messages in thread
From: Jean-Christophe Helary @ 2016-04-27  4:05 UTC (permalink / raw)
  To: emacs-devel

Thank you John for the reply.

Let me ask a few more questions. Apologies if I sound picky, I just want to make sure I understand.

> 2016/04/26 23:48、John Wiegley <jwiegley@gmail.com> のメール:
> 
>>>>>> Jean-Christophe Helary <jean.christophe.helary@gmail.com> writes:
> 
>> I cannot find a clear definition of "form", "expression", "symbolic
>> expression", "sexp" and whether the terms are equivalent or not.
> 
> A "form" is a piece of data in Lisp that represents a program, meaning it can
> be evaluated without error.
> 
>  3       is a simple, self-evaluating form
>  (3)     is not a form
>  (+ 1 2) is a form

Ok, that corresponds to 1.3.3:

"A Lisp expression that you can evaluate is called a form. Evaluating a form always produces a result, which is a Lisp object."

> All of these are Lisp expressions, meaning sentences that are legal according
> to the grammar of the Lisp language.

But in 2.1 we find this:

"In Lisp, an expression is primarily a Lisp object and only secondarily the text that is the object’s read syntax."

Which seems to suggest that there is no distinction between "form" and "expression" and thus contradicts 1.3.3.

And that is confirmed by 9.1:

"A Lisp object that is intended for evaluation is called a form or expression[4]."

But then we seem to have a circular definition...

As a conclusion, according to 1.3.3 if evaluating rose produces an error message because no value has been assigned to it, it is not a form, but according to 9.1, if I intend to evaluate rose, which is syntactically valid Lisp, it is a form...

So I am still confused. Maybe it is because I do not understand what "evaluate" means in the context of Lisp. In the Introduction 1.2, there is: 

"If you run it (for which the Lisp jargon is evaluate), the computer will do one of three things: do nothing except return to you the list itself; send you an error message; or, treat the first symbol in the list as a command to do something."

Again, in Introduction 1.3 there is:

"What we will do is evaluate a list that is not quoted and does not have a meaningful command as its first element."

So evaluation can produce an error in which case 9.1 is the correct definition of form and expression: a form is syntactically valid lisp regardless of whether it produces a Lisp object or not (unless we consider that errors can be considered Lisp objects, but that does not seem to be the case).

The obvious conclusion is that there is a confusion in the use of the term "evaluate". In 1.3.3 it means "produce a lisp object", in 9.1 and in the Introduction it means "see if it produces a lisp object". That meaning seems to be the one chosen in the Emacs manual (for ex in 27.7 Executing Lisp Expressions).

I am still confused...

Jean-Christophe Helary 


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Terminology question
  2016-04-26 14:48 ` John Wiegley
  2016-04-27  4:05   ` Jean-Christophe Helary
@ 2016-04-27 12:46   ` Stefan Monnier
  1 sibling, 0 replies; 5+ messages in thread
From: Stefan Monnier @ 2016-04-27 12:46 UTC (permalink / raw)
  To: emacs-devel

> A "form" is a piece of data in Lisp that represents a program, meaning it can
> be evaluated without error.

I'd rather agree with Richard that the issue is not whether it can be
evaluated without error, but whether it is intended for evaluation.

E.g. if you consider

    (let ((x 1)) (+ x 4))
and
    (1 2 3 4 5)

both of those objects are sexps (which I take to mean "the abstract
representation of structured data"), and might be treated as "nothing
more than sexps" (i.e. as data).

Given their shapes, if I had to guess, I'd say that the first is likely
to be a form while the second is likely not to be a form.

This is very closely related to the difference between XML and HTML:
Ignoring the info you get from the namespacing, which basically gives
you a hint about the intention, any XML tree can be considered as
a (potentially invalid) HTML document.  So "sexp" is basically the same
as "XML", and "form" corresponds to "HTML".


        Stefan




^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2016-04-27 12:46 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-04-26 10:20 Terminology question Jean-Christophe Helary
2016-04-26 14:48 ` John Wiegley
2016-04-27  4:05   ` Jean-Christophe Helary
2016-04-27 12:46   ` Stefan Monnier
2016-04-27  1:58 ` Richard Stallman

Code repositories for project(s) associated with this external index

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

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.