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 2:34 PM
Subject: Re: Euphoria features


> Kat wrote:
>
> >
> > 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?

No, that's not what i was doing. Instead of this in a nicklist popup:
mode # +b $address($$1,4)
i use this:
mode # +b $newmask($address($$1,4))
which i have written to notice the location codes in some addys, and leave
those in the mask, while blocking all the other variable parts of the dialup
mask. It's handy in bans, akicks, identifying clones better, ident
variables, etc. Like this:

//echo -s $newmask(nick!ident at user-38ldh1q.dialup.mindspring.com,4)

*!* at user-*ldh*.dialup.mindspring.com
( the ldh is the location )

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

My code didn't go back, it went forwards. Loop commands go back "better", in
coding style, anyhow. I didn't give a looping example.

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

The compiler/interpreter will insert the opcode for a jump to the end of the
case block, so you don't need to write it. Or for those compilers making a
procedure out of everything, a RetFmSub. In both examples above, the poke is
executed after the input is proofread.

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

`Cause not everything is easiest in a case block,, in some cases, it is as
bad as a stack of else blocks. I saw a case statement that filled 32K once
written by someone trying to make all his code inline and not call
procedures. ewwww.

Kat

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

Search



Quick Links

User menu

Not signed in.

Misc Menu