Why is the syntax the way it is?
Bait does not support block comments:
- Complicates lexing and parsing, especially nested block comments
- Hard to format, especially inline comments (a built-in formatter is planned)
Using a decent editor with line wrapping and shortcuts, you can achieve almost the same level of convenience!
For details, I recommend reading https://futhark-lang.org/blog/2017-10-10-block-comments-are-a-bad-idea.html.
- Natural logic flow
- Flow from left to right, mirroring natural language
- Consistent with general design "value before type", e.g. function parameters
- No ambiguity: Use of the designated keyword
as
- Efficient parsing
Type(val)
- Confusable with function calls:
Type(val)
vsfunc(param)
- Problematic parsing without unlimited lookahead, e.g.
- References
&u8
- (nested) Arrays
[][]f64
- References
- Harder to type as code has to be inserted before and after the casted value
- Confusable with function calls:
- No name collision with symbols in other packages
- Clear scope and explicit usage
- Global variables
- Hard to trace where a variable and value changes come from
- Unintended coupling of independent code parts
Parameter names of function types must be named, e.g.
type Fetch := fun (method string, url string) []u8
- Improved Readability:
- Purpose of each argument is easier to understand
- Reduced chance of parameter mix-ups
- Better tooling support and documentation
type Fetch := fun (string, string) []u8