why does this do this?

Started by tomtoo, March 21, 2010, 06:34:41 PM

Previous topic - Next topic

tomtoo

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)

johu

#1
Please see Command line help summary.

http://www.newlisp.org/downloads/newlisp_manual.html#cmd_help">//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.

m35

#2
I've been using newLISP for years now and I still forget about this behavior ^_^

tomtoo

#3
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...

johu

#4
Sorry.



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

Therefore, my English might be strange.

tomtoo

#5
No need to apologize--your input was welcome and helpful, and I was joking about documentation. :-)