Skip to content

Improve frame (specialize none type) and/or defer and/or code sections #191

@dumblob

Description

@dumblob

It seems, the behavior of frame{} is not so consistent as I'd expect it to be :)
This is currently not possible:

routine r() => int {
  if (rand() > 0.5) return 5 else error('<=0.5')
  return 3  # just for compiler
}
routine wrap() {
  # the goal is to silently return if an exception occured in r()
  x = frame(none) { r() }
  if (x == none) return;
  # do some useful stuff with x
  io.writeln(x)
}

Also variants with defer{} inside of the frame{} are not currently feasible as the behavior of frame is sometimes kind of unexpected:

x = frame { defer { 5 } 3 }
io.writeln('first', x)
x = frame { defer { 5; 9 } 3 }
io.writeln('second', x)
x = frame { defer { 5 } return 3 }
io.writeln('third', x)
x = frame { defer { 5; 9 } return 3 }
io.writeln('fourth', x)
x = frame { defer { none } 3 }
io.writeln('fifth', x)
x = frame { defer { none } return 3 }
io.writeln('sixth', x)
x = frame { defer { return none } 3 }
io.writeln('seventh', x)
x = frame { defer { return none } return 3 }
io.writeln('eighth', x)

It should be the same for every code section block, not only frame{}.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions