Re: routine_id mishaps
- Posted by Elliott Sales de Andrade <quantum_analyst at hotmail.com> Dec 14, 2002
- 363 views
>From: xanax at bellsouth.net >Subject: routine_id mishaps > > >Hello all, > >This is strange code (below) because routine_id assigns "my_proc" & >"my_func" >the same value...Can someone (Rob C maybe!) give me a reason why? > ><snip> >with trace >trace(1) > >constant > TRUE = 1, > FALSE = 0 > >sequence > types, > handles, > rps > >handles = {} >rps = {} >types = {} > >global procedure add_routine (object handle, integer rp) >integer pos > pos = find (handle, handles) > if pos then > types[pos] = TRUE -- It does return something > rps[pos] = rp > else > handles = append(handles, handle) > types = append(types, TRUE) > rps = append(rps, TRUE) I think this is wrong. It should be: rps = append(rps, rp) > end if >end procedure > >global function call_routine (object handle, sequence arg) >integer pos > pos = find (handle, handles) > if pos then > if types[pos] then > return {TRUE, call_func (rps[pos], arg)} --function call > else > call_proc (rps[pos], arg) -- procedure call > return {TRUE} > end if > else > return {FALSE} > end if >end function > >procedure my_proc (integer a, integer b) > puts (1, {a,b}) >end procedure >add_routine ("my_proc", routine_id ("my_proc")) > >function my_func (integer a, integer b) > return "Hello!" >end function >add_routine ("my_func", routine_id ("my_func")) > >sequence result > >result = call_routine ("my_proc", {'a','b'}) >-- result is now {TRUE} > >result = call_routine ("my_func", {'a','b'}) >-- result is now {TRUE, "Hello!"} > ><snip> > Euphoria Instant Messenger Have YOU Joined? http://groups.yahoo.com/group/euim/