On 25 Apr 2002, at 9:56, Bill -Sx- Jones wrote:
> On 4/25/02 7:42 AM, "Bernie Cosell" <[EMAIL PROTECTED]> wrote:
> >
> > In the construct: f(a) + g(b) the compiler has the prerogative to
> > evaulate whichever it pleased first [and so you couldn't count on
> > function 'f' being called before function 'g']. I would have guessed
> > that Perl's expression evaluator would have inherited that "tradition"
> > from C.
>
> I guess I would hope that right-to-left operations would take precedence
> here.
>
> Or should it matter, depending upon correctly written code, what gets
> 'called' first?
I can only speak for C compilers [whether Perl continued those semantics
I don't know]. The [C] compiler was allowed, in essence, to 'reverse' the
order it evaluated the operands to a *particular* operator.
As for right-to-left operations, I'm not sure what you mean here, since
there's only one operator [and it happens to be a left-to-right
associative one] In:
f(a) + g(b)
correctly written code *CANNOT* depend on which is called first... by
definition [again, in C and probably in Perl], since the order is
indeterminate, the code can't be "correct" if it depends on the order of
the evaluation of the operands.
You run into similar incorrect coding practices with the use of ++ and --
[although generally all but the most neophyte C programmers learn not to
run into those]: if you do something bizarre, like:
++a + a++
what values actually get used as operands for the '+' and what the final
resulting value of the variable are pretty bad mojo to sort out.
The big difference here [C] versus Perl is that there are [or at least
used to be] dozens, scores, of different C compilers for different
processors, OSs, etc, and these kinds of indeterminacies were REAL traps
for the unwary, but there's pretty much one Perl expression evaluator,
cross-platform, and so you can go a LONG way counting on something you're
not supposed to be and not get bitten [perhaps until version 5.n+1 comes
out, the semantics change a bit [and perhaps in only some
circumstances.ugh! :o)].
/Bernie\
--
Bernie Cosell Fantasy Farm Fibers
mailto:[EMAIL PROTECTED] Pearisburg, VA
--> Too many people, too few sheep <--