Why is the left-arrow thin but right arrow fat?

435 views
Skip to first unread message

Haoyi Li

unread,
Jul 2, 2012, 3:42:36 AM7/2/12
to scala-user
I've always wondered why

<- =>

are considered language "keywords", while

<= ->

are left up to the developer to overload. Purely aesthetically, it seems that the "special" arrows should be either both fat or both thin, while the user-definable ones should be the opposite. 

Is there a reason (historical or otherwise) that they picked one-fat and one-thin arrow to be special, and left the other arrows (again one fat and one thin) to be user-definable?

-Haoyi

Dave

unread,
Jul 2, 2012, 4:16:52 AM7/2/12
to scala-user
I think '<-' means only 'bind' while '=>' can be used as 'bind' in a
function literal, but also in pattern matchings//error handling or
self reference or by-name parameters.

'=>' is like '_' which can have multiple meanings/uses dependent on
its context.

Andrés Testi

unread,
Jan 2, 2014, 9:32:29 AM1/2/14
to scala...@googlegroups.com
'<-' also means pattern matching (in for comprehensions). I'm also wondered by the <-/=> inconsistency. 

Dennis Haupt

unread,
Jan 2, 2014, 9:33:33 AM1/2/14
to Andrés Testi, scala-user
too late to change it now *evil laughter*


2014/1/2 Andrés Testi <andres....@gmail.com>

--
You received this message because you are subscribed to the Google Groups "scala-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to scala-user+...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Dennis Haupt

unread,
Jan 2, 2014, 9:38:17 AM1/2/14
to Andrés Testi, scala-user
to give useful information:
<- is used for pattern matching
blah(a->b) is sugar for blah((a,b)) which is sugar for blah(Tuple2(a,b)) which is sugar for blah(Tuple2.apply(a,b))
blah(a => b) is creating a function

the only unused symbol is <=, because this one is "taken" by "lessThanOrEqual"
(i have no proof this was the intention)


2014/1/2 Dennis Haupt <d.ha...@gmail.com>
Reply all
Reply to author
Forward
0 new messages