Latest syntax experiment: `given as`

Mark "Justin" Waks
1 min readJul 1, 2019

--

Today in Dotty News: churn on continues on how to put stuff into what I’ve traditionally called “implicit scope”. The current state of play is delegate for, which has been a bit controversial, so today Martin is trying out given as. That is, you would declare a typeclass instance this way:

given IntOrd as Ord[Int] { ... }

First-draft rewritten documentation can be found here.

Personal opinion: I think I like it. We’re been fairly settled on using given at the function-declaration use site for a good while now; this syntax parallels that, which should help learning. And I think it reads a bit more naturally than delegate.

If you have opinions (especially if you have opinions more informed by experiment than my own), I encourage you to chime in, either on the PR or the Scala Contributors forum…

--

--

Mark "Justin" Waks
Mark "Justin" Waks

Written by Mark "Justin" Waks

Lifelong programmer and software architect, specializing in online social tools and (nowadays) Scala. Architect of Querki (“leading the small data revolution”).

No responses yet