3 ms·
not only that, 2 of the 3 sets of paren were not needed, the order of operations already would have gotten it right
by curi 19y ago
not only that, 2 of the 3 sets of paren were not needed, the order of operations already would have gotten it right
- anamax 19y agoNot necessarily. Infix precedence/associativity is so "natural" that different languages have have different precedences or associativity for the same operator. If one works in multiple languages, the only safe thing is to ignore precedence and associativity and parethesize everything.
- curi 19y agocool. which of the basic arithmetic operators have difference precedence in which languages? what i am used to is * and / first, then + and -.
- anamax 19y agoapl for one. And then there's associativity. It doesn't much matter for * and +, but it matters a lot for / and -, and if you think that * and / have the same precedence, it matters for . And, you're continuing to ignore the fact that there are far more infix operators. Even if infix worked for +-/, that doesn't tell us that it works when there's .,->,<, &, ?, %, $, #, @, ~, ^, |, \, =, and so on (such as digraphs). No language that uses infix has resisted the temptation to extend it past the point where it causes more problems than it solves.
- curi 19y agoI think you may have mixed people up, I've been arguing against infix, so I'm not continuing to ignore that ;p I believe I posted a comment pointing out that lots of people aren't completely sure, offhand, if && or == has higher precedence. And even in this branch of the thread, when I said he could have omitted some of the parentheses, I didn't mean to say infix is powerful because it can use less parenthesis. it gets rid of them with a dirty trick that doesn't scale. What I was pointing out is that people don't actually know the infix precedence rules by heart (like they try to say they do. they say it's so natural...). so they end up putting parenthesis frequently just cause they aren't sure.