mirror of
https://codeberg.org/ProgramSnail/lang_2023.git
synced 2025-12-05 22:48:42 +00:00
constructors on heap, consuming match, move modifier in reference expression, .bring. keyword to return from block, some fixes
This commit is contained in:
parent
2556efcaba
commit
8a84cfff70
12 changed files with 128 additions and 34 deletions
|
|
@ -1,8 +1,9 @@
|
|||
namespace Employee {
|
||||
decl gen_employee : Unit -> Employee
|
||||
def gen_employee = {
|
||||
var x = $@Complex & 11.3 & 15.87 // construct on heap
|
||||
return
|
||||
$Employee
|
||||
$Employee // construct on stack
|
||||
& name = "John"
|
||||
& role =
|
||||
($Manager
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
decl fruit_cost : Fruit -> Int
|
||||
def fruit_cost : fruit = {
|
||||
return (match fruit with
|
||||
var fruit_copy = fruit
|
||||
return (match <- fruit_copy with // consuming match
|
||||
| $Banana -> 11
|
||||
| $Apple | $Orange -> 7)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -142,5 +142,5 @@ def func : s = {
|
|||
|
||||
exec main {
|
||||
for i in (,0 ,1 ,2 ,3) do func: "abacaba"
|
||||
; print: ({ return read: })
|
||||
; print: ({ bring read: })
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue