Procedures with inputs VS global variables

Procedure parameters enable you to reuse the procedure in different contexts without having to open it up and change its code.

For example, look in

for my merge sort implementation.

The best procedures work entirely through their parameters, with no side effects.

There are places where global variables are needed, for example

  • inter-Event communication
  • a debugging trail for slow moving humans using the Do It facility

Global variables cost the coder mentally, because they don't tell you who or what has been updating them.

I recommend reading the Abelson and Sussman book in