Forums

And has same precedence as Or

General discussion about Cobra. Releases and general news will also be posted here.
Feel free to ask questions or just say "Hello".

Re: And has same precedence as Or

Postby torial » Fri Sep 03, 2010 7:48 am

helium wrote: or it should be a compile time error and should force you to use parenthesis.


I like this option.. if it is easy to implement, I think this should be the route we go. Sure it requires a few more characters, but it forces assumptions to be explicit .
torial
 
Posts: 229
Location: IA

Re: And has same precedence as Or

Postby Charles » Fri Sep 03, 2010 9:50 am

It's an interesting idea. I would like to know how it impacts existing code bases, but won't have time to look into it for awhile.
Charles
 
Posts: 2515
Location: Los Angeles, CA

Re: And has same precedence as Or

Postby gauthier » Tue Sep 07, 2010 5:20 pm

Hi there, it's a long thread here (and long time I've not sneaked into the forum),

I've not read every bits of the thread (I hope it's ok to give my feeling anyway):

On the argument that it should be explicitely bracketed to make precedence obvious, I would say that a warning would be welcome, it would follow the design logic of avoid dummy errors as soon as the compiler can point them.

Now it seems that it would piss the people arguing in favor of AND > OR to have cobra behave differently than most of the language (and hopefully nobody is arguing for VB behaviour ;)).

I wouldn't feel impacted by such a change because I tend to break and put complex boolean expression into local_variable_with_very_descriptive_name to make ultimate conditional statement easier to read, I would definitely use brackets even if a and b or c and d now sound obvious to me with nevdelap pointing the equivalent bracketed expression, though it would not be with two subsequent or or more alternations.
gauthier
 
Posts: 116

Re: And has same precedence as Or

Postby nevdelap » Wed Sep 08, 2010 8:51 pm

torial wrote:forces assumptions to be explicit

I'm always up for forcing assumptions to be explicit.

I don't mind the extra characters when they are mandated - so that there is no ambiguity between cases where they are there and where they aren't. (I'd give anyone a run for their money on length of names, so additional typing is never a worry for me when it makes things more clear.) :)
call me Nev.
nevdelap
 
Posts: 61
Location: Buenos Aires

Previous

Return to Discussion

Who is online

Users browsing this forum: No registered users and 62 guests