On Wed, Nov 23, 2011 at 3:05 PM, Kevin Wright <kev.lee.wri...@gmail.com>wrote:

>
> They're also core to the mechanism that allows collections to just do the
> Right Thing(tm).  For example:
>
> someBitSet map {_.toString}
>

Right, but you can achieve the same result without needing implicits. I'll
just show how Fantom does it but I'm sure the same applies to
Gosu/Ceylon/Kotlin:

    // a set of A instances, where A has a toUppercase method
    aSet := [ A("foo"), A("bar") ]
    l := aSet.map | v->Str | { v.toUppercase }
    echo(l)
    echo(l.typeof)

[FOO, BAR]
sys::Str[]

The signature of map() is exactly what you would expect: it takes a
function that takes an element of the collection and returns "something",
and the type of your expression is "list of something" (here we transformed
a list of A's into a list of strings).

It's really not rocket science, and the fact that you need implicits to
achieve this result is an implementation detail that's very specific to
Scala.

Sure, you can handwave it with "You don't need to understand the exact
details of the API", but the truth is... you really do. Not a week goes by
without me having to go check out a Javadoc or the signature of java.util
or Guava method. And saying that only library authors need to know about
implicits, CanBuildFrom and its triple generic signature is creating a rift
between the Scala developers (people who know and people who don't), which
is worrisome.

-- 
Cédric

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

Reply via email to