Re: Implementation Language Choice

Lorenzo Bettini <bettini@dsi.unifi.it>
6 Mar 2004 14:03:46 -0500

          From comp.compilers

Related articles
[7 earlier articles]
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: Lorenzo Bettini <bettini@dsi.unifi.it>
Newsgroups: comp.compilers
Date: 6 Mar 2004 14:03:46 -0500
Organization: CINECA
References: 04-02-109 04-02-149 04-02-164 04-02-174 04-03-014
Keywords: design
Posted-Date: 06 Mar 2004 14:03:46 EST

Lauri Alanko wrote:
> 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.


Hi,


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.


http://www.lorenzobettini.it/software/doublecpp/index.html


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
--
+-----------------------------------------------------+
| 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) |


Post a followup to this message

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