top | item 42778202

(no title)

crowcountry | 1 year ago

Scala has implicit contextual parameters: https://docs.scala-lang.org/tour/implicit-parameters.html.

discuss

order

agumonkey|1 year ago

I've always been curious about how this feature ends up in day to day operations and long term projects. You're happy with it ?

kloop|1 year ago

As a veteran of a large scala project (which was re-written in go, so I'm not unbiased), no. I was generally not happy.

This was scala 2, so implicit resolution lookup was a big chunk of the problem. There's nothing at the call site that tells you what is happening. But even when it wasn't hidden in a companion object somewhere, it was still difficult because every import change had to be scrutinized as it could cause large changes in behavior (this caused a non-zero number of production issues).

They work well for anything you would use environment variables for, but a chunk of the ecosystem likes to use them for handlers (the signature being a Functor generally), which was painful

xmodem|1 year ago

Not OP, but I briefly seconded to a team that used Scala at a big tech co and I was often frustrated by this feature specifically. They had a lot of code that consumed implicit parameters that I was trying to call from contexts they were not available.

Then again I guess it's better than a production outage because the thread-local you didn't know was a requirement wasn't available.

segfaltnh|1 year ago

Scala has everything, and therefore nothing.