cast¶
basedpython adds a cast infix soft keyword for inline type casts:
transpiles to:
syntax¶
cast is an infix soft keyword: <value> cast <type>. the left operand is
the value being cast, the right operand is the target type
scope¶
cast is a basedpython-only keyword: a .py file using it as an infix produces
a parse error. when the next token cannot start an expression (e.g. cast = 5
or cast(int, a)), cast is parsed as an ordinary identifier so existing
python code that uses cast as a name or function call continues to parse
polyfill¶
<value> cast <type> lowers to cast(<type>, <value>) with an injected
from typing import cast import. this is a runtime construct — typing.cast
returns its second argument unchanged at runtime