lang_2023/tests/classes.lang
ProgramSnail 0d62ae0814 debug
2023-03-31 12:10:12 +03:00

69 lines
1.3 KiB
Text

// ?? value - parametric classes ??
// struct fields/etc. accessible from everywere
// class fields/etc. accessible only from namespace of class or class instance (from "methods")
// points at the beginning of constructor name - amount of needed constructor prefixes ?
// ?? how to make class compositons ??
struct Fruit =
| Apple
| Orange
| Banana
struct Optional 'A =
| Some & 'A
| None
struct (Result : #Move) 'A 'B =
| & 'A
| Error & 'B
// struct (Complex : #Value) =
// & Float(0.0)
// & Float(0.0)
//
// struct Task =
// & name("Task") : String
// & duration(0.0) : Float
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)
class Bag =
&
( | Apple
| Orange
| Banana)
& bag_type :
( | Small
| Medium
& weight_kg : Int
& weight_g : Int
& weight_g : Int
| Big)
& other_things : Array Something