This page is no longer maintained — Please continue to the home page at www.scala-lang.org

specialization and unification

No replies
Matthew Pocock 3
Joined: 2010-07-30,
User offline. Last seen 42 years 45 weeks ago.
I'm still trying to understand why some things don't specialize for me in my fork of scalala. Here is part of the -Ylog:specialized output.
[log explicitouter] [specSym] checking for rerouting: sparse.this.SparseVectorCol.canBuildSparseVectorFrom[Double, Double] with          sym.tpe: [V, NV](evidence$25: scalala.scalar.Scalar[NV])scalala.generic.collection.CanBuildTensorFrom[scalala.tensor.sparse.SparseVectorCol[V],scalala.tensor.domain.IndexDomain,Int,NV,scalala.tensor.sparse.SparseVectorCol[NV]],          tree.tpe: (evidence$25: scalala.scalar.Scalar[Double])scalala.generic.collection.CanBuildTensorFrom[scalala.tensor.sparse.SparseVectorCol[Double],scalala.tensor.domain.IndexDomain,Int,Double,scalala.tensor.sparse.SparseVectorCol[Double]]          env: Map(type NV -> Double)         name: canBuildSparseVectorFrom$mDc$sp [log explicitouter] Conformance for anyref - polytype with result type: (evidence$25: scalala.scalar.Scalar[Double])scalala.generic.collection.CanBuildTensorFrom[scalala.tensor.sparse.SparseVectorCol[V],scalala.tensor.domain.IndexDomain,Int,Double,scalala.tensor.sparse.SparseVectorCol[Double]] and (evidence$25: scalala.scalar.Scalar[Double])scalala.generic.collection.CanBuildTensorFrom[scalala.tensor.sparse.SparseVectorCol[Double],scalala.tensor.domain.IndexDomain,Int,Double,scalala.tensor.sparse.SparseVectorCol[Double]] Orig. sym.: method canBuildSparseVectorFrom[log explicitouter] Could not unify.
It's found a specialized form of canBuildSparseVectorFrom, but then fails to use it. It's says, "Could not unify" but I'm not sure what it was that it couldn't unify. By hand, it seems to me that the two CanBuildTensorFrom types do unify with V->Double. Here are the key types and signatures:
trait CanBuildTensorFrom[-From, -Domain, @specialized(Int, Long) K, @specialized(Int, Long, Float, Double) V, +To]
implicit def canBuildSparseVectorFrom[V, @specialized(Int, Long, Float, Double) NV: Scalar]   : CanBuildVectorFrom[SparseVectorCol[V], V, NV, SparseVectorCol[NV]]
type CanBuildVectorFrom[From <: Tensor1[Int, V1], V1, V, To <: Vector[V]] =  CanBuildTensorFrom[From, IndexDomain, Int, V, To]
I'm mystified as to why this doesn't unify and why the specialized form is rejected. Can anyone explain it to me? Thanks,
Matthew
--
Dr Matthew PocockVisitor, School of Computing Science, Newcastle Universitymailto: turingatemyhamster [at] gmail [dot] comgchat: turingatemyhamster [at] gmail [dot] com msn: matthew_pocock [at] yahoo [dot] co [dot] ukirc.freenode.net: drdozertel: (0191) 2566550 mob: +447535664143

Copyright © 2012 École Polytechnique Fédérale de Lausanne (EPFL), Lausanne, Switzerland