From 79c7c2dd451156ebe3047a95bd5c866c3c58599f Mon Sep 17 00:00:00 2001 From: whitequark Date: Fri, 29 Apr 2016 12:09:14 +0000 Subject: [PATCH] doc: explain RPC return type annotations. Fixes #410. --- doc/manual/compiler.rst | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/doc/manual/compiler.rst b/doc/manual/compiler.rst index ad47fc3ee..81d8e3774 100644 --- a/doc/manual/compiler.rst +++ b/doc/manual/compiler.rst @@ -16,6 +16,34 @@ A number of Python features can be used inside a kernel for compilation and exec For a demonstration of some of these features, see the ``mandelbrot.py`` example. +Remote procedure calls +---------------------- + +Kernel code can call host functions without any additional ceremony. However, such functions are assumed to return `None`, and if a value other than `None` is returned, an exception is raised. To call a host function returning a value other than `None` its return type must be annotated using the standard Python syntax, e.g.: :: + + def return_four() -> TInt32: + return 4 + +The Python types correspond to ARTIQ type annotations as follows: + ++-------------+-------------------------+ +| Python | ARTIQ | ++=============+=========================+ +| NoneType | TNone | ++-------------+-------------------------+ +| bool | TBool | ++-------------+-------------------------+ +| int | TInt32, TInt64 | ++-------------+-------------------------+ +| float | TFloat | ++-------------+-------------------------+ +| str | TStr | ++-------------+-------------------------+ +| list of T | TList(T) | ++-------------+-------------------------+ +| range | TRange32, TRange64 | ++-------------+-------------------------+ + Additional optimizations ------------------------