Hi Folks,
Would you provide a use case for creating two levels of syntax please?
I will provide two use cases, one from Lisp and the other from XML:Books.
Use Case #1: Recall from my previous message that the Lisp language defines two levels of syntax: s-expressions and Lisp forms. A list that is an s-expression may contain any elements, whereas a list that is a Lisp form must start with a symbol (This is a bit simplified – see John Cowan’s post). Now here’s why the Lisp folks created two levels of syntax: Lisp has functions and macros. The arguments to a function must be Lisp forms, which are evaluated before calling the function. Conversely, the arguments to a macro only have to be s-expressions, the arguments are not evaluated before calling the macro; the macro assigns a meaning to the s-expression (very neat!). (I realize this explanation is a bit terse. Hopefully, however, it gives you some feel for why two levels of syntax are important/needed in Lisp.)