newLISP Fan Club

Forum => Anything else we might add? => Topic started by: tomtoo on March 21, 2010, 06:34:41 PM

Title: why does this do this?
Post by: tomtoo on March 21, 2010, 06:34:41 PM
go.lsp ...

#!/usr/bin/newlisp
(set 'b (join (rest (rest (main-args))) " "))
;(exit)


a.txt ...

hello


b.txt ...

(hello)


$ ./go.lsp a.txt

newLISP v.10.2.1 64-bit on Linux IPv4 UTF-8, execute 'newlisp -h' for more info.



> b

"a.txt"



$ ./go.lsp b.txt



ERR: invalid function : (hello)
Title: Re: why does this do this?
Post by: johu on March 22, 2010, 04:39:20 AM
Please see Command line help summary.

//http://www.newlisp.org/downloads/newlisp_manual.html#cmd_help


QuoteIf a newLISP executable program is followed by parameters the program must finish with and (exit) statement, else newLISP will take command-line parameters as additional newLISP scripts to be loaded and executed.


newLISP takes a.txt and b.txt as newLISP scripts ,

because go.lsp dose not have (exit) statement.



In the first example,

After go.lsp was loaded , a.txt is loaded.

Symbol hello is evaluated as nil.



In the second example,

S-expression (hello) is evaluated and then the error occurs.
Title: Re: why does this do this?
Post by: m35 on March 23, 2010, 09:25:04 AM
I've been using newLISP for years now and I still forget about this behavior ^_^
Title: Re: why does this do this?
Post by: tomtoo on March 23, 2010, 02:50:23 PM
Yep.  seems counterintuitive.  I did notice the (exit) bit--in my example it was commented out, I think.  I was confused because I never told newlisp to read anything.  Just of the top of my head, it seems like the argument should have been treated as though it was "bob," or anything else.  It just happened to be a file name.



Thanks, though.  What is this "documentation" you speak of?  It sounds strange and wonderful...
Title: Re: why does this do this?
Post by: johu on March 24, 2010, 06:22:42 AM
Sorry.



I am Japanese, and I am not good at English.

Therefore, my English might be strange.
Title: Re: why does this do this?
Post by: tomtoo on March 24, 2010, 01:16:43 PM
No need to apologize--your input was welcome and helpful, and I was joking about documentation. :-)