On Thu, Aug 9, 2012 at 12:57 PM, Adriaan Moors <
adriaa...@epfl.ch> wrote:
> i tried to understand your goal but am afraid it's not immediately clear to
> me
I didn't make it immediately apparent, but my goal is no different
than yours: having support for
pattern matching with Scala-virtualized, lightweight modular staging (LMS)
&C. The program in the testsuite shows that you can reify a
simple pattern match, like this:
def test = 7 match { case 5 => "foo" case _ => "bar" }
but of course one needs to support also more complex examples - and
that currently fails. Say, calling
staged functions and pattern matching on the their result:
def power(b: Rep[Int], x: Int): Rep[Int] = if (x == 0) 1 else b *
power(b, x - 1)
def test2 = power(3, 2) match { case 9 => "Bingo!" case _ => "What???" }
As you see, in that code I'm pattern-matching over a value of type
Rep[Int], instead of just Int. But whenever I try this, the virtualized pattern
matcher currently gives a type error. In other words, it is not
possible to virtualize pattern matches where the scrutinee is an
already staged representation - that is, most interesting examples;
see for instance figure 17 in the LMS paper from Tiark Rompf&Martin
Odersky, GPCE '10.
Tiark's testcase in virtualized-lms-core shows that instead Scala
2.10.0-M1-virtualized did not give a type error, but failed to
virtualize the code.
Thanks for your time on this.
Paolo