http://qs321.pair.com?node_id=181356


in reply to (tye)Re: Logical expression style
in thread Logical expression style

I think I do about the same thing, but isn't this slightly misleading? Since the or binds least tightly, if I were to show precedence, I'd do:

if ( defined $settings && ! $settings->{hidecode} and $codtype{ $node->{nodetype} } or $node->{code} || containscode( $node->{doctext} ) ) { # ...
In other words, I'd line up the horns of the or at the outermost level, and then the and, etc.

Or did I miss the point you were trying to make? (No pun intended ;-)

This is similar to how I indent SQL where clauses:

where EXISTS (select 1 from users where users.user_id = acct.user_id or (acct_id is null and user_id = 0)

Replies are listed 'Best First'.
(tye)Re2: Logical expression style
by tye (Sage) on Jul 12, 2002 at 18:17 UTC

    Yes, it was a contrived example and I did it wrong. ):

            - tye (but my friends call me "Tye")