Re: Implementation Language Choice

Lauri Alanko <la@iki.fi>
2 Mar 2004 11:08:05 -0500

          From comp.compilers

Related articles
[4 earlier articles]
Re: Implementation Language Choice joachim.durchholz@web.de (Joachim Durchholz) (2004-02-13)
Re: Implementation Language Choice kevin@albrecht.net (Kevin Albrecht) (2004-02-13)
Re: Implementation Language Choice lex@cc.gatech.edu (Lex Spoon) (2004-02-26)
Re: Implementation Language Choice joachim.durchholz@web.de (Joachim Durchholz) (2004-02-26)
Re: Implementation Language Choice gdr@integrable-solutions.net (Gabriel Dos Reis) (2004-02-27)
Re: Implementation Language Choice joachim.durchholz@web.de (Joachim Durchholz) (2004-03-02)
Re: Implementation Language Choice la@iki.fi (Lauri Alanko) (2004-03-02)
Re: Implementation Language Choice lex@cc.gatech.edu (Lex Spoon) (2004-03-02)
Re: Implementation Language Choice torbenm@diku.dk (2004-03-06)
Re: Implementation Language Choice bettini@dsi.unifi.it (Lorenzo Bettini) (2004-03-06)
Re: Implementation Language Choice joachim.durchholz@web.de (Joachim Durchholz) (2004-03-11)
Re: Implementation Language Choice mayan@sandbridgetech.com (Mayan) (2004-03-19)
Re: Implementation Language Choice Barak.Zalstein@ceva-dsp.com (Barak Zalstein) (2004-03-26)
| List of all articles for this month |

From: Lauri Alanko <la@iki.fi>
Newsgroups: comp.compilers
Date: 2 Mar 2004 11:08:05 -0500
Organization: Private
References: 04-02-109 04-02-149 04-02-164 04-02-174
Keywords: design
Posted-Date: 02 Mar 2004 11:08:05 EST

Gabriel Dos Reis <gdr@integrable-solutions.net> virkkoi:
> Joachim Durchholz <joachim.durchholz@web.de> writes:
[On pattern matching]
> | Though it's beyond me why this never made it into mainstream imperative
> | languages; it's exceedingly useful.
>
> Probably because people have been using the more general Visitor Pattern?


The more excruciatingly painful, you mean?


I once participated in writing a toy OQL compiler. The implementation
language was preordained to be C++. We did things by the book and used
the visitor pattern instead of "ugly" dynamic casts to discriminate
between different syntactic classes.


It was horrible, really. Having to write a trivial visit-method in
every class, and having to write all the auxiliary visitor classes
whenever the syntax tree had to be traversed. I couldn't help thinking
all the time how much simpler everything would have been had we just
used Haskell, defined a simple datatype for the abstract syntax, and
pattern matched on the terms.


I guess the code would have been shorter by a factor of ten, maybe.




Lauri Alanko
la@iki.fi


Post a followup to this message

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