Skip to content

Instantly share code, notes, and snippets.

View xeno-by's full-sized avatar

Eugene Burmako xeno-by

View GitHub Profile
@xeno-by
xeno-by / .project
Created December 27, 2011 13:29
.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>
@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 ^
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 January 2, 2012 01:39
First prototype of Scala quasiquotes
/** 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).
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.
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 April 13, 2012 10:10
.project for scalamacros/kepler
<?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 April 13, 2012 10:11
.classpath for scalamacros/kepler
<?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 April 15, 2012 08:41
Manifests in Scala 2.10.0 M3
To be implemented
@xeno-by
xeno-by / gist:2428930
Created April 20, 2012 14:04
Fun with units
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"))