News for hackers. Stuff that matters.
Re:Such a Little Thing: The Semicolon in Rust by loup-vaillant on Friday October 19, 2012 @04:23AM (#4672705)
Bug prone? The compiler will inevitably warn you about your error at compile time. No such bug will have any consequence beyond that.

This is also not such a big problem when a human reads the function. We can always see at a glance the return type of the function. Either it's explicitly declared, or it's a lambda whose usage is readily visible. Semicolon or not, you can easily guess if the function is supposed to return its last expression, or not.

By the way, the compiler could do the same. Knowing that, there probably will be helpful error messages such as "did you forget the last semicolon?", or "should you remove the last semicolon?".

The semicolon is really just a small confirmation. That's why they didn't chose a heavier syntax.

Re:Such a Little Thing: The Semicolon in Rust by wladimir on Friday October 19, 2012 @05:11AM (#4672801)
Ok, I misunderstood then. I thought it would subtly return no value instead of a value, and you'd only discover this at run time. That would be bug prone. If it simply generates a compilation error, no problem.
Re:Such a Little Thing: The Semicolon in Rust by danieldk on Friday October 19, 2012 @08:06AM (#4673125)
The thing is that in a safe language, a value always evaluates to a value of the type of the expression[1]. E.g. in Haskell, if a function returns a list:

  foo :: Int -> [a]
It should always evaluate to a list. There is no such thing as a null pointer. The only thing that comes close to a nullable type is an option type such as Maybe:

  data Maybe a = Just a | Nothing
The function

  bar :: Int -> Maybe [a]
can either evaluate to a Just [a] or Nothing.

[1] Actually, I lied a bit, since there is bottom: http://www.haskell.org/haskellwiki/Bottom But bottom does not fullfil the same role as, say null pointers.