Updated specification #8
23
README.md
23
README.md
|
@ -18,6 +18,25 @@ kernel.
|
||||||
|
|
||||||
Only types supported in the kernel can be referenced.
|
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
|
## Class and Functions
|
||||||
* Instance variables must be annotated: (Issue #1)
|
* Instance variables must be annotated: (Issue #1)
|
||||||
```python
|
```python
|
||||||
|
@ -31,7 +50,7 @@ Only types supported in the kernel can be referenced.
|
||||||
* Three types of instance variables: (Issue #5)
|
* Three types of instance variables: (Issue #5)
|
||||||
* Host only variables: Do not add type annotation for it in the class.
|
* 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
|
* 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
|
(use tuple instead of list in the host, but the type annotation should still
|
||||||
be list?)
|
be list?)
|
||||||
* Normal Variables: The host can only assign to them in the `__init__`
|
* 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
|
* Function pointers are supported, and lambda expression is not supported
|
||||||
currently. (maybe support lambda after implementing type inference?)
|
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
|
## Built-in Types
|
||||||
* Primitive types include:
|
* Primitive types include:
|
||||||
* `bool`
|
* `bool`
|
||||||
|
|
Loading…
Reference in New Issue