synt.expr.closure
¤
Closure
¤
Bases: Expression
, IntoCode
Python's closure expression, aka lambda
.
Notes
In Python, a lambda expression can have a single expression as its body. Synt won't try to create a separate function containing multiple statements, you must do it yourself.
References
Source code in synt/expr/closure.py
__init__
¤
|
Initialize a closure expression.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
args |
list[Identifier]
|
Argument list. |
required |
body |
IntoExpression
|
expr.Expression body. |
required |
Source code in synt/expr/closure.py
ClosureBuilder
¤
Builder for Closure
.
Examples:
Source code in synt/expr/closure.py
__init__
¤
|
Initialize a closure.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
*args |
Identifier
|
Initial closure argument list. |
()
|
join
¤
|
Append new arguments to the closure.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
*args |
Identifier
|
New closure arguments. |
()
|
ret
¤
|
Set the expression to be returned by the closure.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
e |
IntoExpression
|
expr.Expression to be returned. |
required |