Ok. As predicted this thread has grown to N^2 or ackerman(N,N) or
something -- syntax, jeez! -- but I think the rough idea is now clear.
It seems like we wind up with two camps:
- Those who want to at least *accommodate* the expression-y style
(who favour option 3). This would be Dave, Patrick, Roy and Rob.
- Those who do not wish to accommodate expression-y style (who favour
option 4 and/or 1). This would be Peter, Igor, Sebastian and
Jeffrey (though he'd also be ok with 3).
Split poll! However, I note that camp #1 has done more of the work so
far, and I have done the majority, so I am going to play tie-breaker
(which I not-so-secretly assumed I'd wind up doing anyway). I initially
thought I'd go with #1 or #4, but have reconsidered:
- The type checking procedure for 3 has more precedent in other
languages, 4 has very little and I'd be Making Stuff Up to get it
right. I've a stated and very real goal of trying to stick to
precedent when I can. It improves the odds of other tools, proofs,
and program-transformers working correctly when applied to Rust.
- With {}-exprs we wind up pretty much unable to desugar, so we need
most of the machinery to support 3 anyway. This makes 3 actually
appear to be less work for me than 4; the only one that's less work
still is 1.
- I'm a pluralist anyway, and prefer to accommodate larger numbers of
styles rather than restrict them. We *do* advertise support for
writing in pure-functional style. Those people are well represented
in group #1 above, and they have a pretty clear aesthetic
preference. It seems a bit deceptive to say "yes, we support your
stylistic preferences" and then dodge and say "actually only if you
write in nutty gnu-C style". Nobody actually *likes* writing
expressions in that style.
So I'm going to go with 3 for now. Thanks for the feedback. If it turns
out to be a usability disaster in practice for people who prefer
imperative style, of course, I'm happy to revisit this. The imperative
users carry more weight collectively; I'm just not convinced any of them
will *notice* that we support expression style. They have to write it
intentionally, and (by assumption) it's not a style they're going to write.
Since this is the "less work" approach -- since we're assuming {}-exprs
persist -- we can always punt stuff back out of the expression grammar
again, pushing them back to statements, without having to overhaul the
whole compiler. Just changing the relevant AST node and ... devising
some novel 4-like algorithm for the typechecker.
NB: I'm completely willing to add ternary in any case. Now that I take
an honest look at the language landscape I can see I was leaving it out
until now due to my own bigotry, not the absence of any consensus among
languages. Seems most languages held on to it.
-Graydon
_______________________________________________
Rust-dev mailing list
[email protected]
https://mail.mozilla.org/listinfo/rust-dev