Re: Euphoria features

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

Kat wrote:

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

<nod> Thats true... but thats how it can be in Euphoria... I may have not
thought about the overhead to procedure calling, as I may have thought there is
no overhead to procedure calling. If there is, I stand corrected.

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

Hrm, then why not a procedure to filter out the masks? take a file of all the
people there on the channel, along with their IP address, and filter it down for
bellsouth masks? It'd essentially be the same thing... sorta like this:
<pseudo-code>
if mask != "bellsouth.net" then <procedure that reads the next line from the
file>()
else <procedure to do whatever you wanted with it, perhaps output it to another
file>()
</pseudo-code>

Then, after the procedure is done, call the above back to continue processing
it.

Essentially the same, no?



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

<nod> Thats how goto's work... they (in my experience) will go back and help in
redirecting the processing, so that there is no need for 500 statements to test
if something is true, just go back and test the next, no?

>
>
> 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
> }
>

<nod> True, except that in the case statement, it isn't told to explicitly go to
the next, where the goto statement says exactly where to go. True?

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

Agreed, yet we do want to be careful what we ask for, as it may only cause bloat
to Euphoria. If a case statement and a goto statement are relatively the same,
then whats the use of implementing goto?

--"LEVIATHAN"

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

Search



Quick Links

User menu

Not signed in.

Misc Menu