RE: Declaring a Function Before it is used

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

Thats right, Pete. In C and C++, you have to use prototypes to this end.
Regards.
----- Original Message -----
From: Pete Lomax <petelomax at blueyonder.co.uk>
To: <EUforum at topica.com>
Subject: Re: Declaring a Function Before it is used


>
>
> On Tue, 28 Oct 2003 18:09:05 -0500, Michelle Rogers
> <michellerogers at bellsouth.net> wrote:
>
> >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"?
>
> Actually it really is not so difficult:
>
> integer r_Even -- extra/instead
>
> integer i
>
> function Odd(integer o)
> if o=0 then return 0 end if
> if o=1 then return 1 end if
> -- return Even(o-1)
> return call_func(r_Even,{o-1}) -- extra/instead
> end function
>
> function Even(integer e)
> if e=0 then return 1 end if
> if e=1 then return 0 end if
> return Odd(e-1)
> end function
> r_Even=routine_id("Even") -- extra/instead
>
> ? Odd(3)
> ?Even(3)
> ? Odd(2)
> ?Even(2)
>
> Analysis
> =======
> You've had to replace the one line "return Even(o-1)" with three:
>
> integer r_Even -- extra/instead
> return call_func(r_Even,{o-1}) -- extra/instead
> r_Even=routine_id("Even") -- extra/instead
>
>
> YES, there is a (valid) beef about this in this forum.
> However, it works, and Eu is fast(er) because of it.
> Is it a major problem?
>
> You decide.
>
> Pete
> PS I would also sacrifice a little speed for ease of programming.
> However, I'm not walking away over this (minor) issue.
> PPS In other languages I believe you have to declare a "prototype", or
> worse independently define it in a .h file, sometimes anyway.
>
>
>
> 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