Dynamic typing example
This commit is contained in:
16
examples/dynamic_typing.core
Normal file
16
examples/dynamic_typing.core
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
|
||||||
|
storage: [32]S64
|
||||||
|
len : S64
|
||||||
|
|
||||||
|
"+" :: (a: Any, b: Any): Any
|
||||||
|
result: Any = storage[len++]
|
||||||
|
if a.type == S64 && b.type == S64
|
||||||
|
*(result.data->*S64) = *(a.data->*S64) + *(b.data->*S64)
|
||||||
|
return result
|
||||||
|
|
||||||
|
main :: (): int
|
||||||
|
a: Any = 10
|
||||||
|
b: Any = 20
|
||||||
|
c := a + b
|
||||||
|
Assert(c.type == S64 && *(c.data->*S64) == 30)
|
||||||
|
return 0
|
||||||
Reference in New Issue
Block a user