Skip to content

Instantly share code, notes, and snippets.

View .project
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>scala</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.pde.ManifestBuilder</name>
<arguments>
View gist:1525720
@echo off
set CLASSPATH="C:\Projects\Kepler\build\locker\classes\compiler;C:\Projects\Kepler\build\locker\classes\library;C:\Projects\Kepler\build\locker\classes\partest"
cd /D "%PROJECTS%\Kepler\test"
java >con ^
-Xmx1024M >con ^
-Xms64M >con ^
-Dscala.home="C:\Projects\Kepler" >con ^
-Dpartest.javacmd="java" >con ^
-Dpartest.java_options="-Xmx1024M -Xms64M" >con ^
-Dpartest.scalac_options="-deprecation" >con ^
View gist:1525721
package scala.tools
package partest
import nsc.io.{ File, Path, Directory }
import util.{ PathResolver }
import nsc.Properties.{ propOrElse, propOrNone, propOrEmpty }
object PartestDefaults {
import nsc.Properties._
private def wrapAccessControl[T](body: => Option[T]): Option[T] =
@xeno-by
xeno-by / gist:1548942
Created Jan 2, 2012
First prototype of Scala quasiquotes
View gist:1548942
/** This demo shows:
* Syntax for quasiquotations
* String interpolation as a quasiquote
* Code quoting as a quasiquote
* Pattern matching against code quotes
* Some capabilities of brand new Scala reflection API (typechecking, compiling and running ASTs)
*/
>scala -Xquasiquotes -Yquasiquote-debug
Welcome to Scala version 2.10.0.dev-1473-ga6c67da (Java HotSpot(TM) 64-Bit Server VM, Java 1.6.0_25).
View gist:1551797
Certain types of quasiquotes can have dynamic number of bound varables (example is shown here:
https://gist.github.com/1548942, a code pattern with a single splice gets transformed into
a pattern with two bound variables), so just requiring a quasiquote provider to expose unapply isn't enough.
Having unapplySeq will work, but won't help us with allocating slots for the case of
pattern matching used to declare variables: val c"$x + $y" = c"2 + 2".
Also, when generating a pattern, quasiquote provider might need to access the guard as well
(see https://gist.github.com/1548942 for an example). This doesn't directly fit into the model of
macro-driven quasiquote expansion. We either give the q/q provider access to
the entire CaseDef (including the body) or hinder it by disallowing to customize guards.
View gist:1831018
object Test extends App {
def foo(bar: Any) = bar
val code = foo{
object lazyLib {
def delay[A](value: => A): Susp[A] = new SuspImpl[A](value)
implicit def force[A](s: Susp[A]): A = s()
@xeno-by
xeno-by / gist:2375580
Created Apr 13, 2012
.project for scalamacros/kepler
View gist:2375580
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>kepler</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.pde.ManifestBuilder</name>
<arguments>
@xeno-by
xeno-by / gist:2375582
Created Apr 13, 2012
.classpath for scalamacros/kepler
View gist:2375582
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" output="build/quick/classes/library" path="src/library"/>
<classpathentry kind="src" output="build/quick/classes/compiler" path="src/compiler"/>
<classpathentry kind="lib" path="lib/ant/ant-contrib.jar"/>
<classpathentry kind="lib" path="lib/ant/ant-dotnet-1.0.jar"/>
<classpathentry kind="lib" path="lib/ant/ant.jar"/>
<classpathentry kind="lib" path="lib/ant/maven-ant-tasks-2.1.1.jar"/>
<classpathentry kind="lib" path="lib/ant/vizant.jar"/>
<classpathentry kind="lib" path="lib/fjbg.jar"/>
@xeno-by
xeno-by / gist:2391081
Created Apr 15, 2012
Manifests in Scala 2.10.0 M3
View gist:2391081
To be implemented
View gist:2428930
Welcome to Scala version 2.10.0-20120418-145922-016bc3db52 (Java HotSpot(TM) 64-Bit Server VM, Java
1.6.0_25).
Type in expressions to have them evaluated.
Type :help for more information.
scala> Array[Unit]((), ())
typechecking macro expansion materializeClassTag[Unit](`package`.this.mirror) at source-<console>,li
ne-8,offset=101
ClassTag.Unit
Select(Ident(newTermName("ClassTag")), newTermName("Unit"))