aboutsummaryrefslogtreecommitdiff
path: root/bootstrap/test.cff
diff options
context:
space:
mode:
authorlemon <lsof@mailbox.org>2022-08-06 22:12:59 +0200
committerlemon <lsof@mailbox.org>2022-08-06 22:30:45 +0200
commita522d6c89067aa2b560ccab3eed9b4e00e89b100 (patch)
tree59d0ce39a20864d780781607e45c1f9572eae831 /bootstrap/test.cff
parent09baa8201a5422b8fa3d9d96bbfe7ceb3e12736b (diff)
slices
Diffstat (limited to 'bootstrap/test.cff')
-rw-r--r--bootstrap/test.cff11
1 files changed, 11 insertions, 0 deletions
diff --git a/bootstrap/test.cff b/bootstrap/test.cff
index 95ee7bf..e466bba 100644
--- a/bootstrap/test.cff
+++ b/bootstrap/test.cff
@@ -48,6 +48,11 @@ struct Vec2f {
}
}
+fn spanz(cstr *const u8) [#]const u8 {
+ extern fn strlen(s *const u8) usize;
+ return cstr[0::strlen(cstr)];
+}
+
extern fn main (argc int, argv **u8) int {
let colors [3]Color = { :Red, :Green, :Blue } ;
@@ -63,6 +68,12 @@ extern fn main (argc int, argv **u8) int {
each(i, x, is,
printf("%d\n", x);
)
+ let slice [#]int = is[3::5];
+
+ printf("sl %d\n", slice[0]);
+ slice = slice[1::4];
+ printf("sl %d\n", slice[0]);
+ slice.#len;
printf("sizeof(is) = %zu\n", sizeof(is));
printf("sizeof *void = %zu\n", sizeof *void);