1. goto

Anyone have an idea of how to make a preprocessor to process gotos?

-- 
Linux User:190064
Linux Machine:84163
http://jbrown105.1avenue.com

new topic     » topic index » view message » categorize

2. Re: goto

On 16 Jul 2001, at 17:34, jbrown105 at hotpop.com wrote:


> 
> Anyone have an idea of how to make a preprocessor to process gotos?

Well, for Eu, you have one big constraint as a preprocessor. The "goto" and 
the :label will haveto be in the same block,, or be one block of it's own. They 
will be restricted to the procedure or function they live in, no jumping into a 
procedure or out of one. No overlapping goto blocks unless you want to do 
some real fancy coding.

So,, with that in mind, locate the "goto" and it's :label, lift them out of
where
they are, drop them into a procedure of that name, passing all the vars used 
between the goto and the :label. Then pass them all back if they are 
changed, and reset them in the place you lifted the goto-:label from.

It's actually easier to do this in the source code. The C64 had "goto line 
number". I added "goto :label", then i added "goto variable", then i was able 
to place the target label anywhere, including in the middle of lines. Ditto with
gosubs. Basically, you see the goto, then search for the :label , unless 
you've already seen it, then you simply resume execution there.

I would like to be able to goto out of any level of loop, to avoid multiple
exits.

Maybe you could do a case statement first, those will all be isolated 
forwards jumps, and not overlapping, a easy thing to do with routine_id(). I 
have like 600 irc server commands that are aching for a case, or a goto 
variable.

Kat

new topic     » goto parent     » topic index » view message » categorize

3. Re: goto

[Slightly off-topic]
I remember reading an article in which the author was responding to the idea
that the use of goto in a program causes "spaghetti" code and nobody could
understand what was happening. This author responded with a beautifully
structured program that had no goto and was equally incomprehensible. It
went along the lines of ...

  constant EndProgram = -1
  integer State

  State = 0
  while not EndProgram do
     if State = 0 then
          <do something> 
          State = 6

     elsif State = 1 then
          <do something> 
          State = 7

     elsif State = 2 then
          <do something> 
          State = 5

     elsif State = 3 then
          <do something> 
          State = 4

     elsif State = 4 then
          <do something> 
          State = 1

     elsif State = 5 then
          <do something>  
          State = 3

     elsif State = 6 then
          <do something> 
          State = 2

     elseif ... etc...
     else
          State = EndPRogram
     end if    
  end while


-----------
cheers,
Derek Parnell
Senior Design Engineer
Global Technology Australasia Ltd
dparnell at glotec.com.au

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




confidential information intended solely for the use of the individual or
entity to whom they are addressed. If you are not the intended recipient of
this message you are hereby notified that any use, dissemination,
distribution or reproduction of this message is prohibited. If you have
received this message in error please notify the sender immediately. Any
views expressed in this message are those of the individual sender and may
not necessarily reflect the views of Global Technology Australasia Limited.

new topic     » goto parent     » topic index » view message » categorize

4. Re: goto

> 
> >Hehe, it would be one of the disguised gotos, silly. With the actual >goto, 
> >put
> >the label before the loop, and goto it. Simple.
> >
> >Kat
> 
> Yes, but restricted by the structure of the language.
> 
> I would like to know how euman has implemented his goto's
> What happens if the programmer puts goto or label where they should not
> be?..Euman?

Actually Karl's writing Goto's ask him.

I dont see a pressing need for them in euphoria.

At times it might be nice to have them but there are ways around it.
1. Dont get yourself into situations where you would.

If you have the Euphoria source or the translator you'll see
Rob isnt entirely opposed to "goto's" just having them in Euphoria.

Euman
euman at bellsouth.net

new topic     » goto parent     » topic index » view message » categorize

5. Re: goto

Ýòî ñîîáùåíèå â ôîðìàòå MIME ñîñòîèò èç íåñêîëüêèõ ÷àñòåé.

------=_NextPart_000_01C124BC.901F3360

new topic     » goto parent     » topic index » view message » categorize

6. Re: goto

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.

Jeremy

Edmund Burke: "All that is necessary for evil to triumph is for good men to do
nothing."

new topic     » goto parent     » topic index » view message » categorize

7. 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.
> 
> Jeremy
> 
> Edmund Burke: "All that is necessary for evil to triumph is for good men to
> do nothing."

Hi there Jeremy and others,


Maybe another way of looking at this is that with most languages
you can't email the author or post a message asking for features
to be added...you either take the language as it is or leave it.
Im sure that if you were to write your own language you would use
standards that you believed in for some things.
A while back i had to write a somewhat complex routine that 'could'
have used goto's but instead i had to use 'while' loops so that
the code could jump back sometimes and fall through other times.
Is that neat coding?  I dont think so, but im still not sure if
a 'goto' would be that neat either.  Maybe something else...
Some routines wont come out that neat in any language.

BTW, the same routine in 'Basic' would use a few goto's hee hee.
I dont use that language any more in favor of Euphoria, even though
there are no goto's....there must be some reason i'm putting up 
with it :)


Take care,
Al

And, good luck with your Euphoria programming!

My bumper sticker: "I brake for LED's"

new topic     » goto parent     » topic index » view message » categorize

8. 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

new topic     » goto parent     » topic index » view message » categorize

Search



Quick Links

User menu

Not signed in.

Misc Menu