Closed Coolnesss closed 6 years ago
Haven't yet decided if we should allow omitting the {}
(like C++), or allow omitting the ()
but require the {}
(like Rust, Swift).
Requiring {}
makes all if-statements have a consistent syntax, on the other hand some people are used to being allowed to omit them and may like it that way.
Not requiring {}
may introduce bugs, but they can be avoided with good compiler warnings (which means more work for compiler developers). As a compromise we could only allow omitting the {}
if the body is on the same line, which would avoid the problems pointed out in the above link.
"allow omitting ... if" sounds like an unnecessary level of syntax complexity. I think you should be consistent here.
"on the other hand some people are used to being allowed to omit them" isn't a real argument for me. You want to be different than any other language out there, why would you copy bad parts then?
"allow omitting ... if" sounds like an unnecessary level of syntax complexity.
Yeah, that's what I'm thinking too.
"on the other hand some people are used to being allowed to omit them" isn't a real argument for me.
One of Delta's design principles is to keep the language familiar to C and C++ programmers. Some of them might want to continue omitting braces for single-statement ifs, so I'm not sure if I want to force them to do otherwise, as that might make some of them feel negatively about the language. And you can always add a linter check if you want to enforce a braces-always style.
That being said, I agree that mandatory braces are better than optional braces if starting with a clean slate. I can't really find any arguments for optional braces other than the previous paragraph. Anyway, I'm pretty sure this decision won't make or break a language, so it probably doesn't matter very much which one we pick. My gut feeling says optional braces, but my logical reasoning is pretty much fifty-fifty between the two. No idea which of them to trust in this case, at least not yet.
Can't do