lang_2023/tests/default_constructors.lang

45 lines
950 B
Text
Raw Normal View History

2023-03-31 12:10:12 +03:00
namespace Employee {
decl gen_employee : Unit -> Employee
2023-05-11 23:14:36 +03:00
def gen_employee = {
var x = $@Complex & 11.3 & 15.87 // construct on heap
2023-03-31 12:10:12 +03:00
return
$Employee // construct on stack
2023-03-31 12:10:12 +03:00
& name = "John"
& role =
($Manager
2023-04-25 21:21:36 +03:00
& "John"
2023-03-31 12:10:12 +03:00
& productivity =
2023-04-25 21:21:36 +03:00
($Productivity::High
2023-03-31 12:10:12 +03:00
& duration = 10.3
2023-04-25 21:21:36 +03:00
& sleep_on_work = ($Productivity::SleepOnWork::No))
2023-03-31 12:10:12 +03:00
& salary = 123)
2023-03-31 12:10:12 +03:00
}
}
/*
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)
*/