lang_2023/tests/default_constructors.lang

44 lines
950 B
Text

namespace Employee {
decl gen_employee : Unit -> Employee
def gen_employee = {
var x = $@Complex & 11.3 & 15.87 // construct on heap
return
$Employee // construct on stack
& name = "John"
& role =
($Manager
& "John"
& productivity =
($Productivity::High
& duration = 10.3
& sleep_on_work = ($Productivity::SleepOnWork::No))
& salary = 123)
}
}
/*
class Employee =
& name : String
& role :
( | Director
& importance : Float
& share : Float
| Manager
& productivity :
( Productivity
| .Low
| .Average
| .High
& duration : Float
& sleep_on_work :
(SleepOnWork
| ..Yes
| ..No
))
& salary : Int
| Programmer
& skills : Float
& current_task : Optional Task
& salary : Int)
*/