hylo icon indicating copy to clipboard operation
hylo copied to clipboard

Compile addressors efficiently

Open kyouko-taiga opened this issue 1 year ago • 4 comments

Addressors are subscripts that project an existing value rather than a synthetic one. Such subscripts should be compiled as direct function calls and not require any continuation.

For example:

type Point {
  var x: Int
  var y: Int
  subscript(_ p: Int): Int {
    match p {
      0 { yield x }
      1 { yield y }
      _ { precondition_failure() }
    }
  }
}

In this example, Point.[] is an addressor. As such, it can be compiled to a function (Point) -> Pointer<Int>.

kyouko-taiga avatar May 01 '23 13:05 kyouko-taiga