Common Lisp equivalent to Haskell's main function?
Haskell's `main` function does just what I want: evaluate when the file is loaded by itself (e.g. `./myfile.hs` or `runhaskell myfile.hs`) and in no other case. `main` will not be called when the file is imported by another file. [newLISP][1] also has this functionality.

Is there equivalent code for Common Lisp?

I read the [source code][2] for CLISP. Here's what happens when the user enters `clisp myfile.lisp` or `./myfile.lisp`:

 1. CLISP saves `myfile.lisp` as `p->argv_execute_file`.
 1. CLISP creates the expression `(LOAD "p->argv_execute_file")` and pushes it onto the Lisp stack.
 1. CLISP saves any additional command-line arguments in a list.
 1. CLISP stores the arguments in the Lisp variable `*args*`.

CLISP never makes a Lisp variable referring to `p->argv_execute_file`, so there is no way to discern whether `myfile.lisp` was loaded directly, by the user in the REPL, or by another Lisp file. If only `(car *args*)` were `myfile.lisp`, my task would be easy.

Note: Shebangs give CLISP trouble if the file is loaded from the REPL, so I put this code in `~/.clisprc.lisp`:

    (set-dispatch-macro-character #\# #\!
     (lambda (stream character n)
      (declare (ignore character n))
      (read-line stream nil nil t)
      nil))


  [1]: http://subversion.assembla.com/svn/mcandre/newlisp/module.lsp
  [2]: http://clisp.cvs.sourceforge.net/viewvc/clisp/clisp/src/spvw.d?view=markup
Common Lisp equivalent to Haskell's main function?
===

Haskell's `main` function does just what I want: evaluate when the file is loaded by itself (e.g. `./myfile.hs` or `runhaskell myfile.hs`) and in no other case. `main` will not be called when the file is imported by another file. [newLISP][1] also has this functionality.

Is there equivalent code for Common Lisp?

I read the [source code][2] for CLISP. Here's what happens when the user enters `clisp myfile.lisp` or `./myfile.lisp`:

 1. CLISP saves `myfile.lisp` as `p->argv_execute_file`.
 1. CLISP creates the expression `(LOAD "p->argv_execute_file")` and pushes it onto the Lisp stack.
 1. CLISP saves any additional command-line arguments in a list.
 1. CLISP stores the arguments in the Lisp variable `*args*`.

CLISP never makes a Lisp variable referring to `p->argv_execute_file`, so there is no way to discern whether `myfile.lisp` was loaded directly, by the user in the REPL, or by another Lisp file. If only `(car *args*)` were `myfile.lisp`, my task would be easy.

Note: Shebangs give CLISP trouble if the file is loaded from the REPL, so I put this code in `~/.clisprc.lisp`:

    (set-dispatch-macro-character #\# #\!
     (lambda (stream character n)
      (declare (ignore character n))
      (read-line stream nil nil t)
      nil))


  [1]: http://subversion.assembla.com/svn/mcandre/newlisp/module.lsp
  [2]: http://clisp.cvs.sourceforge.net/viewvc/clisp/clisp/src/spvw.d?view=markup