Skip to content

Instantly share code, notes, and snippets.

View razie's full-sized avatar

Razvan Cojocaru razie

View GitHub Profile
def f(x:Int)=1+2
/**
* minimal script interface
*
* TODO use JSR 264 or whatever the thing is and ditch custom code...
*
* @author razvanc
*/
trait RazScript {
import RazScript._
trait InterpolationContext {
implicit def str2interp(s: String) = new InterpolatedString(s)
class InterpolatedString(val s: String) {
def / = interpolate(s)
def identifier = s.substring(2, s.length - 1)
}
object Tokenizer {
def unapply(s: String): Option[Iterator[String]] = {
class Interpreter(val settings: Settings, out: PrintWriter) {
repl =>
// 1. Request is private. I need: dependencies (usedNames?) newly defined values (boundNames?)
// the resulting value and the error message(s) if any
case class PublicRequest (usedNames : List[String], valueNames:List[String], extractionValue:Option[Any])
// 2. Can't get the last request
wif (_ == 1) {
inc + log ($0)
} welse {
inc + inc + log ($0)
}
par {
seq {
inc
log($0)
}
seq {
inc
log($0)
}
}
v(c) (c ? P | c ! Q)
@razie
razie / scala-profiles.markdown
Created September 24, 2010 15:35
Scala abuses

Scala is a wonderful language, with a specification of a size comparable with that of Java. Overall, the specification is simpler than C++. Why then do some feel intimidated by its expressiveness?

Scala can generate complex constructs. There are some features of the language that, if not used properly, can negatively influence one's perception of its simplicity and generate a waste of many an hour of a frustrated developer.

Newcomers from simply typed, object-oriented, structured languages do not have a full grasp of all the features of scala and their effects or benefits, and they may be very surprised if others on their team use them.

One thing to have when starting or using scala is a readily available bible. I recommend "Programming in Scala", the .pdf version, an easily searcheable language reference.

The scala style guide is very good. Here we will describe the advanced features of the language, which are aimed at library-developers and should not b

@razie
razie / scalaskilset.markdown
Created December 9, 2010 17:42
Scala skill levels
@razie
razie / CmdOptions.scala
Created January 21, 2011 22:44
scala dsl sample: realistic -options
package razie.learn.dsl.fs1
case class Flag (val c:Char)
object r extends Flag('r')
object f extends Flag('f')
class Cmd_rm (var flags:List[Flag]) {
def - (f:Flag) = { flags = f :: flags; this }
def apply (s:String) = "removing " + s
}