From 7d98ef87d53768895efe1f9eca0c388be5476746 Mon Sep 17 00:00:00 2001 From: John Date: Fri, 26 Jul 2024 06:22:29 -0500 Subject: [PATCH] sample-code: proper type annotations on HEX_LUT, add FIXME for min and max --- sample-code/hex.cl | 2 +- sample-code/math.cl | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/sample-code/hex.cl b/sample-code/hex.cl index ebf0d28..64bddf3 100644 --- a/sample-code/hex.cl +++ b/sample-code/hex.cl @@ -2,7 +2,7 @@ mod math; // TODO: casting and/or conversion -const HEX_LUT: Array = [ +const HEX_LUT: [char; 16] = [ '0', '1', '2', '3', // '4', '5', '6', '7', // '8', '9', 'a', 'b', // diff --git a/sample-code/math.cl b/sample-code/math.cl index 7ba02d2..0a750a9 100644 --- a/sample-code/math.cl +++ b/sample-code/math.cl @@ -1,9 +1,15 @@ //! Useful math functions +// FIXME: +// These two functions shouldn't actually be polymorphic, but +// the AST interpreter doesn't know about type annotations +// or operator overloading. +#[generic("T")] pub fn max(a: T, b: T) -> T { (if a < b { b } else { a }) } +#[generic("T")] pub fn min(a: T, b: T) -> T { (if a > b { b } else { a }) }