[antlr-interest] philosophy about translation

Monty Zukowski monty at codetransform.com
Fri Oct 6 13:34:26 PDT 2006


...
> > Just for the record I am opposed to the translation you show  here.
> > That is not at all what I would expect unless it's clear that  those
> > variables are always constants.
>
>
> Ahh...and therein lies the difference in our approaches. It's not what
> you'd *expect* because of your background
> in language tools. But is it what you'd *want* as a customer who wants
> to replace C code with Java? Answer: customers
> don't want "JOBOL", and they don't want "Cava". (Although, if they do
> want C in Java clothes, there's
> a tool for that: http://ovid.tigris.org/Ephedra/)

Note, you missed the fact that it has to be clear that those variables
are constants.  Obviously, if they are not, then you can't do the
substitution.

Also as I was thinking about it, I don't like eliminating the
variables just because they are constants.  Sometimes programmers do
things like that to make the code more readable, and crunching it into
one line again makes it less readable.  Without knowing the intent of
the programmer I would say it should not do such fancy things as
variable substitution.  Worse yet, if the string is overridden later,
or tested against, or things like that, then you've made the code
harder to maintain by putting the constant everywhere (perhaps
embedded in other strings).

Monty


More information about the antlr-interest mailing list