From 9a3bfbad022d283706774e0889d6596e0689c08c Mon Sep 17 00:00:00 2001 From: Jeremy Wall Date: Mon, 9 Dec 2019 18:41:01 -0600 Subject: [PATCH] DOCS: Document the syntax for casting. --- docsite/site/content/reference/expressions.md | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/docsite/site/content/reference/expressions.md b/docsite/site/content/reference/expressions.md index b8751fe..409c19b 100644 --- a/docsite/site/content/reference/expressions.md +++ b/docsite/site/content/reference/expressions.md @@ -213,6 +213,16 @@ The type must be a string literal matching one of: ("foo" is "str") == true; ``` +Casting +------- + +UCG can cast primitive types to other primitive types. UCG is very conservative in +the casts it allows however and a failed cast is a compile error. The allowed casts +are `int(expr)`, `float(expr)`, `str(expr)`, and `bool(expr)`. Casts are not function +calls even though they look like them and as a result you can not define your own +functions with the same name as a cast. If the expressions do not resolve to a primitive +type that is castable to the desired type then a compile error will occur. + Copy Expressions ----------------