Another pedantic Rust syntax pet peeve of mine:
use std::f64::consts;
impl HasArea for Circle {
fn get_area(&self) -> f64 {
self.radius * consts::PI * 2f64
}
}
I have an LL(k) grammar under development which checks so far with k=2 (i.e. one token lookahead) using the SLK parser generator, which enables me to use the reuse the .
member access operator also the scoping operator which IMHO is much more attracted but it does require that scoping and type names begin with an uppercase letter while instance and function names may not:
impl HasArea for Circle {
fn get_area(&self) -> f64 {
self.radius * Std.F64.Consts.PI * 2f64
}
}
Or:
use Std.F64.Consts;
impl HasArea for Circle {
fn get_area(&self) -> f64 {
self.radius * Consts.PI * 2f64
}
}
To my eye, it is redundant to dictate a distinction between access and scoping because the uppercase restriction in my grammar makes it obvious and also naming is more consistent. And distinguishing access to methods which don't input &self
is also obvious because type names begin with an uppercase letter and instance names do not. For me, language design is an artform and I want it to be elegant like a painting. Einstein also wanted his theories to be elegant, which is one reason he resisted quantum theory (and I think he will be proven correct).
The grammar I am developing employs Python/Haskell-like indenting instead of the more noisy, inconsistent readability (and vertical screen space wasteful) brace-delimited blocks, which also enable eliding the semicolons without incurring ambiguities.