A short question in comp.lang.tcl got me several useful answers that I'm now putting here for later reference:
The (generalized) question:
The specific context:
The answers:
my own: (provided in the posting as an example of what I meant)
proc noop args {return 1}
if { <cond1> && [noop John Doe ]
&& <cond2> && [noop Fu Bar ]
...
} { do something ... }by Roy Terry:
proc ? {cond args} { return [uplevel expr $cond]}
if { [? {<cond1>} John Doe ]
&& [? {<cond2>} Fu Bar ]
...
} ...A previous simpler version returned the first argument directly (without uplevel&expr), to which RS added: Note that this is another use for the K combinator...
if { cond1 (* John Doe *)
&& cond2 (* Fu Bar *)
...
} ...by Ulrich Schoebel
set cond [list]
lappend cond $cond1 ;# John Doe
lappend cond $cond2 ;# Fu Bar
...
if {[expr [join $cond &&]]} { ... by Michael Barth (per email):
if { <cond1> && (1 || " John Doe ")
&& <cond2> && (1 || " Fu Bar ")
...
} { do something ... }This is conceptually similar to my own solution, but better insofar, as no special procedure is needed and the "comment-ness" is immediately visible.
Andreas Leitgeb: Thanks for all the hints!