disallow default parameter

This commit is contained in:
pca006132 2020-12-17 09:48:58 +08:00 committed by pca006132
parent c6b9f620d2
commit 31c688b4c8
1 changed files with 3 additions and 11 deletions

View File

@ -51,17 +51,9 @@ class Foo(EnvExperiment):
* No implicit coercion, require implicit cast. Integers are int32 by default, * No implicit coercion, require implicit cast. Integers are int32 by default,
floating point numbers are double by default. floating point numbers are double by default.
* RPCs: optional parameter type signature, require return type signature. * RPCs: optional parameter type signature, require return type signature.
* Value of the optional parameter would be created by the caller, and * Function default parameters are not allowed, as changes to the default value
independent between different invokations. The following code would always would not be kept across kernel calls, and that is a potential source of
output 2 `1`, instead of `1` and `2` for actual Python: confusion.
```py
def test(a = [1]):
print(a)
a[0] += 1
test()
test()
```
## Generics ## Generics
We use [type variable](https://docs.python.org/3/library/typing.html#typing.TypeVar) for denoting generics. We use [type variable](https://docs.python.org/3/library/typing.html#typing.TypeVar) for denoting generics.