Releases: epfldata/squid
Squid v0.4.0
This pre-release adds a few features to Squid:
Cross-quotation references (see #48)
Finally, Squid supports direct cross-quotation references!
Previously, one had to use first-class Variable
symbols, as in:
val v = Variable[Int]
code"($v: Int) => ${ ... foo(code"$v + 1") ... }" // notice the reference to v across quotations
or using a variable function insertion:
code"(v: Int) => ${ (w: Variable[Int]) => ... foo(code"$w + 1") ... }(w)"
But now one can just write, in quasicode:
code{(v: Int) => ${ ... foo(code{v + 1}) ... }}
...and in quasiquotes (see fc54eac), we need to escape the $
insertions and the inner quotes because of a limitation in macro expansion order:
code"""(v: Int) => $${ ... foo(code"v + 1") ... }"""
Importantly, this feature preserves static scope safety, so it distinguishes itself from the similar capabilities present in BER MetaOCaml and Dotty, which are not scope-safe.
Automatic lifting of implicits (see b39538e)
Importing the IR.ImplicitLifting.liftImplicit
method allows implicit T
values to be lifted to code values when asking for a ClosedCode[T]
implicit.
For example, implicitly[ClosedCode[Ordering[(Int,Int)]]]
returns the equivalent of:
code"Ordering.Tuple2[Int, Int](Ordering.Int, Ordering.Int)"
This is super useful in applications where we'd like to rely on the standard implicits of a library, and still allows specializing and optimizing the implicits, by rewriting them after they have been lifted. The feature was used in our ECOOP 2019 paper.
See basic examples here.
Effectful reification (see #62)
A feature that is sometimes useful when one wants to imperatively register code inside some enclosing scope (like is done in LMS), as an alternative to purely-functional code composition, the approach favored by Squid.
Overridden methods are now unified (see #51)
A big usability improvement, one can now match, for example, a call of head
on Nil
with a call of head
on some List[T]
:
code"Nil.head" match { case code"($ls: List[Any]).head" => assert(ls == code"Nil") }
Previously, since the method symbols were not precisely the same (head
is overridden in Nil
), the match would fail.
We now use a union-find data structure to equate all methods that are overridden or override other methods, and transitively. This is sound, because in addition to checking method symbols, we always also check the type of the receiver in code pattern matching.
More minor changes include:
Squid v0.3.0
This pre-release of the Squid type-safe metaprogramming framework was focused on adding important features that were so far missing and consolidating existing ones, as well as aligning Squid's high-level interface with what was presented in our our POPL 2017 paper.
Important new features:
-
first-class variable: a more hygienic and convenient way of manipulating constructed and extracted bindings, a path-dependent-types-based alternative to the nominal system;
-
cross-stage persistence: the ability to have code fragments capture references values in the current stage, to be used during later runtime compilation;
-
better support for context-unsafe metaprogramming: i.e., better support for programming without having to deal with contexts (using
OpenCode[T]
only), in a way that does not compromise the soundness of the rest of the system; -
compile-time code execution: the ability to compose and execute code at compile time, useful for communicating configurations to Squid macros in a reliable and uniform way – currently only used in
StaticOptimizer
, but will be used by the quasiquotes and by Squid macros in the future; for examples, see the tests;
Other main changes and improvements:
-
Scala 2.12 support
-
renaming of
IR[T,C]
,IRType[T]
andir"..."
to respectivelyCode[T,C]
,CodeType[T]
andcode"..."
– and similarly for other types and functions; introduction ofOpenCode[T]
andClosedCode[T]
type synonyms; -
type extraction improvements using ranges, which finally fixes some frustrating match failures that were due to subtyping subtleties;
-
reimplementation of the scheduling algorithm of
SchedulingANF
, removing the problems of the old (broken) one; -
move to SBT 1.1;
-
addition of a
LoggingOptimizer
trait to facilitate dumping compile-time code optimization info; -
renaming of
squid.lib.Var
tosquid.lib.MutVar
to avoid confusion with the newBase#Variable
datatype.
Squid v0.2.1
Mostly minor fixes; better display unbound variables; and support for varargs in @embed
'ed classes, thanks to @fschueler.
Squid v0.2.0
First pre-release of the Squid type-safe metaprogramming framework.
To see the currently supported features, please refer to the README.md and doc.
Our focus has been on streamlining the high-level quasiquote-based interface, bringing it closer to a stable state. The lower-level interfaces (such as squid.lang.Base
) will likely change more in the future.