3 ms·
> shed the tears of joy with how many symbols are used It... doesn't, though? Rust's syntax is pretty aggressively conventional, from my perspective. Looking
by tene 6y ago
> shed the tears of joy with how many symbols are used
It... doesn't, though? Rust's syntax is pretty aggressively conventional, from my perspective.
Looking at the punctuation symbol tokens, almost all of this is common to many languages: https://doc.rust-lang.org/reference/tokens.html#punctuation https://doc.rust-lang.org/reference/tokens.html#punctuation
The symbols that come to mind when I think about my experiences writing Rust are:
- <> for generics
- ? for early-return errors
- Macro invocations require a !
- Match statements use =>
- ' for lifetimes
- #[attrname] for attributes
- |x,y| for closures
- -> for return types
All the other common symbols I use feel too conventional to seem worth mentioning, like {} for lexical scopes, = for assignment, +-/ for math, foo() for function calls, foo.bar() for method calls, (a,b,c) for tuples, [1,2,3,4] for arrays, <>!== for comparison, "quoted" 'strings', / comments */ and //comments, etc.
I agree that might_fail()? and 'lifetime are different, but everything else I listed seems lightweight, and very common for languages to use symbols for. <> is common for generics from C++, but alternatives I've seen are [] and (), also symbols. Matches use =>, and C's switch cases use :, also a symbol.
Using macro_rules to define macros is pretty symbol-heavy, I guess?
Usually when I see complaints like this, they come down to complaints about the lifetime syntax, and not liking the use of ' for anything besides quoted strings.
If you disagree, could you explain how I've missed or misunderstood your point? Can you show some examples of normal Rust code that uses way more symbols than normal Perl?