Re: Declaring a Function Before it is used

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

wait a sec...i thought this language was supposed to be EASIER to use...then
why would you have to go through all of this for a simple "declare a
function before it's used"?

----- Original Message -----
From: "Derek Parnell" <ddparnell at bigpond.com>
To: <EUforum at topica.com>
Subject: Re: Declaring a Function Before it is used


>
>
> ----- Original Message -----
> From: "Michelle Rogers" <michellerogers at bellsouth.net>
> To: <EUforum at topica.com>
> Sent: Tuesday, October 28, 2003 10:06 PM
> Subject: Declaring a Function Before it is used
>
>
> > Also, can anyone tell me if there is a way to declare a function before
it
> > is used.
>
> You can't, damn it! This is the thing I most want in Euphoria, but the
author is philosophically against it.
>
> > If not, how do you handle things like:
> > Run Function A, which calls Function B
> > Function B calls Function C
> > If statement then
> >   Function C calls Function D
> > else
> >   Function C calls Function A
> > end if
> >
> > This seems impossible to handle if you can't declare Function A ahead of
> > time, because you can't move it ahead of Function C to solve the
problem,
> > since that causes a problem of not being able to call Functions B and C
from
> > Function A
> >
>
> Welcome to the wonderful world of 'routine_id()'.
>
> The function 'routine_id()' returns an index to a routine, and the
routines 'call_proc()' and 'call_func()' can use this index to invoke the
routine indirectly. Here is an example...
>
> -- This need to be near the front of the file.
> integer r_FuncA, r_FuncB, r_FuncC, r_FuncD
>
> function FuncA()
>   x = call_func(r_FuncB,{})
> end function
>
> function FuncB()
>  x = call_func(r_FuncC,{})
> end function
>
> function FuncC()
>  if statement then
>     x = call_func(r_FuncD,{})
>  else
>     x = call_func(r)FuncA,{})
>  end if
> end function
>
> function FuncD()
>  . . .
> end function
>
> -- These need to be after the routines they are referring to.
> r_FuncA = routine_id("FuncA") -- Notice the routine name is in a string.
> r_FuncB = routine_id("FuncB")
> r_FuncC = routine_id("FuncC")
> r_FuncD = routine_id("FuncD")
>
>
> --
> Derek
>
>
>
> TOPICA - Start your own email discussion group. FREE!
>
>

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

Search



Quick Links

User menu

Not signed in.

Misc Menu