epfldata / squid

Squid – type-safe metaprogramming and compilation framework for Scala
http://epfldata.github.io/squid/
Apache License 2.0
197 stars 14 forks source link

Cannot splice `Var` in quotation #6

Closed sachinbjohn closed 6 years ago

sachinbjohn commented 7 years ago
val v = __newVar[Int](unit(1))
ir"println($v)"
LPTK commented 7 years ago

Squid sees variables as members of squid.lib.Var, therefore you have to write ir"println($v.!)". Look at the examples I gave you.

PS: can you paste the errors you get with the offending code in the future?

amirsh commented 7 years ago

@LPTK I'm not sure the syntax you came up with is a good idea. It's true that this is the syntax for working with references in ML, but I don't think that using it as Scala code is a good idea. Ideally the main learning barrier of quasiquotes for a Scala user should only be quoting and splicing.

LPTK commented 7 years ago

@amirsh Feel free to contribute an enhancement to the quasiquote API. This is not a blocker.