hylo
hylo copied to clipboard
Compile addressors efficiently
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>
.