1. misleading error message

constant list = {"A","B","C"}

procedure report()
return list
.....

OK, the above was supposed to be a function, but I typed procedure 
instead. So what was the helpful error message?

test.exu:4
may not change the value of a constant
return list
          ^
Warning: test.exu:4 - statement after return will never be executed

Press Enter...

Who's trying to change the value of the constant, I ask? Not me!
And if that statement after return will never be executed, just 
when _is_ the list going to be changed, anyway :)

Irv

new topic     » topic index » view message » categorize

2. Re: misleading error message

irvm at ellijay.com wrote:
> constant list = {"A","B","C"}
> 
> procedure report()
> return list
> .....
> 
> OK, the above was supposed to be a function, but I typed procedure 
> instead. So what was the helpful error message?
> 
> test.exu:4
> may not change the value of a constant
> return list
>           ^
> Warning: test.exu:4 - statement after return will never be executed
> 
> Press Enter...
> 
> Who's trying to change the value of the constant, I ask? Not me!
> And if that statement after return will never be executed, just 
> when _is_ the list going to be changed, anyway :)

Like all language translators, Euphoria only looks a narrow
context. It can't see the "big picture".

In a procedure, you can only have a simple:
    return
You can't have:
    return expression
so:
    return list
is seen by Euphoria as being two statements on one line.
i.e.
    return
    list ...
It looked like you were starting a new statement:
    list ...
which looks like the start of an illegal statement to
assign to a constant.

The warning about "statement after return"
is just a bonus that most other languages
won't give you.

Regards,
    Rob Craig
    Rapid Deployment Software
    http://www.RapidEuphoria.com

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

Search



Quick Links

User menu

Not signed in.

Misc Menu