One big limitation of functions is that they cannot be universal in value. For instance.
def foo[A](bar: A): Unit
This cannot be expressed as a function value.
val foo: A => Unit
for which type A parameter resolution is required. Other differences: methods carry the natural concept of this as an encompassing class; they can be interrupted by return . They can have several parameter lists, and most importantly, a list of implicit parameters. They have default names and arguments. (I'm trying to imagine what a function with named and standard arguments will look like, maybe it can be developed)
It would probably not be possible to simply have function values, but def seems to be the best match for the OO Scala aspects.
source share