THIS GIST WAS MOVED TO TERMSTANDARD/COLORS
REPOSITORY.
PLEASE ASK YOUR QUESTIONS OR ADD ANY SUGGESTIONS AS A REPOSITORY ISSUES OR PULL REQUESTS INSTEAD!
scala> :paste | |
// Entering paste mode (ctrl-D to finish) | |
import scala.language.dynamics | |
import scala.language.experimental.macros | |
import scala.reflect.macros.whitebox | |
object implicitly extends Dynamic { | |
def apply[T](implicit t: T): T {} = t |
// Quasiquoted excerpt | |
def cdef = q""" | |
class $ClassName[..$classTypeParams](..$primaryParams) extends ..$classParents { | |
..$primaryAccessors | |
def get = this | |
def isEmpty = ${quasi.isEmpty} | |
def copy(..$primaryWithDefaults) = $ObjectName(..$primaryNames) |
scala> import syntax.typeable._ | |
import syntax.typeable._ | |
scala> val wat: Any = List(1, 2, 3, 4) | |
wat: Any = List(1, 2, 3, 4) | |
scala> wat.cast[List[Int]].map(_.sum) | |
res0: Option[Int] = Some(10) | |
scala> val wat2: Any = "foo" |
// full implementation at https://github.com/ghik/selftyped | |
trait Base extends SelfTyped { | |
def same[T: Self]: T | |
def twice[T: Self]: T | |
} | |
trait SimpleSame extends Base { | |
// we can always safely return 'this' where self-type is expected |
# Scaladoc Developer Guide | |
## Introduction | |
Scaladoc is the tool that enables developers to automatically generate documentation for their Scala (and Java) projects. It is Scala's equivalent of the widely-used Javadoc tool. This means that Javadoc (and even doxygen) users will be familiar with Scaladoc from day 1: for them, it is most beneficial to check out the Scaladoc/Javadoc comparison tables and if necessary, skim through this document to understand specific features. | |
The rest of this tutorial is aimed at developers new to Scaladoc and other similar tools. It assumes a basic understanding of the Scala language, which is necessary to follow the examples given throughout the tutorial. For the user perspective on the Scaladoc-generated documentation, such as finding a class, understanding the page layout, navigating through diagrams, please refer to the Scaladoc User Guide. | |
The tutorial will start by a short motivation and then will explain the main concept in Scaladoc: the doc comment. | |
### Why document? |
THIS GIST WAS MOVED TO TERMSTANDARD/COLORS
REPOSITORY.
PLEASE ASK YOUR QUESTIONS OR ADD ANY SUGGESTIONS AS A REPOSITORY ISSUES OR PULL REQUESTS INSTEAD!
Welcome to Scala version 2.10.0 (Java HotSpot(TM) 64-Bit Server VM, Java 1.7.0_05). | |
Type in expressions to have them evaluated. | |
Type :help for more information. | |
scala> def foo = { println("foo"); "foo" } | |
foo: String | |
scala> def bar = { println("bar"); "bar" } | |
bar: String |
package s | |
object Test { | |
// Observe that x.companion is statically typed such that foo is callable | |
def f1() = { | |
val x = new Foo | |
println(x) // Foo instance | |
println(x.companion) // Foo companion | |
println(x.companion.foo) // I'm foo! |
Hello scala, my old friend | |
I've come to take you home again | |
Because a feature slowly creeping | |
left me plagued with doubts and weeping | |
and the version that was tagged in the repo | |
just has to go | |
it lacks the signs of soundness | |
On sleepless nights I hacked alone | |
applying ant and other tools of stone |
#! /bin/bash | |
set -e | |
SCALA_DEV=~/code/scala | |
HASH=`git --git-dir $SCALA_DEV/.git rev-list "$1" | head -n1` | |
DESC=`git --git-dir $SCALA_DEV/.git describe $HASH` | |
shift | |
DIR=~/usr/scala-$DESC | |
SCALA=$DIR/pack/bin/scala |