Clone this wiki locally
Scala-Virtualized is a branch of the Scala compiler and standard library that contains a few additions to provide even better support for embedded DSLs (we call that language virtualization).
The key features are as follows:
overloadable control structures (while-loops, if-then-else, pattern matching), variables, object creation, etc. Scala has always translated for-comprehensions into method calls, so that the programmer can change the meaning of a for-comprehension by implementing these methods in a certain way. We generalize this to all control flow operators, as well as to the representation of mutable variables and object creation (for now limited to struct-like datatypes, but providing precise types for field-selection).
extension methods: define new infix-methods on existing types (pimp-my-library with less boilerplate)
Material in This Wiki
- Virtualized Scala Reference: In-depth description of each feature
- Source Location and Source Context: Linking DSL expressions back to the original source
- Tutorial: Introduction
- Tutorial: Generating SQL
- Tutorial: Compiling embedded Scala code at runtime
Tutorial source code is available here.
Releases of Scala-Virtualized are binary compatible with the corresponding regular Scala release.
Here is a sample
build.sbt file for use with the Simple Build Tool (SBT):
name := "My Scala-Virtualized Project" version := "1.0" scalaVersion := "2.10.0" scalaOrganization := "org.scala-lang.virtualized"
Scala-Virtualized is actively used in a couple of open source projects:
- OptiML: A DSL for machine learning developed at Stanford PPL
- Scala Integrated Query (SIQ): LINQ-style database interface in Scala
- Delite: Framework/Runtime for heterogeneous parallelism
- LMS-Core: Compiler framework for embedded DSLs
Community support is available on the regular Scala mailing lists. Posts should mention scala-virtualized in the subject line.
Using Scala-Virtualized for your project? Please let us know!