Now what would you expect this to print out?
RW
fbsd06 at mlists.homeunix.com
Tue May 20 14:44:04 UTC 2008
On Tue, 20 May 2008 11:33:50 +0200
Jonathan McKeown <jonathan at hst.org.za> wrote:
> On Tuesday 20 May 2008 02:41, RW wrote:
> > On Mon, 19 May 2008 21:46:03 +1200
> >
> > Jonathan Chen <jonc at chen.org.nz> wrote:
> > > find /usr/src \( -name Makefile -or -name '*.mk' \) -print
> >
> > Why does that make a difference, when print always evaluates to
> > true?
> >
> > x AND true = x
> >
> > so
> >
> > (a OR b) AND true = a OR b
> > a OR (b AND true) = a OR b
>
> It makes a difference (as in programming) because -print is used for
> its side-effect rather than its value, and the binding order
> influences when the side-effect happens.
That's still a bit counter-intuitive because in normal programming
languages the binding order modifies side-effects via the evaluation
order. And in both cases the evaluation order would be expected to be
left-to-right, with -print running last.
I guess what you are saying is that the side-effect of print is based-on
a Boolean "running-value". And without the brackets, the first test has
been evaluated, but not yet ORed into that "running-value", by the time
that print runs.
More information about the freebsd-questions
mailing list