forum-msg-id-131726-edit
Original date:2018-01-01 12:40:09 Edited by: petelomax Subject: Re: SWITCH question
If I may step in and summarize what has already been said, the thing that is broken is:
Duplicate case entries trigger a compilation error
But http://openeuphoria.org/docs/lang_branch.html#_147_switchstatement does not actually state that, and apparently the compiler does not always implement it correctly (but sometimes it does!).
We are quite used to this
if x=17 then ?"x is 17" elsif x=17 then ?"x is 17 as well" end if
simply (and not really very helpfully) effectively just ignoring the second branch, whereas
switch x do case 17: ?"x is 17" case 17: ?"x is 17 as well" end switch
sometimes crashes, presumably trying to put 17 in the jump table twice. (but use the real examples from #2 above instead)
NB: we do not give a flying monkeys what that should do were it to somehow compile correctly; it should give a compilation error and not run.
One thing that has just struck me is that if the compiler assumes the jump table entry is 0 or some predetermined base offset when calculating jump_table[17]... not that such explains the sporadic behaviour.
HTH, Pete
|
Not Categorized, Please Help
|

