You might wish to pass _context implicitly, but this hits a wall. On
the one hand, implicit parameters must come after explicit parameters.
But, on the other hand, you need that wannabe-implicit context to
define path-dependent types of your explicit parameters, so it has to
come first in the parameter list.
Yes! Please! Want! Now!
Cheers,
Miles
--
Miles Sabin
tel: +44 7813 944 528
gtalk: mi...@milessabin.com
skype: milessabin
g+: http://www.milessabin.com
http://twitter.com/milessabin
http://www.chuusai.com/
-- Martin
--
Martin Odersky
Prof., EPFL and Chairman, Typesafe
PSED, 1015 Lausanne, Switzerland
Tel. EPFL: +41 21 693 6863
Tel. Typesafe: +41 21 691 4967
The difficulty has nothing to do with macros per se -- it's to do with
the cake pattern. The same problems will affect people using the
reflection API, or those who, perhaps after reading PiS, have adopted
this pattern in their own codebase. Surely we want to make it easier
for all of these people to keep their code well factored.
Dependent method types go a long way, but the overly-conservative
restriction on the direction of the dependencies still stands in the
way.
-jason
> This begs for a question. How do we fight bakery of doom here?
I've just checked in a slightly different approach:
https://github.com/retronym/macrocosm/commit/f0197ab2
The important bits:
implicit def Util(context: Context) = new Util[context.type](context)
class Util[C <: Context with Singleton](val context: C) {
import context._
def id(a: Tree): Tree = a
// more method here
}
-jason
-- Martin
Yes, that looks more like it. We can always refactor by creating
intermediate objects.
Cheers
-- Martin
Just as Adriaan suggested: loosen the check in Namers [1] to allow for:
def foo(a: b.x)(implicit b: B)
-jason
MethodType(a: b.x, MethodType(b: B, ...)
I think we'd introduce some serious scoping problems here!
-- Martin
I'm going to leave Adriaan to field that one while I swim back to shore :)
-jason
The important bits:
implicit def Util(context: Context) = new Util[context.type](context)
class Util[C <: Context with Singleton](val context: C) {
import context._
def id(a: Tree): Tree = a
// more method here
}