6
// constants/symbols (atomic)
9
case class Sym[T](n: Int) extends Exp[T]
11
// operations (composite, defined in subtraits)
14
// additional members for managing encountered definitions
15
def findOrCreateDefinition[T](rhs: Def[T]): Sym[T]
16
implicit def toExp[T:Manifest](d: Def[T]): Exp[T] = findOrCreateDefinition(d)
19
trait BaseExp extends Base with Expressions {
22
def findOrCreateDefinition[T](rhs: Def[T]): Sym[T] = null // stub
25
trait NumericOps extends Base {
26
def plus[T](x: Rep[T], y: Rep[T]): Rep[T]
29
trait NumericOpsExp extends BaseExp {
30
case class Plus[T:Numeric](x: Rep[T], y: Rep[T])
33
def plus[T: Numeric](x: Rep[T], y: Rep[T]): Rep[T] = Plus[T](x,y)
35
// Possible solutions:
36
// def plus[T: Numeric: Manifest](x: Rep[T], y: Rep[T]): Rep[T] = Plus[T](x, y)
37
// def plus[T](x: Rep[T], y: Rep[T])(implicit num: Numeric[T], man: Manifest[T]): Rep[T] = Plus(x,y)