From 09baa8201a5422b8fa3d9d96bbfe7ceb3e12736b Mon Sep 17 00:00:00 2001 From: lemon Date: Sat, 6 Aug 2022 18:10:56 +0200 Subject: .#len operator --- bootstrap/test.cff | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'bootstrap/test.cff') diff --git a/bootstrap/test.cff b/bootstrap/test.cff index be6cb95..95ee7bf 100644 --- a/bootstrap/test.cff +++ b/bootstrap/test.cff @@ -10,9 +10,8 @@ enum Color { Red, Green, Blue } -defmacro arraylength(ary) [ (sizeof(ary)/sizeof(ary[0])) ] defmacro each(i, x, arr, ...body) [ - for let i = 0; i < arraylength(arr); ++i { + for let i = 0; i < arr.#len; ++i { let x = arr[i]; { body } } @@ -60,7 +59,7 @@ extern fn main (argc int, argv **u8) int { printf("mag = %g\n", (&x)->mag()); let is []int = { [4] = 1, 2, [1 - 1] = 3 }; - isort(is, arraylength(is)); + isort(is, is.#len); each(i, x, is, printf("%d\n", x); ) -- cgit v1.2.3