1. RE: Unusual EU Problem (must see)

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?
> 
> I get the error message:
>    FunctionBBB has not been declared
>      return FunctionBBB(param)
>                       ^
> 
> After changing the order of both routines, so that I have ...
> 
> ----------=----------=----------=----------=---------
> procedure FunctionBBB(atom param)
>    ?param
> end procedure
> 
> function FunctionAAA()
>    atom param
>    param=1
>    return FunctionBBB(param)
> end function
> ----------=----------=----------=----------=---------
> 
> ... I get the error message:
>    Syntax error - expected to see an expression, not a procedure
>      return FunctionBBB(param)
>                       ^
> as expected.
> 
> If you meant the following, though (as Pete also supposed) ...
> 
> ----------=----------=----------=----------=---------
> procedure FunctionBBB(atom param)
>    ?param
> end procedure
> 
> procedure FunctionAAA()
>    atom param
>    param=1
>    return FunctionBBB(param)
> end procedure
> ----------=----------=----------=----------=---------
> 
> ... I get a warning:
>    Unusual EU Problem.exw:8 - statement after return will never
>    be executed
> 
> So Eu raises a warning, not an error here. Maybe you didn't get the
> warning, because you used "without warning" in your program?
> 
> BTW: I tested this, using the Windows interpreter 2.4.
> 
> <snip>
> 
> Best regards,
>    Juergen
> 
> -- 
>  /"\  ASCII ribbon campain  | "Everything should be made as simple
>  \ /  against HTML in       |  as possible, but not simpler."
>   X   e-mail and news,      |
>  / \  and unneeded MIME     | [Albert Einstein]
> 

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).
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.

Take care for now,
Al

new topic     » topic index » view message » categorize

2. RE: Unusual EU Problem (must see)

Pete Lomax wrote:
> 
> 
> On Thu, 14 Aug 2003 06:39:51 +0000, Al Getz <Xaxo at aol.com> wrote:
> 
> >Very unexpected behavior when i accidentally used:
> >
> >function FunctionAAA()
> >  atom param
> >  param=1
> >  return FunctionBBB(param)
> >end function
> >
> <snip>
> >procedure FunctionBBB(atom param)
> >  ?param
> >end procedure
> 
> >but no real error comes up as usual in Euphoria.
> well, I got Syntax error - expected to see an expression, not a
> procedure. If I change FunctionAAA() to a procedure, which is what I
> think you meant, there is no error or warning.
> 
> The correct warning to report in this case is unreachable code, or
> "will never be executed".
> 
> While I'm here, probably my biggest bugbear:
> 
> The warning system in Euphoria is so OTT that virtually every program
> ever written has without warning as the top line, something which
> should only be done for release code (possibly if the proposed shroud
> -fullsource option is implemented, which creates a single releaseable
> source with all the comments etc left intact). A warning system is not
> much use if most people turn it off, during development!
> 
> 
> Firstly, I'd like warnings to be classified, eg:
> 
> unused parameters
> unused parameters on routines referenced by routine_id
> unused variables
> unused constants
> unused constants created with side effects
> short circuit warnings
> unreachable code
> 
> I think that in much the same way you can have with/without trace
> covering sections of code, but still need the trace() command, you
> need with/without warning and a warning() command, to set the classes
> of warnings you are (locally) interested in.
> 
> My code ends up littered with things like:
> 	procedure onClickButton(int self, int event, seq params)
> 		if self or event or length(params) end if -- suppress warnings
> 
> 	constant menu=create(Menu,"File",0,...)
> 	crud=menu	-- suppress warnings
> 
> 	-- if isVisible(x) or isVisible(y) then
> 	flag=isVisible(x) or isVisible(y)
> 	if flag then
> 
> 	(And no Rob, you are not allowed to add that extremely annoying 
> 	warning to the second case to make them consistent blink
> 
> 
> There is definitely something wrong with
> without warning
> 	constant A=1
> with warning
> having no effect; whether or not you get a warning about A and all
> other unused constants depends solely on whether warning is in force
> at the end of the file, which is counter-intuitive. Maybe I'm being
> simple-minded, but somewhere in the above it must set a flag to
> indicate A has never been referenced to True, should be False.
> 
> 
> Also, if the program dies with an error, it should definitely prompt
> before dumping out the warnings and scrolling the error message off
> the screen.
> 
> 
> My other vote would be for a win32 style debugger, with display of
> subscripts and slices.
> 
> Pete
> 

Hi Pete,

Im for more debug warnings too.
(also see my other reply about the strange error).

Take care for now,
Al

new topic     » goto parent     » topic index » view message » categorize

3. RE: Unusual EU Problem (must see)

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()
> 
> That's the same for Euphoria, but I think humans so can better see the
> difference between this and "return <expression>", as used in functions.
> 
> 
<snip>

Hello again Juergen,

To help clarify this, forget about the past posts.
Write a short program with at least one procedure in it
and try to call it while you are tracing the program
with a line like this:

"return ProcedureName()"

without the quotes.

While you are tracing, the procedure called "ProcedureName"
doesnt get called, yet there is no error info.

If you dont trace, you do get the warning "statement after
return will never get executed".

Its the strangest thing smile  Take a look.

Take care for now,
Al

new topic     » goto parent     » topic index » view message » categorize

4. RE: Unusual EU Problem (must see)

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 message » categorize

5. RE: Unusual EU Problem (must see)

Pete Lomax wrote:
> 
> 
> On Sat, 16 Aug 2003 19:18:12 +0000, Al Getz <Xaxo at aol.com> wrote:
> 
> >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
> Ah! There is your misunderstanding.
> Line 10 is not executed.
> The "return" on line 10 is executed, not "return DoThis()".
> OK, it is quite confusing, a good example of bad coding style making a
> program virtually unreadable, and also a good reason to avoid the evil
> "without warning" and/or ignore those pesky helpful hints Eu tries to
> give you once the program finishes blink
> 
> Your example is the opposite of:
> 
> ?4
> 
> +
> 
> 5-3
> 
> *
> 10
> 
> which prints -21 (think about it, not 4 and an error, and not 60 or
> perhaps even 24, which are other ways a human might read it...)
> 
> and your example is a bit similar to:
> 
> function max(integer a, integer b)
> 	if a>b then return a else return b end if
> end function
> 
> Maybe someone should write a style checker for Eu code.
> HTH
> 
> Pete
> 

Hello Pete,

You've hit the nail on the head smile

It's not a matter of style, however, because the warning
isnt correct either.
The warning starts out "the line *AFTER*..."
note the use of the word 'after'.
In the line:
"return DoThis()"
in my sample code,
'DoThis()'
is in the SAME line as the 'return' statement.

When i saw the warning, i was looking for code after the
return statement.

The only problem now is that my sample code wasnt correct.
Here's a corrected version:


-----------------------
--in 3 year old file:
global procedure DoThis() --was once a function
    ?1
end procedure
-----------------------
--in new file:
with trace
trace(1)

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

x=DoThisToo()
------------------------


Take care for now,
Al

new topic     » goto parent     » topic index » view message » categorize

Search



Quick Links

User menu

Not signed in.

Misc Menu