This utility removes subforms which do nothing. Useless subforms may result from poorly written user-level code. They are also created if user-level code discards the value produced by a form such as scan, which generates both side-effects and a value. Finally, certain rewriting rules within the compiler must preserve subforms that may or may not be useful, because they do not know if they will generate side-effects or whether a form is or is not pure.
Removal of useless forms must follow type inference, which wraps a return form around the code if it returns a value to the caller.
Specifically, a subform is considered useful if it either side-effects the world (including setting final return values if this function returns any). Recursively, subforms are useful if they produce values used by useful subforms. Forms that side-effect the world include
All other subforms are useless. Furthermore, forms following an unconditional call to (icp-error) are useless, because they can never execute.
All useless forms are removed from the code. An error is triggered if the entire function is found to do nothing.
Ownership, Maintenance and Disclaimers
Last modified