This page is no longer maintained — Please continue to the home page at www.scala-lang.org

SLS 6.12.3

1 reply
Tony Morris
Joined: 2008-12-19,
User offline. Last seen 30 weeks 4 days ago.

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Is the precedence of infix operators specified in SLS 6.12.3 a lie?

scala> implicit def x(s: String) = new { def <<(t: String) = s + t }
x: (String)java.lang.Object{def <<(String): java.lang.String}

scala> implicit def y(s: String) = new { def |||(t: String) = t + s }
y: (String)java.lang.Object{def |||(String): java.lang.String}

scala> ("abc" << ("def" ||| "ghi")) == ("abc" << "def" ||| "ghi") //
should be true!
res22: Boolean = false

Should be true^^^

- --
Tony Morris
http://tmorris.net/

S, K and I ought to be enough for anybody.

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFJeRbAmnpgrYe6r60RAjBwAJ4h2e6t1lqmlhl9bs/58qPmtzdPfACePboX
ivY3g8+2NA/Q2wVBjMm8Gu4=
=jOuc
-----END PGP SIGNATURE-----

Tony Morris
Joined: 2008-12-19,
User offline. Last seen 30 weeks 4 days ago.
Re: SLS 6.12.3

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Woops! Just read that they are in increasing order of precedence, sorry.

Tony Morris wrote:
> Is the precedence of infix operators specified in SLS 6.12.3 a lie?
>
>
>
> scala> implicit def x(s: String) = new { def <<(t: String) = s + t
> } x: (String)java.lang.Object{def <<(String): java.lang.String}
>
> scala> implicit def y(s: String) = new { def |||(t: String) = t + s
> } y: (String)java.lang.Object{def |||(String): java.lang.String}
>
> scala> ("abc" << ("def" ||| "ghi")) == ("abc" << "def" ||| "ghi")
> // should be true! res22: Boolean = false
>
> Should be true^^^
>

- --
Tony Morris
http://tmorris.net/

S, K and I ought to be enough for anybody.

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFJeRc0mnpgrYe6r60RArPgAKCRZsoEsnuf59zcITs1bE6pO7g8owCeK3+h
b6Iz7pbRYBZaGAEUI9DytFg=
=BoUr
-----END PGP SIGNATURE-----

Copyright © 2012 École Polytechnique Fédérale de Lausanne (EPFL), Lausanne, Switzerland