Version 5 of SEXP

Updated 2006-06-02 15:09:58

short for "S-Expression" [L1 ] (S stands for symbolic).

   The defining RFC-draft: http://theory.lcs.mit.edu/~rivest/sexp.txt
   Rivest's SEXP page: http://theory.lcs.mit.edu/~rivest/sexp.html

Zarutian is half in love with the canonical form because of ease of parsing.

Lars H is more sceptic. Syntactically, plain old Tcl lists are much simpler and more readable.


Comparing Tcl lists and SEXPs may be intructive in explaining some fundamental differences between Tcl and LISP. The following is a SEXP

  (abc (de #6667#) "ghi jkl")

and this is the corresponding Tcl list

  abc {de \x66\x67} "ghi jkl"

Some useful observations are:

  1. Both allow several equivalent ways of encoding the same information, e.g. the #6667# / \x66\x67 could alternatively have been written fg. SEXPs offers about twice as many forms as Tcl lists do, however. (This is typical. In comparison to the radical simplicity of Tcl, LISP is a language suffering from severe featuritis.)
  2. In the SEXP, there is parenthesis around the outer list, whereas there is no such thing in the Tcl list. This reflects the fact that a SEXP inherently has a type (the example is a list), whereas Tcl values are untyped (the example can be read as a list, but also as a string, and the same holds for the final list element; the type is in the beholder).
  3. ...

A Tcl-native encoding of a list of SEXPs as above could be as a list where even elements are types and the odd ones the corresponding values. Then the above example would be

  list {"" abc list {"" de "" fg} "" {ghi jkl}}

if one writes "" for the empty type specifier. (The RFC-draft above also allows for every base string to carry a "display hint" prefix, which looks like "[image/gif]". That effectively means every non-list has a type tag, even though one normally omits it.)


Category Glossary | Category Internet