4 ms·
Why is there so much sugar?! Can't a keyword just be a keyword?
by p4lindromica 15y ago
Why is there so much sugar?! Can't a keyword just be a keyword?
- exim 15y agoMy overall impression regarding Rust is that it has an extremely noisy syntax (and I'm a pro {} guy).
- exDM69 15y ago> Why is there so much sugar?! Can't a keyword just be a keyword? Statements based on keywords are syntactic sugar. What I'm seeing here in Rust is the complete opposite, building an iteration statement from language built-ins. It does include some sugar in it (and "for" is a special keyword) but the semantics of the construct is based on lambda calculus and other lower level constructs in Rust. In general, it's better that a language has as little special syntax that cannot be constructed from elementary blocks. The gaps are then bridged by adding a little sugar coating to make programming convenient (for humans) but keeping the core language clear and concise (for interpreters and compilers). For example, in C, you cannot define your own loop structures and you're stuck with for, do and while (C macros are so crappy that they don't count). Haskell, on the other hand, does not have any special iteration statements in the language core but there's a handful of iteration functions that are regular functions and you are free to define your own. Same thing with Scheme (and other Lisps).
- frewsxcv 15y agoThis is more like Splenda, not sugar