From: �x���u
Subject: what is S-expression ?
Date: 
Message-ID: <MPG.ff200bc6fde265b989685@news.ntu.edu.tw>
S-expression can be atom 
and atom-pair.....
what is it ?
what abilities does it have ?

Dick Guan

From: Kent M Pitman
Subject: Re: what is S-expression ?
Date: 
Message-ID: <sfwn2bcnvik.fsf@world.std.com>
········@csie.ntu.edu.tw (�x���u) writes:

> S-expression can be atom 
> and atom-pair.....
> what is it ?
> what abilities does it have ?

Forget all of that.  S-expression is an archaic term for expression.
It is ANY Lisp syntax tht can be parsed by the Lisp READ function.  It
is distinguished from M-expression which is a kind of expression that
Lisp used to have back in Lisp 1.5 days (early 1960's) which was
syntactically and semantically different.  Eventually M-expressions
were no longer used and disappeared as redundant.  Old lispers still
use the term.  But always just think "expression".

If you search the archives at http://www.dejanews.com/home_ps.shtml
for S-expression and M-expression on comp.lang.lisp, I wouldn't be
surprised if you find more info.  We've answered this question already
once this year.

Maybe someone should put the longer answer in the Lisp FAQ, too.
(Same with my recent answer about DEFPARAMETER vs DEFVAR, which is
really a common question.) Or maybe they're there already and I'm
wasting my time.  Guess I shoulda looked.  But it's middle of the
night and I'm tired and only reading e-mail because I had bad dreams I
wanted to put out of my mind...  'night folks.
From: William Paul Vrotney
Subject: Re: what is S-expression ?
Date: 
Message-ID: <vrotneyEuq9n6.IFz@netcom.com>
In article <···············@world.std.com> Kent M Pitman
<······@world.std.com> writes:

> 
> > S-expression can be atom 
> > and atom-pair.....
> > what is it ?
> > what abilities does it have ?
> 
> Forget all of that.  S-expression is an archaic term for expression.
> It is ANY Lisp syntax tht can be parsed by the Lisp READ function.  It
> is distinguished from M-expression which is a kind of expression that
> Lisp used to have back in Lisp 1.5 days (early 1960's) which was
> syntactically and semantically different.  Eventually M-expressions
> were no longer used and disappeared as redundant.  Old lispers still
> use the term.  But always just think "expression".
> 

It sounded to me like the original poster was fishing for the recursive
definition of S-expression, actually it looked like homework to me. :-)

We define an S-expression "sexp" recursively as

        sexp is
                atom
           or
                (sexp . sexp)

where atoms are terminal (they terminate the recursion).  We refer to the
second as a "dotted pair" and in many Lisps, dotted pairs are internally
represented by a "cons" data type.  An important sub-type of atom is
"symbol" and an important symbol is NIL.  NIL means all of: the empty list,
not-TRUE and the symbol NIL.  If we have

        (sexp1 . sexp2)

where sexp2 is a list (note that this includes NIL) then the Lisp printer
dispenses with the dot.  For example the Lisp PRINT function prints

        (x . NIL)

as

        (x)

and

        (x . (y . NIL))

as

        (x y)

and

        (x . (y . z))

as

        (x y . z)

We refer to any such printed nested pairs as "lists" and more specifically
ones with the final dot as "dotted lists".

The abilities afforded by S-expressions are quite profound.  Because of this
simple recursive "nesting" definition, all Lisp programs are S-expressions
and pretty much all data can be defined in terms of S-expressions both as a
printable form and internally in a computer.


Meta expressions are used in Allen's "Anatomy of Lisp" to define (or
bootstrap) the ordinary S-expression Lisp that we are more used to.


PS: And please, no tirades about how the atom is not important in Lisp! :-)
-- 

William P. Vrotney - ·······@netcom.com