I have been an avid Rust user for a few months now and on the whole I am loving the language. However I am beginning to find that as I move onto more complicated projects the syntax becomes rather verbose and unreadable. Particularly I find that error handling can introduce unneccesary complexity into my algorithms.
The try!
macro is clearer raw match
expressions, but it is still to verbose (in my opinion) and makes Rust a very dense language to read.
I'm not suggesting we discard all semicolons, braces, parentheses and understandability. I'm sure many people have suggested that before and met harsh opposition and coming from the C-family of languages I'm not sure I like it either.
I belive a try
keyword, that has the same function as try!()
but doesn't need the parentheses would make a lot of code clearer to understand.
Take this code example, taken from my SPIR-V to GLSL converter.
if try!(self.get_reference(op.result)) != "param" {
let ty = try!(self.get_type(variable.ty));
try!(write!(out, "{}{};", self.indent.begin_line(), try!(self.declare_variable(ty, try!(self.get_reference(op.result))))))
}
That verbose monstrosity would become significantly cleaner imo:
if try self.get_reference(op.result) != "param" {
let ty = try self.get_type(variable.ty);
try write!(out, "{}{};", self.indent.begin_line(), try self.declare_variable(ty, try self.get_reference(op.result)))
}
In particular, it reduces the six closing parentheses ))))))
down to just three )))
.
My question is, how many Rustaceans would like this change? I know that many people want Rust to stay really explicit (after all it is a systems programming language not CoffeeScript), however perhaps there is room for some 'streamlining' of the syntax.
It would be great if you could fill out this 2-second poll to let me know what the general consensus is.
Alternatively, I though about supporting the general case and allowing macros to be invoked without delimiters like ()
or {}
, but I'm not sure it that is actually possible to implement at the moment.