From 1a3dc02a18a9050877288a5867e44d9c47a53542 Mon Sep 17 00:00:00 2001 From: Tom Harley Date: Sat, 11 Jan 2020 02:53:36 +0000 Subject: Added int width specifiers The width of an int can be specified at the site of its creation. For example, the following function returns an int of width 2 bits and value 1: [def two_bit_int [] (2 1)] Ints can still be written the old way; in these cases the compiler looks for a default int bit-width (specified with the -w flag). If a default has not been defined, the compiler throws an error. --- examples/nq/closures.sin | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'examples/nq/closures.sin') diff --git a/examples/nq/closures.sin b/examples/nq/closures.sin index 2e23daf..36d5427 100644 --- a/examples/nq/closures.sin +++ b/examples/nq/closures.sin @@ -16,10 +16,12 @@ [dec tail [xs]] [dec is_nil [xs]] +[dec inc [x]] + [def add_arg [c a] [closure_ [closure_.func c] [closure_.arity c] - [+ [closure_.arg_c c] 1] + [inc [closure_.arg_c c]] [append [closure_.args c] a]]] [def run_closure [h] -- cgit v1.2.1