Kurt Nørmark
Department of Computer Science, Aalborg University, Denmark
Abstract Previous lecture Next lecture Index References Contents | In this lecture we will see how to establish new languages by means of Lisp and Scheme. If we - for academic reasons - establish the same language as we come from we are in the business of meta circular abstraction (in our case Lisp in Lisp). This will be briefly illustrated. We will also see how SGML/HTML/XML languages can be hosted in Scheme. |
Introduction to linguistic abstraction |
Linguistic abstraction Slide Annotated slide Contents Index References Textbook |
The concept Linguistic abstraction: Linguistic abstraction is the act of establishing a new language | In many contexts, linguistic abstraction is qualified with the word 'meta'. Thus we speak about metalinguistic abstraction, emphasizing that we enter a higher language level than the level we came from. |
Abstraction is a central discipline in all serious programming efforts. We have discussed functional abstraction in earlier parts of this material. Procedural abstraction is central in both the imperative paradigm and the object-oriented paradigm. Here we have contrasted functional abstraction with linguistic abstraction. |
|
Linguistic abstraction in Lisp Slide Annotated slide Contents Index References Textbook |
|
|
Fine grained linguistic abstraction in Lisp Slide Annotated slide Contents Index References Textbook |
|
|
|
An example of fine grained abstraction Slide Annotated slide Contents Index References Textbook |
|
Program: A sample document in a course home page language. The outer 'keyword' is course-home-page .
Inside a course-home-page form there may be a number of subclauses.
We see a name clause, a number-of-lectures clause etc. The important point of the example is that the expression is
regarded as a clause in a new language, which we somehow want to implement
with the purpose of 'solving some problem' - here to generate a set of coherent
web pages for some activity. |
|
Program: An almost empty outline of the functions that implement the course home page language. Each kind of subexpression is either implemented as a function or as a macro.
In this simple example, macros are not used. |
|
|
Coarse grained linguistic abstraction in Lisp Slide Annotated slide Contents Index References Textbook |
|
|
An example of coarse grained abstraction Slide Annotated slide Contents Index References Textbook |
|
Program: A sample document in the course home page language. This is an example of a web document in the new course home page language.
We will not implement the language here, just sketch the overall approach
of the processing of the document. |
|
Program: Reading the document as a list structure. We open a port to the document and use the read primitive in Scheme to read the list
expression on the file. The procedure or function process-document is supposed to
implement the processing semantics of the new language. |
|
Program: A simple demo processing of the document. We just extract some information about the document. No attempt is made here
to implement the language, nor to process the document in any realistic way. |
|
Language embedding |
Embedded languages Slide Annotated slide Contents Index References Textbook |
The concept embedded language: A new language N is an embedded language in an existing language E if an expression in N can be used as a subexpression of a construct in E. | As a matter of practical organization the interpreter of the new language N is made available as a function in the existing language E. |
More or less elegant embedding of one language into the other is found in numerous web contexts |
Examples of language embedding in HTML Slide Annotated slide Contents Index References Textbook |
|
Program: An example of an ASP document. |
|
Program: An example of a JSP document. |
|
Program: An example of a BRL document. BRL - Beautiful Report Language - is a Scheme based web server framework which allows the web programmer
to embed Scheme fragments into HTML |
|
|
Course home page embedding in Scheme Slide Annotated slide Contents Index References Textbook |
|
Program: A sample embedding of a course home document in a Scheme program. We use a quasiquotation to provide for a representation of the course home page as a list structure in the Scheme context. |
|
Language Mirroring |
Mirrored Languages Slide Annotated slide Contents Index References Textbook |
The concept mirrored language: A new language N is a mirrored language in an existing language E if an expression in N in a systematic way can be represented as an expression in E. | The mirror of N in E does not call for a new interpreter. A new interpreter as need for an embedded language i E. A mirror expression N-expr is written in E, and it can be evaluated by the processor (interpreter) of E. |
|
An introduction of LAML - with special emphasis on the HTML mirroring rules |
|
Course home page mirroring in Scheme (1) Slide Annotated slide Contents Index References Textbook |
|
|
Program: The course home page DTD. The DTD is essentially a context free grammar of the new XML language. XML DTDs are a heritages from SGML (The Standard Generalized Markup Language).
|
|
Program: The script that parses the DTD. |
Program: The script that generates the mirror. |
|
Program: The mirror in Scheme of the course home page. |
Course home page mirroring in Scheme (2) Slide Annotated slide Contents Index References Textbook |
|
Program: A sample course home page that uses the course home page mirror functions. |
|
|
|
Course home pages ala Course Plan Slide Annotated slide Contents Index References Textbook | The course home pages of the Programming Paradigms is made by the Course Plan system. The principles used in the Course Plan system are the same as illustrated about for the toy course home pages. |
|
Program: A Course Plan XML-in-LAML document. |
|
Embedding versus mirroring Slide Annotated slide Contents Index References Textbook |
|
|
Lisp in Lisp |
Why 'Lisp in Lisp' Slide Annotated slide Contents Index References Textbook | In this section we will look at a principled implementation of Lisp in Lisp. In concrete terms we will study a partial Scheme implementation in Scheme itself. |
|
|
|
|
An overview of Scheme constructs Slide Annotated slide Contents Index References Textbook |
|
|
|
Scheme in Scheme Slide Annotated slide Contents Index References Textbook |
|
Program: The eval and apply functions (procedures) of the Scheme interpreters. The full interpreter
needs a lot of relatively small helping functions (procedures) that we do not show here. |
|
|
The eval and apply primitives Slide Annotated slide Contents Index References Textbook |
|
Table. An illustration of eval and apply. In the first two rows we construct a list structure of the usual html , head , title , and body HTML mirror functions. In the first row, the list structure is made by the list function. In the second row, we use the convenient backquote (semiquote) facility. In both cases we get the same result. The last three rows illustrate the use of apply . apply is handy in the cases where the parameters of a function is already organized in a list. What it interesting in our current context, however, is that apply is really an implementation primitive of Scheme, which is made available in the language itself. |
|
|
Chapter 6: Linguistic abstraction
Course home Author home About producing this web Previous lecture (top) Next lecture (top) Previous lecture (bund) Next lecture (bund)
Generated: July 2, 2013, 09:15:51