|[7 earlier articles]|
|Re: Implementation Language Choice firstname.lastname@example.org (Joachim Durchholz) (2004-02-26)|
|Re: Implementation Language Choice email@example.com (Gabriel Dos Reis) (2004-02-27)|
|Re: Implementation Language Choice firstname.lastname@example.org (Joachim Durchholz) (2004-03-02)|
|Re: Implementation Language Choice email@example.com (Lauri Alanko) (2004-03-02)|
|Re: Implementation Language Choice firstname.lastname@example.org (Lex Spoon) (2004-03-02)|
|Re: Implementation Language Choice email@example.com (2004-03-06)|
|Re: Implementation Language Choice firstname.lastname@example.org (Lorenzo Bettini) (2004-03-06)|
|Re: Implementation Language Choice email@example.com (Joachim Durchholz) (2004-03-11)|
|Re: Implementation Language Choice firstname.lastname@example.org (Mayan) (2004-03-19)|
|Re: Implementation Language Choice Barak.Zalstein@ceva-dsp.com (Barak Zalstein) (2004-03-26)|
|From:||Lorenzo Bettini <email@example.com>|
|Date:||6 Mar 2004 14:03:46 -0500|
|References:||04-02-109 04-02-149 04-02-164 04-02-174 04-03-014|
|Posted-Date:||06 Mar 2004 14:03:46 EST|
Lauri Alanko wrote:
> Gabriel Dos Reis <firstname.lastname@example.org> virkkoi:
>>Joachim Durchholz <email@example.com> 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 think in these cases the best thing would be to have double dispatch
in the language, for this reason I implemented doublecpp.
Doublecpp is a preprocessor for C++ that handles a new linguistic
construct for defining branches of a multi-method. The "right" branch
of such a method will be selected dynamically at run-time according to
the actual type of the object on which the method is invoked and to the
actual type of the first argument: double dispatch.
Doublecpp is free software; you are free to use, share and modify it
under the terms of the GNU General Public License (see COPYING).
hope this helps
| Lorenzo Bettini ICQ# lbetto, 16080134 |
| PhD in Computer Science |
| Dip. Sistemi e Informatica, Univ. di Firenze |
| Tel +39 055 4796741, Fax +39 055 4796730 |
| Florence - Italy (GNU/Linux User # 158233) |
Return to the
Search the comp.compilers archives again.