Skip to content

Mutable Let

type:fixed

This MR aims to fix LIGO's current purification issues by adding "mutable let bindings". The extension can be described by the following calculus:

e ::= c | x | e e | fun x -> e (* STLC *)
    | let mut m = e in e | m | m := e (* Mutable-let features *)
    | for i = e to e do e | ... (* Looping constructs *)

where m denotes a "mutable variable".

Semantically mutable variables behave like OCaml ref-types, with the exception that mutable variables cannot be captured in closures. For example, the following is invalid:

let mut m = 1 in 
fun () -> m := 2

This restriction can be relaxed later with the addition of an effect system.

Future work:

  • Removal of the purification pass (and additional passes e.g. self-ast-core, self-ast-sugar, etc)
  • Improvements on transpilation / support for mutable features in CameLIGO / ReasonLIGO

Changelog details:

Fix/improve LIGO's implementation of mutable features

Edited by Alistair O'Brien

Merge request reports

Loading