From 7995694f138ccef0113ac0494790eb0461f5d44e Mon Sep 17 00:00:00 2001 From: Kaz Kylheku Date: Tue, 21 Mar 2023 22:12:11 -0700 Subject: compiler: recognize ignore and use functions We want the ignore function to go away; but if variables are mentioned, to suppress unused warnings on them. * stdlib/compiler.tl (%functional-funs%): Remove nilf from list since we are handling it specially. (compiler comp-fun-form): Recognize (ignore ...) and (nilf ...) forms, transforming them into (progn .... nil). In the case of ignore, walk the arguments: if any look like variables, mark them used. Also, add the use function to the pattern which handles identity, since it is a synonym. --- stdlib/compiler.tl | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'stdlib') diff --git a/stdlib/compiler.tl b/stdlib/compiler.tl index 2ba6626b..0b271cfd 100644 --- a/stdlib/compiler.tl +++ b/stdlib/compiler.tl @@ -350,7 +350,7 @@ (defvarl %functional-funs% '(chain chand juxt andf orf notf iff iffi dup flipargs if or and - progn prog1 prog2 retf apf ipf callf mapf tf nilf umethod uslot)) + progn prog1 prog2 retf apf ipf callf mapf tf umethod uslot)) (defvarl %functional% (hash-list %functional-funs% :eq-based)) @@ -1390,7 +1390,14 @@ (set form (rlcp ^(,bin ,a ,b) form))) ((- @a) (set form (rlcp ^(neg ,a) form))) - ((@(or identity + * min max logior logand) @a) + ((@(or ignore nilf) . @args) + (if (eql sym 'ignore) + (each ((a args)) + (if (bindable a) + env.(lookup-var a t)))) + (return-from comp-fun-form me.(compile oreg env + ^(progn ,*args nil)))) + ((@(or identity use + * min max logior logand) @a) (return-from comp-fun-form me.(compile oreg env a))))) (when (plusp olev) -- cgit v1.2.3