POV-Ray : Newsgroups : povray.off-topic : My first C++ program : Re: (And in Haskell. Obviously.) Server Time
4 Nov 2024 13:15:57 EST (-0500)
  Re: (And in Haskell. Obviously.)  
From: Nicolas Alvarez
Date: 20 Sep 2008 18:55:07
Message: <48d57f4a@news.povray.org>
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

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.