Created
January 21, 2011 22:44
-
-
Save razie/790585 to your computer and use it in GitHub Desktop.
scala dsl sample: realistic -options
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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