Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

> Why `pub fn'?

I prefer it this way; defaults should be conservative or more common: I write many many more private functions than public. I'm not sure what your objection to 'fn' is... seems like a superficial problem. It likely makes the language easier for the compiler to parse, and to me, it makes it easier to read.

> Why `: type' and `-> type', why can't type go before the identifier?

Because putting the type afterward is more ergonomic. If you're used to C/C++/Java/etc. it feels weird, but once you start writing code with the type after the declaration, it feels much more natural.

> Why do you need `File::' and `Bytes::'?

I'm not sure what you mean here. They're types. You have to specify types.

> What is that question mark?

The question mark is basically "if the Result is Ok, unwrap it; if it's an Err, return it immediately."

> Why does the last statement not need a semicolon?

Leaving off the semicolon returns the last expression from the block.

> It's like the opposite of everything people are used to.

Maybe if your experience with programming languages is fairly limited...



Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: