[Python-ideas] Enhance definition of functions
Masklinn
masklinn at masklinn.net
Wed Jul 31 10:38:54 CEST 2013
On 2013-07-31, at 08:37 , Haoyi Li wrote:
> I'd like multiline lambdas too, but the syntax is a thorny problem. F# is
> the only language I know (are there others?) that allows you to mix
> whitespace-delimited and paren-delimited expressions, e.g. with
> whitespace-blocks inside parens:
>
> let f n = n + (
> if n % 2 = 0 then
> printf "lol"
> 1
> else
> printf "omg"
> 2
> )
Haskell can do that:
f n = n + (
case n `mod` 2 of
0 -> unsafePerformIO $ do
putStrLn "lol"
return 1
1 -> unsafePerformIO $ do
putStrLn "omfg"
return 2
)
although a difference is that it doesn't have statement blocks, only
expressions (`do` blocks are sugar for monadic chain expressions)
More information about the Python-ideas
mailing list