forum-msg-id-131750-edit

Original date:2018-01-05 10:10:43 Edited by: irv Subject: Re: SWITCH question

More problems with the switch statement:

include std/stack.e  
  
constant op = stack:new(FIFO)  
    ? op  
 
constant stk = op  
    ? stk  
 
    switch stk do -- err line 
        case op then  
            puts(1, "\n result is first stack \n" )  
        case else  
            puts(1, "\n result is something else \n")  
    end switch  
  

1
1

/home/irv/stk.ex:9 A machine-level exception occurred during execution of this statement (signal 11)

include std/stack.e  
  
atom op = stack:new(FIFO)  
    ? op  
 
atom stk = op  
    ? stk  
 
    switch stk do  
        case op then -- err line has moved 
            puts(1, "\n result is first stack \n" )  
        case else  
            puts(1, "\n result is something else \n")  
    end switch  
  

/home/irv/stk.ex:10
<0091>:: found variable but expected 'else', an atom, string, constant or enum
case op then



^ Notice, please, that this second version has two problems:

  • It did not print the two 1s, unlike the first program
  • Secondly, what does that error message even mean????

Given the difference, I suspect the problems exist in at least two separate places. The first example fails in the actual switch code, and the second is in an earlier step (parsing?).

Clearly, there are some major problems with switch!

Not Categorized, Please Help

Search



Quick Links

User menu

Not signed in.

Misc Menu