kuroko-lang / kuroko

Dialect of Python with explicit variable declaration and block scoping, with a lightweight and easy-to-embed bytecode compiler and interpreter.
https://kuroko-lang.github.io/
MIT License
431 stars 25 forks source link

Type annotations have no effect #14

Closed Teashrock closed 3 years ago

Teashrock commented 3 years ago

Screenshot_4 It shouldn't be like this, I suppose.

klange commented 3 years ago

Annotations are not specifically type hints; their values are arbitrary and not checked in any way by the runtime or compiler as their meaning is up to the user.

Ref Python:

Python 3.8.10 (default, Jun  2 2021, 10:49:15) 
[GCC 9.4.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> x: int = "A string!"
>>> __annotations__
{'x': <class 'int'>}
>>> def some_random_func(a_float_variable: str) -> None:
...     return int(a_float_variable)
... 
>>> some_random_func(3.1415)
3
>>> some_random_func.__annotations__
{'a_float_variable': <class 'str'>, 'return': None}

Python PEP on function annotations: https://www.python.org/dev/peps/pep-3107/

Teashrock commented 3 years ago

Thank you very much.