Unseparated arguments & colon keyword arguments
The BuildDSL allows passing arguments to function calls without separation by commas.
Keyword arguments may be specified using colons (:
) instead of equal signs (=
).
Example 1
print 'Hello, World!' 42 * 1 + 10 file: sys.stdout
print('Hello, World!', 42 * 1 + 10, file=sys.stdout)
Example 2
task "hello_world" do: {
print "Hello, World!"
}
def _closure_1(self, *arguments, **kwarguments):
print('Hello, World!')
task('hello_world', do=_closure_1)
Example 3
list(map { print('Hello,', self) } ['John', 'World'])
def _closure_1(self, *arguments, **kwarguments):
print('Hello,', self)
list(map, _closure_1['John', 'World'])
Danger
Note how this actually passes all arguments to list()
and it tries to index an element on the closure.
The outer-most statement has the priority to receive the arguments, and subscripting takes precedence over
the subscript being treated as a separate argument.
list(map({ print('Hello,', self) }, ['John', 'World']))
def _closure_1(self, *arguments, **kwarguments):
print('Hello,', self)
list(map(_closure_1, ['John', 'World']))