Re: goto... is it so bad?
James Kanze wrote:
I do know of at least
one compiler (for Modula-2), however, that based itself on the
explicitly written structures, and didn't even try to optimize
if there was a goto. According to the authors of the compiler,
this resulted in much faster optimization, at no cost to typical
(Modula-2) programs.
And who has written an M2 compiler since 1990? Nobody. Yes, I also knew
of compilers written in the 80's that would abandon all optimizations if
there was a goto. And regardless of the justifications put out by the
authors of such, I'll bet the real answer is they were ignorant of well
known compiler technology. A lot of people did write compilers in the
80's who didn't know anything about it. There's nothing slow about the
loop detection algorithms. I implemented them to run on a friggin' 16
bit DOS computer in 1985.
Of course, most of the optimizing technology that you would have
been taught in 1982 was developed for Fortran, where you didn't
have that luxury.
C'mon, James, even Fortran had structured loops (DO 10 I). Fortran's
heyday was the 60's. The state of the art had long since left Fortran
behind in the 70's. Structured programming was well entrenched by 1982.
Structured programming (i.e. goto-less) was the great buzzword of the 70's.
The buzzword of the 80's was object-oriented programming.
The buzzword of the 90's was generic programming.
The buzzword of the 00's is metaprogramming.
The buzzword of the 10's will be (I predict) concurrent programming.
One could argue that, today, we could do
better. Still, it's a tried and true technology, and if I were
writing a compiler today, I'd probably use it, not because I
want to support goto particularly well, but because I know it
works, given the number of compilers which use it.
You'd also use it because it's actually *easier* to write the compiler
that way. It really does pay off to read a book on compiler construction
before expending a large portion of your time implementing one <g>.
--
[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]