Menu

#44 *args* omits script name (if any)

closed-wont-fix
5
2010-12-11
2010-12-01
No

Scripting with Common Lisp would be a lot easier if *args* included the lisp file loaded by clisp.

E.g., ./myscript.cl and clisp.cl would have *args* => ("myscript.cl")

One workaround is to use shebang trickery. http://speely.wordpress.com/2010/11/27/writing-scripts-with-common-lisp/

Discussion

  • Pascal J. Bourguignon

    You can use *load-pathname* to get the script name.

     
  • Andrew Pennebaker

    *load-pathname* is the name of the currently loading file, not necessarily the file indicated by calling clisp somefile.lisp.

    I petition CLISP to add something equivalent to Python's if __name__=="__main__" or Ruby's if __FILE__==$0.

    Basically, I'd like CLISP's *args* to operate like SBCL, Clozure, GCL, ECL, CMUCL, AllegroCL, and LispWorks. Notice the use of cdr in http://common-lisp.net/gitweb?p=projects/qitab/command-line-arguments.git;a=commitdiff;h=19866582857b3431e01c945afb62e9366e919f07

     
  • Sam Steingold

    Sam Steingold - 2010-12-01

    Pascal is right; *load-pathname* is what you want.
    http://clisp.sourceforge.net/impnotes/quickstart.html#quickstart-unix

    You are asking me to introduce a gratuitous incompatibility with the previous versions of clisp.
    While I agree that it is a good idea to offer an interface similar to other CL implementations,
    I don't see much benefit in this specific change.

     
  • Sam Steingold

    Sam Steingold - 2010-12-01
    • labels: 100543 -->
    • status: open --> pending-wont-fix
     
  • Bruno Haible

    Bruno Haible - 2010-12-11

    I agree with Sam. The piece of code that you pointed to
    <http://common-lisp.net/gitweb?p=projects/qitab/command-line-arguments.git;a=blob;f=get-command-line-arguments.lisp;h=02af126783ec366c974c22ad3a4e37b099213b69>
    indicates that what people want in most cases is the list of arguments. That's why FaRe's function there
    contains a cdr call for most CL implementations. So clisp's ext:*args* corresponds already exactly
    to what people want in most cases. You're asking to change that; it makes no sense.

     
  • Bruno Haible

    Bruno Haible - 2010-12-11
    • labels: --> Extend ANSI CL
    • status: pending-wont-fix --> closed-wont-fix
     

Log in to post a comment.