Re: argv[0] not available to CLISP programs
Andrew Pennebaker <[email protected]>
| Newsgroups | gmane.lisp.clisp.devel |
|---|---|
| Message-ID | <CAHXt_SWmqPpN97QRsctcXs0FznkYQMeWbSFNX86SWaoFpENFEA@mail.gmail.com> |
> Are you trying to figure out whether a particular file is the "main > script" as opposed to being loaded from some other script? > Yes. There's no standard name for the behavior of bundling a package API with a usable CLI in a single code file, so I've taken to calling it "scripted main" and begun documenting on Rosetta Code<http://rosettacode.org/wiki/Scripted_main> how to achieve this in a variety of programming languages. Another word for programs this is "modulino". > One way to do this is to check your own variable *main* and bind it if > it is not bound already. This is portable. > Another way is to use SYS::*LOAD-LEVEL*, which is bound to incremented > values by LOAD. > Yeah, so I'm looking for a simpler way to do this. Some languages expose this via a variable, like $0, or a single function call. Yet another way is EXT:ARGV > http://clisp.org/impnotes/environment-enq.html#argv This isn't portable. It involves CLISP-specific parsing to reliably extract the script name, so the same code can't be used in ECL, CCL, ABCL, ... I like my code to be very portable. > 2 years ago you asked about this here: > > http://sourceforge.net/tracker/?func=detail&aid=3124233&group_id=1355&atid=351355 > can you offer a better rationale than then? > I agree that modifying the output of ext:*args* would break reverse compatibility. I agree that we don't want to break reverse compatibility. So I'll tweak my suggestion and request that CLISP provides another function much like ext:*args*, except that it exposes an equivalent to C's argv[0]. An easy way to satisfy this is to make a function ext:*argv0*. -- Cheers, Andrew Pennebaker www.yellosoft.us ------------------------------------------------------------------------------ Monitor your physical, virtual and cloud infrastructure from a single web console. Get in-depth insight into apps, servers, databases, vmware, SAP, cloud infrastructure, etc. Download 30-day Free Trial. Pricing starts from $795 for 25 servers or applications! http://p.sf.net/sfu/zoho_dev2dev_nov _______________________________________________ clisp-devel mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/clisp-devel