From 284ab3324c52c2dba8f55d3d3ed804a75795372f Mon Sep 17 00:00:00 2001 From: pca006132 Date: Mon, 12 Apr 2021 19:58:29 +0800 Subject: [PATCH] modified according to comments --- README.md | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index dec672e..1570f31 100644 --- a/README.md +++ b/README.md @@ -18,6 +18,25 @@ kernel. Only types supported in the kernel can be referenced. +Examples: +```python +FOO = 0 + +@kernel +def correct() -> int: + global FOO + return FOO + 1 + +@kernel +def fail_without_global() -> int: + return FOO + 2 + +@kernel +def fail_write() -> None: + FOO += 1 + +``` + ## Class and Functions * Instance variables must be annotated: (Issue #1) ```python @@ -31,7 +50,7 @@ Only types supported in the kernel can be referenced. * Three types of instance variables: (Issue #5) * Host only variables: Do not add type annotation for it in the class. * Kernel Invariants: Immutable in the kernel and in the host while the kernel - is executing. Type: `KernelInvariant(T)`. The types must be immutable. + is executing. Type: `KernelInvariant[T]`. The types must be immutable. (use tuple instead of list in the host, but the type annotation should still be list?) * Normal Variables: The host can only assign to them in the `__init__` @@ -47,6 +66,8 @@ Only types supported in the kernel can be referenced. * Function pointers are supported, and lambda expression is not supported currently. (maybe support lambda after implementing type inference?) + Its type is denoted by the typing library, e.g. `Call[[int32, int32], int32]`. + ## Built-in Types * Primitive types include: * `bool`