Constant expressions

This commit is contained in:
Krzosa Karol
2022-10-01 14:31:46 +02:00
parent df291c6eb5
commit 1473204860

View File

@@ -0,0 +1,38 @@
// We can bind module to a name
M :: #import "Multimedia.core"
// We can bind a struct to a name
Mu :: M.Mu
// We can bind a lambda to a name
Start :: M.StartMultimedia
// Other example of binding a lambda to a name
SomeOtherLambda :: () ;; pass
AliasOf :: SomeOtherLambda
// We can bind a simple type to name, this type is
// exactly the same as int, typechecker doesn't complain
NewInt :: int
// We can force it to complain using a '#strict' directive
// this makes a new type that requires casting, good for ids
// and stuff like that, normal int operations still work!
StrictInt :: #strict int
SomeStruct :: struct ;; a: int
StructAlias :: SomeStruct
main :: (): int
some_struct: SomeStruct = {a = 10}
struct_alias: StructAlias = some_struct
Assert(struct_alias.a == 10)
#Assert(SomeStruct == StructAlias)
#Assert(NewInt == int)
#Assert(StrictInt != int)
mu: Mu = Start(x = 1280, y = 720)
Assert(mu.x == 1280 && mu.y == 720)
return 0