RE: Unusual EU Problem (must see)

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

Juergen Luethje wrote:
> 
> 
> Al Getz wrote:
> 
> > Juergen Luethje wrote:
> >>
> >>
> >> Al wrote:
> >>
> >>> Juergen Luethje wrote:
> >>>>
> >>>>
> >>>> Al wrote:
> >>>>
> >>>> <snip>
> >>>>
> >>>>> function FunctionAAA()
> >>>>>   atom param
> >>>>>   param=1
> >>>>>   return FunctionBBB(param)
> >>>>> end function
> >>>>>
> >>>>> Looks normal, doesnt it?
> >>>>> Well, you would think so anyway...but
> >>>>>
> >>>>> FunctionBBB() never executes!
> >>>>>
> >>>>> Why not?
> >>>>>
> >>>>> procedure FunctionBBB(atom param)
> >>>>>   ?param
> >>>>> end procedure
> >>>>
> >>>> <snip>
> >>>>
> >>>>> but no real error comes up as usual in Euphoria.
> >>>>> <<Now why cant that happen with an invalid sequence arg?>> smile
> >>>>>
> >>>>> Shouldnt there be an error message or something?
> >>
> >> <big snip>
> >>
> >>> Yes, the function (procedure) gets declared beforehand of course.
> >>> The strange thing happens when you try to call a procedure with
> >>> "return ProcedureName()"
> >>> as the procedure never gets called, and you dont even see that
> >>> warning you were talking about until you stop debugging
> >>> (from trace mode).
> >>
> >> You did not mention before that you were using trace mode.
> >>
> >> With your both routines in the intended order, and using trace mode,
> >> we have:
> >>
> >> ----------=----------=----------=----------=---------
> >> with trace
> >> trace(1)
> >>
> >> procedure FunctionBBB(atom param)
> >>    ?param
> >> end procedure
> >>
> >> function FunctionAAA()
> >>    atom param
> >>    param=1
> >>    return FunctionBBB(param)
> >> end function
> >>
> >> FunctionAAA()
> >> ----------=----------=----------=----------=---------
> >>
> >>
> >>> Now i know what to look for, but before i found that i didnt
> >>> know what was causing the problem, so i thought i would
> >>> mention it so it could raise an error in 2.5 perhaps.
> >>
> >> Running my code above, exw.exe 2.4 says:
> >>    Syntax error - expected to see an expression, not a procedure
> >>       return FunctionBBB(param)
> >>                        ^
> >>
> >> So there _is_ an error message.
> >>
> >>
> >> You wrote:
> >>| try to call a procedure with
> >>| "return ProcedureName()"
> >>| as the procedure never gets called
> >>
> >> This is neither true nor false, but it depends.
> >> If the statement "return ProcedureName()" is inside a _function_ (as in
> >> your code), then Eu _does_ try to call "ProcedureName()", and correctly
> >> raises an error, because the correct syntax is "return <expression>",
> >> and the name of a procedure is not a valid expression.
> >>
> >>
> >> If "return ProcedureName()" is inside a _procedure_, then these are
> >> actually _two_ statements. We better write:
> >>    return
> >>    ProcedureName()
<snip>

HERE:

-----------------------------------
with trace
trace(1)

procedure DoThis()
  ?1
end procedure

procedure DoThisToo()
  ?2
  return DoThis()
end procedure

DoThisToo()
-----------------------------------

--Note that in line 10 when DoThis() is called
--no value is returned because it's a procedure,
--not a function, but the procedure never gets called.
--In the trace mode it doesnt show up.

Take care for now,
Al

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

Search



Quick Links

User menu

Not signed in.

Misc Menu