|
@@ -50,13 +50,13 @@ Its semantics are defined in terms of the following interfaces:
|
|
|
```
|
|
```
|
|
|
interface IndexWith(SubscriptType:! type) {
|
|
interface IndexWith(SubscriptType:! type) {
|
|
|
let ElementType:! type;
|
|
let ElementType:! type;
|
|
|
- fn At[me: Self](subscript: SubscriptType) -> ElementType;
|
|
|
|
|
- fn Addr[addr me: Self*](subscript: SubscriptType) -> ElementType*;
|
|
|
|
|
|
|
+ fn At[self: Self](subscript: SubscriptType) -> ElementType;
|
|
|
|
|
+ fn Addr[addr self: Self*](subscript: SubscriptType) -> ElementType*;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
interface IndirectIndexWith(SubscriptType:! type) {
|
|
interface IndirectIndexWith(SubscriptType:! type) {
|
|
|
impl as IndexWith(SubscriptType);
|
|
impl as IndexWith(SubscriptType);
|
|
|
- fn Addr[me: Self](subscript: SubscriptType) -> ElementType*;
|
|
|
|
|
|
|
+ fn Addr[self: Self](subscript: SubscriptType) -> ElementType*;
|
|
|
}
|
|
}
|
|
|
```
|
|
```
|
|
|
|
|
|
|
@@ -78,11 +78,11 @@ final external impl forall
|
|
|
[SubscriptType:! type, T:! IndirectIndexWith(SubscriptType)]
|
|
[SubscriptType:! type, T:! IndirectIndexWith(SubscriptType)]
|
|
|
T as IndexWith(SubscriptType) {
|
|
T as IndexWith(SubscriptType) {
|
|
|
let ElementType:! type = T.(IndirectIndexWith(SubscriptType)).ElementType;
|
|
let ElementType:! type = T.(IndirectIndexWith(SubscriptType)).ElementType;
|
|
|
- fn At[me: Self](subscript: SubscriptType) -> ElementType {
|
|
|
|
|
- return *(me.(IndirectIndexWith(SubscriptType).Addr)(index));
|
|
|
|
|
|
|
+ fn At[self: Self](subscript: SubscriptType) -> ElementType {
|
|
|
|
|
+ return *(self.(IndirectIndexWith(SubscriptType).Addr)(index));
|
|
|
}
|
|
}
|
|
|
- fn Addr[addr me: Self*](subscript: SubscriptType) -> ElementType* {
|
|
|
|
|
- return me->(IndirectIndexWith(SubscriptType).Addr)(index);
|
|
|
|
|
|
|
+ fn Addr[addr self: Self*](subscript: SubscriptType) -> ElementType* {
|
|
|
|
|
+ return self->(IndirectIndexWith(SubscriptType).Addr)(index);
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
```
|
|
```
|
|
@@ -98,8 +98,8 @@ An array type could implement subscripting like so:
|
|
|
class Array(template T:! type) {
|
|
class Array(template T:! type) {
|
|
|
external impl as IndexWith(like i64) {
|
|
external impl as IndexWith(like i64) {
|
|
|
let ElementType:! type = T;
|
|
let ElementType:! type = T;
|
|
|
- fn At[me: Self](subscript: i64) -> T;
|
|
|
|
|
- fn Addr[addr me: Self*](subscript: i64) -> T*;
|
|
|
|
|
|
|
+ fn At[self: Self](subscript: i64) -> T;
|
|
|
|
|
+ fn Addr[addr self: Self*](subscript: i64) -> T*;
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
```
|
|
```
|
|
@@ -110,7 +110,7 @@ And a type such as `std::span` could look like this:
|
|
|
class Span(T:! type) {
|
|
class Span(T:! type) {
|
|
|
external impl as IndirectIndexWith(like i64) {
|
|
external impl as IndirectIndexWith(like i64) {
|
|
|
let ElementType:! type = T;
|
|
let ElementType:! type = T;
|
|
|
- fn Addr[me: Self](subscript: i64) -> T*;
|
|
|
|
|
|
|
+ fn Addr[self: Self](subscript: i64) -> T*;
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
```
|
|
```
|