|
|
Orchid XP v8 wrote:
> In the case alternatives, the line end *is* the delimiter. So if you
> were to "change only the spacing" then you could actually CHANGE THE
> MEANING of the program! (In fact, likely, cause it to no longer
> compile.) This is different from "curly bracket languages" where you use
> "{", "}" to delimit blocks, and ";" as a seperator. In Haskell,
> generally a newline is a seperator, and indentation delimits blocks.
>
> So, this works:
>
> case foo of
> 1 -> bar1
> 2 -> bar2
> 3 -> bar3
>
> If the expressions are a bit bigger, you can say
>
> case foo of
> 1 ->
> very_long_thing_1
> 2 ->
> very_long_thing_2
> 3 ->
> very_long_thing_3
>
> And if they're really long, you can say
>
> case foo of
> 1 ->
> multiline1
> multiline2
> multiline3
> 2 ->
> another_block_1
> another_block_2
> 3 ->
> yet_another_block
>
> or some such. The case expression itself ends when we get to something
> less indented.
Just like Python, then :)
Post a reply to this message
|
|