Kernel objects specification as per discussion in #8

This commit is contained in:
pca006132 2021-06-08 12:03:49 +08:00
parent d06a044189
commit 3464dabeb9

View File

@ -49,10 +49,10 @@ def fail_write() -> None:
``` ```
* 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 only variables: Denoted with type `Kernel[T]`.
* 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: `KernelImmutable[T]`. The types must be immutable.
(use tuple instead of list in the host, but the type annotation should still In particular, the attribute cannot be modified during RPC calls.
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__`
function. Not accessible afterwards. function. Not accessible afterwards.
* Functions require full type signature, including type annotation to every * Functions require full type signature, including type annotation to every
@ -62,6 +62,9 @@ def fail_write() -> None:
return a + b return a + b
``` ```
* RPCs: optional parameter type signature, require return type signature. * RPCs: optional parameter type signature, require return type signature.
* Classes with constructor annotated with `kernel/portable` can be constructed
within kernel functions. RPC calls for those objects would pass the whole
object back to the host.
* Function default parameters must be immutable. * Function default parameters must be immutable.
* 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?)