3 ms·
Your points have nothing to do with ugliness. > Why `pub fn'? Why is public not the default and why do you have to specify that it's a function? If public wer
by uasi 2y ago
Your points have nothing to do with ugliness.
> Why `pub fn'? Why is public not the default and why do you have to specify that it's a function?
If public were the default, you'd end up having to make other functions `priv fn` instead.
> Why `: type' and `-> type', why can't type go before the identifier?
It's easier to parse, and most major typed languages other than C/C++/C#/Java put the type after the identifier.
> Why do you need `File::' and `Bytes::'?
Seriously?
> What is that question mark?
The final version doesn't use a question mark.
> Why does the last statement not need a semicolon?
This is a legitimate question. In Rust, the last statement without a semicolon becomes the return value.
- mFixman 2y ago> If public were the default, you'd end up having to make other functions `priv fn` instead. My guilty pleasure is Go's visibility system, where all functions that start with lowercase are private to the scope of the current class/file and all Functions that start with Uppercase are public. It doesn't look but it would work and it's a mess when you need acronyms, but it somehow works great and the result looks nice.
- kelnos 2y agoI actually really dislike Go's system! Casing, to me, shouldn't be significant. (Just like I dislike how whitespace is significant in Python.) And to me it just doesn't look nice, but I also prefer snake_case over camelCase and PascalCase.