Created
January 16, 2014 21:53
-
-
Save jimbaker/8464160 to your computer and use it in GitHub Desktop.
Possible constructor DSL for Clamp
This file contains hidden or 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
| from java.lang import Integer, String | |
| from clamp import Constructor | |
| BarBase = clamp_base("bar") | |
| class Foo(BarBase, Callable): | |
| # need to specify a no-args constructor with @Constructor() if | |
| # other constructors are specified, given that __init__ needs | |
| # specific args to unpack, possibly with defaults | |
| @Constructor(String, Integer) | |
| @Constructor(String) | |
| def __init__(self, name, repeat=42): | |
| self.name = name | |
| self.repeat = repeat | |
| class Baz(BarBase, Callable): | |
| @Constructor() | |
| # [X] implies that it is any array of such args | |
| @Constructor([String]) | |
| def __init__(self, args): | |
| self.args = args |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment