How to find unused lists/procedures in scheme?

139 views Asked by At

I am cleaning up some (Chicken) scheme code and I want to identify all lists/procedures not used in a given program. Is there a specific option to pass either to the Chicken compiler or to csi -s I can use to do so without listing out each define and grep-ing for the identifiers in the *.scm scripts?

3

There are 3 answers

2
ramrunner On

you could use the repl function from eval unit and pass to that an evaluator function that keeps track of the symbol if it is a list or a lambda before calling eval on the argument.

0
sjamaan On

If you put your code in a module, it will show a warning about unused, unexported identifiers when compiling it (you might need to use csc -v to show them).

1
ceving On

It is not possible to decide which top-level entries will be used, because it is possible to dynamically craft expressions:

(eval (list (string->symbol "+") 1 2)) →  3

It would be necessary to evaluate all possible permutations of your program.