Re: Euphoria features

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

----- Original Message -----
From: LEVIATHAN <leviathan at USWEST.NET>
To: <EUPHORIA at LISTSERV.MUOHIO.EDU>
Sent: Sunday, November 14, 1999 5:53 AM
Subject: Re: Euphoria features


> Kat wrote:
>
> >
> > >I still want goto's. And i want to be able to goto a variable's
contents
> > >too, as if it were a form of case statement.
>
> I thought about that the other day, and _methinx_ we may already have
goto's,
> just in a different form... calling other procedures.

That's not the same, and calling procedures adds time to your code. Lots of
overhead in compiled languages, but i don't know how Eu does it.

> I mean, sure, I liked the way in BASIC where I could say 'goto (line) 10'
but it
> wasn't all that great to me. in Euphoria, all you need to say is
>
> if <something screwed up happens> then
> <procedure()> else
> <whatever you feel like>

That's not quite how i use gotos. For instance, if i want a better form of
addy mask on irc, better than *!*ident at *.bellsouth.net, i use an if to see
if it's a bellsouth mask, then i skip all the other tests for the other 50
nets that use other location codes in their masks. The procedure you'd call
is what is on the other side of my goto, all the code hasto execute it. In
your example,  i'd have elses stacked up testing for each net, and probably
a test at the bottom involving global vars to test if i should call the
procedure again or not.

What about this:
<begin imaginary code>
pokedata {
if ( $1 is hex ) { convert to dec here | goto poke }
if ( $1 is bin ) { convert to dec here | goto poke }
if ( $1 is octal ) { convert to dec here }
:poke
do the poke here
}

Now, what if there were 500 if statements there? Do you want to write them?
I don't. In that example, there's little chance of encountering 500 number
bases, but there are more than 500 names of people/objects , and more than
500 stars, and more than 500 species, etc ( altho i grant that there are
better ways of handling the getting the qualities of 500 species than an
case/if tree).

The preceeding example  can be restated as :
pokedata {
case $type($1) of {
hex : convert to dec
bin : convert to dec
octal : convert to dec
}
poke it here
}

Imho, there is little difference in the reulting machine code from that case
statement and this goto:
pokedata {
goto $getbase($1)
:hex | convert to dec | goto poke
:bin | convert to dec | goto poke
:octal | convert to dec
}
:poke
poke it here
}

So the words used in the scripting language *can* have little to do with
that the interpreter/compiler makes in the machine code. The language exists
only to make the writing of code easier, so we don't need to remember all
the cpu op codes. If it's easier for you to use the case statement, do so.
If it's better for you to use the if statement, then do that. But since the
machine code may be identical in both cases, why would the language be
designed to restrict which we use? You drive a Ford, someone else drives a
Chevy or Nissan or Kia or Whatever.

Kat

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

Search



Quick Links

User menu

Not signed in.

Misc Menu