Re: How Do CL's Macros Differ from Scheme's?
- From: Kaz Kylheku <kkylheku@xxxxxxxxx>
- Date: Mon, 5 Oct 2009 05:38:38 +0000 (UTC)
On 2009-10-04, Vassil Nikolov <vnikolov@xxxxxxxxx> wrote:
To clarify the analogy, consider how context-sensitive grammars
better (or more fully) describe programming languages, but are
The analogy is poor because both hygienic and non-hygienic macro systems
are practical, useful, and in actual wide use.
Whereas, context-sensitive grammars are of little help in programming
languages and are not widely used at all.
harder to deal with, so context-free grammars are used together with
additional "extra-grammatical" facilities to describe languages and
process programs written in them.
Not only is there no feasible way to represent that information in
the context-sensitive grammar, it doesn't even reflect how the
users think about the language.
What is a context-sensitive grammar? It's one in which you can have
rules that rewrite strings of several nonterminal symbols, rather
than just one. The rules can have several symbols on the left side,
not just one.
So in a context free grammar we might have a rule like:
A -> A B ;; A generates an A followed by B.
In a context sensitive grammar we might have stuff like.
A C -> A B ;; a followed by B generates A B; C is eaten.
D A -> B ;; A preceded by D generates B.
It's not even remotely obvious how to apply this to achieve
a syntactic representation of the ``extra grammatical'' stuff
found in a typical programming language.
It's also not clear that encoding that stuff in this kind of grammar would not
just constitute a convoluted representation of the same data structures which
are used to solve the problem in the conventional ways.
That it to say, suppose you solve some familiar C parsing problems using the
above kind of language. A C program which refers to a nonexistent identifier in
a primary expression is identified as syntactically ill-formed. And syntax of
the form T(x); is recognized as a declaration because T was previously declared
as a typedef name.
How would the context-sensitive rules achieve that?
A normal compiler simply makes references to a symbol table. Has x been
declared? What kind of name is T?
Wouldn't the context-sensitive rules simply build up some kind of
representation of a symbol table, within the string of grammar symbols
being pushed around? So the context which would allow T(x); to be
recognized as a declaration would actually be a symbol table
in which T is declared as a type name, only this symbol table would
look like a string of grammar symbols (to someone who doesn't know
better). Someone who does understand this context-sensitive grammar,
such as hopefully its implementor, would be able to look at the
string of grammar symbols and utter ``yes, this rule applies because
T has been declared to be a type name''.
So what would really be achieved, and how would that be better
and more complete?
Hygienic macros do bring something to the table, and so do non-hygienic
ones.
.
- References:
- How Do CL's Macros Differ from Scheme's?
- From: Proponent
- Re: How Do CL's Macros Differ from Scheme's?
- From: Paul Donnelly
- Re: How Do CL's Macros Differ from Scheme's?
- From: Tamas K Papp
- Re: How Do CL's Macros Differ from Scheme's?
- From: Vassil Nikolov
- Re: How Do CL's Macros Differ from Scheme's?
- From: Tamas K Papp
- Re: How Do CL's Macros Differ from Scheme's?
- From: Vassil Nikolov
- Re: How Do CL's Macros Differ from Scheme's?
- From: Pascal Costanza
- Re: How Do CL's Macros Differ from Scheme's?
- From: Vassil Nikolov
- Re: How Do CL's Macros Differ from Scheme's?
- From: Pascal Costanza
- Re: How Do CL's Macros Differ from Scheme's?
- From: Vassil Nikolov
- How Do CL's Macros Differ from Scheme's?
- Prev by Date: Re: Is this a bug in CMU Common Lisp 19c Release (19C) ?
- Next by Date: Re: loading csv-files: too much memory-consumption
- Previous by thread: Re: How Do CL's Macros Differ from Scheme's?
- Next by thread: Re: How Do CL's Macros Differ from Scheme's?
- Index(es):
Relevant Pages
|