Files
corelang/examples/constant_expressions.core
2026-03-20 08:35:18 +01:00

40 lines
1001 B
Core

// We can bind module to a name
M :: #import "Multimedia.core"
// You can bind struct to a name
MU :: M.MU
// We can bind a lambda to a name
Start :: M.StartMultimedia
Update :: M.UpdateMultimedia
// 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)
Start(x = 1280, y = 720)
Update()
return 0