Squid v0.4.0 Release Notes

Release Date: 2019-07-24 // over 2 years ago
  • ๐Ÿš€ 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:

    ๐Ÿ‘€ Making syntax of variable function insertion more regular (see #54).

    โšก๏ธ Updating the docs to make cross-quotation references the preferred approach (see ed9f7d6).

Previous changes from 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] and ir"..." to respectively Code[T,C], CodeType[T] and code"..." โ€“ and similarly for other types and functions; introduction of OpenCode[T] and ClosedCode[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 to squid.lib.MutVar to avoid confusion with the new Base#Variable datatype.