Page 1 of 1

why does this do this?

Posted: Mon Mar 22, 2010 1:34 am
by tomtoo
go.lsp ...

Code: Select all

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

Code: Select all

hello
b.txt ...

Code: Select all

(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)

Re: why does this do this?

Posted: Mon Mar 22, 2010 11:39 am
by johu
Please see Command line help summary.
http://www.newlisp.org/downloads/newlis ... l#cmd_help
If 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.

Re: why does this do this?

Posted: Tue Mar 23, 2010 4:25 pm
by m35
I've been using newLISP for years now and I still forget about this behavior ^_^

Re: why does this do this?

Posted: Tue Mar 23, 2010 9:50 pm
by tomtoo
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...

Re: why does this do this?

Posted: Wed Mar 24, 2010 1:22 pm
by johu
Sorry.

I am Japanese, and I am not good at English.
Therefore, my English might be strange.

Re: why does this do this?

Posted: Wed Mar 24, 2010 8:16 pm
by tomtoo
No need to apologize--your input was welcome and helpful, and I was joking about documentation. :-)