4 ms·
Personal taste, not factual One-True-Way™ It looks on the surface like almost Rust meets JS with a sprinkling of Ruby/Smalltalk. Semicolons in 2018, really? I
by himom 8y ago
Personal taste, not factual One-True-Way™
It looks on the surface like almost Rust meets JS with a sprinkling of Ruby/Smalltalk.
Semicolons in 2018, really? Indentation and line-oriented parsing makes code more beautiful. Heck, in general, enums, arrays and dictionary literals shouldn’t even need commas if there’s one tuple per line. Extra typing is a waste of time and clutters-up code with distracting, Christmas ornament “blink tags” that go “Ho, ho, ho” when anyone walks by.
# package name is the same as the directory path
# module name is the same as the filename sans extension
# big modules can be broken up into separate include files
con X: int = 6 # constant
var M: int = 17 # module-public variable
mix any # module-private mixin
λ any? -> bool
each {x| if (Block? ? yield(x) : x): return true}
false
ext []: mix any # module-private type extension
typ T: int[10][8]
λ Zero? -> bool: any? {x| x.any? {y| y == 0}}
typ S
a, b: int
x, y: float
s[7..6], t[5], u[4..2], _[1], v[0]: byte
λ Good? -> bool: xGood? & yGood? # no & / && distinction, precedence by expression type
λ xGood? -> bool: x > 0
λ yGood? -> bool: y > 0
uni Q # union
I: int
F: float
λ thisIsPrivate(x: int) -> int
x + M + 1
λ ThisIsPublic(x, y: float) -> float
π * (x + y - X)
- flohofwoe 8y agoThat's just your personal opinion, obviously. You need some sort of separators for putting several statements on the same line anyway, and requiring them everywhere is better than Javascript's or python's optional semicolons. Also I guess zig's main audience is C programmers, and semicolons are not one of the problems that need fixing in a "better C" language.