Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic

Re: (tye)Re: Logical expression style

by VSarkiss (Monsignor)
on Jul 12, 2002 at 17:58 UTC ( #181356=note: print w/replies, xml ) Need Help??

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")

Log In?

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://181356]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others wandering the Monastery: (6)
As of 2022-08-08 19:52 GMT
Find Nodes?
    Voting Booth?

    No recent polls found