Re: Incomplete compiler?

Martin.Ward@durham.ac.uk (Martin Ward)
3 May 2002 15:55:05 -0400

          From comp.compilers

Related articles
Incomplete compiler? Uwe.Uta.Altenburg@t-online.de (Uwe Altenburg) (2002-04-24)
Re: Incomplete compiler? haberg@matematik.su.se (2002-04-29)
Re: Incomplete compiler? haberg@matematik.su.se (2002-05-01)
Re: Incomplete compiler? bernhard@cs.waikato.ac.nz (Bernhard Pfahringer) (2002-05-01)
Re: Incomplete compiler? haberg@matematik.su.se (2002-05-03)
Re: Incomplete compiler? Martin.Ward@durham.ac.uk (2002-05-03)
Re: Incomplete compiler? idbaxter@semdesigns.com (Ira D. Baxter) (2002-05-03)
Re: Incomplete compiler? tfb@apocalypse.OCF.Berkeley.EDU (2002-05-04)
Re: Incomplete compiler? haberg@matematik.su.se (2002-05-04)
| List of all articles for this month |

From: Martin.Ward@durham.ac.uk (Martin Ward)
Newsgroups: comp.compilers
Date: 3 May 2002 15:55:05 -0400
Organization: Compilers Central
Keywords: syntax, design
Cc: Martin.Ward@durham.ac.uk
Posted-Date: 03 May 2002 15:55:05 EDT

> [More function names are fine, you can do that without adding random new
> syntax. The 1970s extensible languages let you define, say, your own
> mutant case statement which was just awful. -John]


Quote from the README of a perl module:


"Switch.pm provides the syntax and semantics for an explicit case
mechanism for Perl. The syntax is minimal, introducing only the
keywords C<switch> and C<case> and conforming to the general pattern
of existing Perl control structures. The semantics are particularly
rich, allowing any one (or more) of nearly 30 forms of matching to
be used when comparing a switch value with its various cases."


Perl's "code block" syntax means that you can introduce new "keywords"
into the language (including mutant case statements). How does perl
get away with this where previous extensible languages failed?


I think a major reason for the sucess of perl is that everone is
encouraged to use the CPAN (Comprehensive Perl Archive Network, which
is based on the CTAN, Comprehensive TeX Archive Network), rather than
every programmer or every project inventing their own mini
language. The way things seem to happen is:


(1) A need is discovered (eg people decide that they really *need*
some kind of switch/case statement)


(2) People invent 10 different ways of solving the problem (in perl
TMTOWTDI: There's More Than One Way To DO It)


(3) Someone takes the five best of the ten ways and merges them into a
single, generic, flexible perl module.


(4) Everyone (well, nearly everyone) uses the module instead of
rolling their own.


This seems to me to give all the advantages of extensible languages
while avoiding the problems.


Martin


Martin.Ward@durham.ac.uk http://www.cse.dmu.ac.uk/~mward/ Erdos number: 4
[I know that it's possible to fake up new syntax in perl using code
blocks, but I don't know of anyone who does. We like the existing
line-noise-like syntax just fine. But you're certainly right that a
set of common libraries makes life a lot easier, both for people who
write programs and for people who have to read them. -John]





Post a followup to this message

Return to the comp.compilers page.
Search the comp.compilers archives again.