Skip to content

Instantly share code, notes, and snippets.

@razie
Created January 21, 2011 22:44
Show Gist options
  • Save razie/790585 to your computer and use it in GitHub Desktop.
Save razie/790585 to your computer and use it in GitHub Desktop.
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
}
trait Commands {
def rm = new Cmd_rm (Nil)
}
object CmdOptions extends Application with Commands {
rm -r -f apply "gigi.file"
(((rm) - r) - f) apply "gigi.file"
rm.-(r).-(f).apply("gigi.file")
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment