ta0kira / zeolite

Zeolite is a statically-typed, general-purpose programming language.
Apache License 2.0
18 stars 0 forks source link

Add syntax for grouping statements for use with `scoped`. #27

Closed ta0kira closed 4 years ago

ta0kira commented 4 years ago

For example, something like this should be possible:

scoped {
  RawFileReader reader <- RawFileReader$open("file")
} cleanup {
  reader.freeResource()
} in {
  // some procedure using reader
}

At the moment, the closest alternative (semantically) is something like:

scoped {
  RawFileReader reader <- RawFileReader$open("file")
  // some procedure using reader
} cleanup {
  reader.freeResource()
} in scoped {
  // some procedure using reader
} in ~ empty

scoped was originally meant to act like {} scoping in C++, while also encouraging the user to separate scoped variables from the sub-procedure that uses them. We therefore don't want to generally allow {} scoping outside of scoped/cleanup.