lama_byterun/stdlib/Ref.lama

19 lines
445 B
Text
Raw Normal View History

2020-02-20 12:43:52 +03:00
-- Emulation of first-class references.
-- (C) Dmitry Boulytchev, JetBrains Research, St. Petersburg State University, 2020
--
-- This unit provides an implementation for first-class references emulation.
-- Creates a new reference cell with contents x
public fun ref (x) {
[x]
}
2020-02-20 12:43:52 +03:00
-- Returns the contents of the cell x
public fun deref (x) {
x[0]
}
2020-02-20 12:43:52 +03:00
-- Assigns a new value y into the cell x
public infix ::= before := (x, y) {
x[0] := y
}