RE: Declaring a Function Before it is used

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

Robert Craig wrote:
> 
> 
> Irv Mullins wrote:
> > I understand the desirability of declaring a routine before referencing 
> > it. But why couldn't something like:
> > 
> >  declare function foo(2) 
> >  or
> >  declare function foo ( name, age )
> > 
> > be used to declare a routine in advance? Seems that meets the 
> > philosophical requirements as well as the practical ones.
> 
> In practice, people would simply arrange their 
> routines in random order, then keep adding 
> declarations until the interpreter shuts up.
> 
> I like having some kind of logical order imposed,
> and machine verified. You may have an even more
> logical way of arranging some of your routines,
> but what does it mean to me as the reader of your 
> code? And is it machine verified?
> 
> I still think the advantages of 
> "define-it-before-you-use-it" outweigh
> the nuisance of occasionally having to copy/paste
> a routine to a new place. It may not be desirable 
> in *every* program, but when people know there are 
> no exceptions to this rule, it promotes the 
> readability and maintainability of Euphoria 
> programs in general.
> 

Please explain to me how, in the example below, the called routine is
defined-before-use ...

  integer r_ProcTwo

  procedure ProcOne()
     call_proc(r_ProcTwo,{})
  end procedure

  procedure ProcTwo()
    . . .
  end procedure

  r_ProcTwo = routine_id("ProcTwo")

-- 
Derek

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

Search



Quick Links

User menu

Not signed in.

Misc Menu