RE: goto

new topic     » goto parent     » topic index » view thread      » older message » newer message

Subject: Re: goto




Jeremy Peterson wrote:
 
> I like languages that let the programmer do what he wants instead of what
the
> language creator thinks the programmer should be allowed to do.  Goto is a
valuable
> part of a language, and very useful in cases where other language features
haven't
> been implemented like continue in loops.  One con of putting goto in a
language
> though is that it slows it down, which is probably one reason Rob won't
put
> it in Euphoria.  It may make it easier to write sloppy code, but people
who
> will do that will find some way to do it whether they have goto or not, so
don't
> punish the people who might need it by leaving it out.

Hi Jeremy,

In previous recent thread about 'goto', there was the example
with the Euphoria 'exit' operator.

For example, Turbo Basic 1.1 has 6 different 'exit' operators:

exit select
exit def
exit for
exit if
exit loop
exit sub

Quick Basic 4.5 has 5 different 'exit' operators:

EXIT DEF
EXIT DO
EXIT FOR
EXIT FUNCTION
EXIT SUB

Plus they both have 'goto', 'gosub/return', subs and functions.

And these *all* basic's *exits* serve for a single purpose, exactly
to *exclude gotos* from the program structure.

Euphoria has no goto, has no gosub/return, but has a single 'exit',
and has 'return'/'return something' in procedures, functions and types.

And a Euphoria programmer can do much much much much ... much more
than all at all Turbo Basic 1.1 and Quick Basic 4.5 programmers
in the World.

Do you *want* to learn 11 exit operators to do all you *want*
in these basics as a programmer?

Just a joke. I think there is a good sense of humor on this list.

Good Luck!

Regards,
Igor Kachan
kinz at peterlink.ru

----------------------------------------

Euphoria has:

end if
end for
end while
end function
end procedure
end type

just to exit a block of code, while most languages designers understood that
just "end;", or just a character '}', or just an indentation change, would
be good enough for the purpose.

Isn't this even worse? I'd say yes, because you use "exit" far less often
than "end".

As far as the goto statement is concerned, my personal taste would be to
have dedicated constructs taking care of its main uses. I think indeed that
a language is made for the programer to do as litle translation as possible
between his thought and executable, maintainable code. Euphoria can largely
improve in this respect.

A possibility could be 

- using "exit 3" to exit 3 levels of loop above current (so that exit 0 =
exit), perhaps exit -2 to exit all loops but the outmost to.

- continue/next would go to the top of the loop, executing its "starting"
code (incrementing index or testing condition). Same extension.

- retry (or goback?) to go to the top of the loop without executing the
"initial" code. Same extension.

- exif: like exit, but for if-blocks.

Coded all that  (and goto) in a modified version of the PD source, but I'm
now working on the ESL, so that I didn't test it yet.

CChris

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu