brownplt / pyret-lang

The Pyret language.
Other
1.07k stars 110 forks source link

`block` not usable for `else`? #930

Closed shriram closed 7 years ago

shriram commented 7 years ago

I would have expected the following to work:

if false:
  "wrong one"
else block:
    print("this case")
  "right one"
end

but neither the indenter (as seen above) nor the language (error signaled at else) understands the program.

blerner commented 7 years ago

No, we decided a long time ago when working with block that it belongs solely at the initial keyword ofa blocky thing, and applies to all the blocky things within it. So, it belongs on the if, and applies to both the then and else branches. Ditto for cases and every case within it. Documented http://www.pyret.org/docs/latest/Blocks.html#%28part._s~3ablocky-blocks%29, just after the green good example.