[plt-scheme] Am I being required or...?

From: Danny Yoo (dyoo at cs.wpi.edu)
Date: Mon Mar 29 10:46:55 EDT 2010

On Mon, Mar 29, 2010 at 9:02 AM, Noel Welsh <noelwelsh at gmail.com> wrote:
> This is an unusual thing to do IME. Why don't you explain why you want
> to make the distinction and perhaps someone will be able to suggest an
> alternative that avoids this issue.

One use case is to allow a "module" to have both implementation and
test cases; when a program is run from the command line, it should
evaluate the unit tests and output them to the console.  When a module
is just required, it shouldn't fire off its unit tests.

The idiom is used in Java, where a class may have a main() static
method, and in Python, where the magic module variable '__name__' has
the special value "__main__" in the module that is being directly

Posted on the users mailing list.