Well, Java has left-to-right evaluation, except when it doesn't

x + y * z is equivalent to x.+(y.*(z))  NOT (x.+(y)).*(z)

x :: someList is equivalent to someList.::(x)

You also have this little gem in the Java spec:

"The Java programming language also guarantees that every operand of an
operator (except the conditional operators &&, ||, and ? :) appears to be
fully evaluated before any part of the operation itself is performed."


and this one:

15.7.5 Evaluation Order for Other Expressions


The order of evaluation for some expressions is not completely covered by
these general rules, because these expressions may raise exceptional
conditions at times that must be specified. See, specifically, the detailed
explanations of evaluation order for the following kinds of expressions:

   - class instance creation expressions
   - array creation expressions
   - method invocation expressions
   - array access expressions
   - assignments involving array components

The rules for precedence and order of evaluation are rarely as simple as you
think :)




On 9 August 2010 15:21, Ben Schulz <[email protected]> wrote:

> On 9 Aug., 13:50, Kevin Wright <[email protected]> wrote:
> > There's no implicit conversion here
> > just a list, with a :: method, taking x as an argument
>
> I'm sorry, I thought you were trying to make a point about the general
> case and how operator overloading is simple and intuitive in the
> general case. And if x and someList are just expressions we know
> nothing about except that someList denotes a List[_], then x ::
> someList and someList.::(x) are most definitely not equivalent. That
> is because Scala has a left-to-right order of evaluation just like
> Java. Most surprising to me and definitely unintuitive is that this
> does not hold for implicit conversions.
> Granted implicit conversions really should not have side effects and
> if they do one should certainly not be relying on their order, but
> it's a violation of the principle of least astonishment nonetheless.
>
> With kind regards
> Ben
>
> --
> You received this message because you are subscribed to the Google Groups
> "The Java Posse" group.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to
> [email protected]<javaposse%[email protected]>
> .
> For more options, visit this group at
> http://groups.google.com/group/javaposse?hl=en.
>
>


-- 
Kevin Wright

mail/google talk: [email protected]
wave: [email protected]
skype: kev.lee.wright
twitter: @thecoda

-- 
You received this message because you are subscribed to the Google Groups "The 
Java Posse" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/javaposse?hl=en.

Reply via email to