From 31c688b4c8089e4091e6cf95853550bf34ff15a8 Mon Sep 17 00:00:00 2001 From: pca006132 Date: Thu, 17 Dec 2020 09:48:58 +0800 Subject: [PATCH] disallow default parameter --- README.md | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/README.md b/README.md index 3a8feb9..f093706 100644 --- a/README.md +++ b/README.md @@ -51,17 +51,9 @@ class Foo(EnvExperiment): * No implicit coercion, require implicit cast. Integers are int32 by default, floating point numbers are double by default. * RPCs: optional parameter type signature, require return type signature. -* Value of the optional parameter would be created by the caller, and - independent between different invokations. The following code would always - output 2 `1`, instead of `1` and `2` for actual Python: - ```py - def test(a = [1]): - print(a) - a[0] += 1 - - test() - test() - ``` +* Function default parameters are not allowed, as changes to the default value + would not be kept across kernel calls, and that is a potential source of + confusion. ## Generics We use [type variable](https://docs.python.org/3/library/typing.html#typing.TypeVar) for denoting generics.