I feel myself dumb (as usual), but is it a way to read an newlisp expression from file or string (buffer), not evaluating it? Something like read in both Common Lisp and Scheme?
read-file
Quote from: "Jeff"
read-file
read-file reads file as a string, not as an expression. I mean, if you file contains a line "(a b c)", or you have a string with the same content, how do you read or convert it to the list (a b c) ?
> (eval-string "'(a b c)")
(a b c)
But so you have the same as a 'load'.
Ah, you want to read the string in as a quoted expression. No, not that I know of. Anything that would interpret the block would evaluate it.
Hi, Cyrill!
Look into http://en.feautec.pp.ru around newlisp console (nlc) project. There is some sort of a parser. Feel free to ask questions.
P.S. But, I think it would be cool to have a newlisp hardcoded engine (I suspect - a link to some existing internal function will be sufficient ;-)
Internally such a function already exists. It reads one top-level term or s-expression from a file or string and returns. It would be easy to expose this function in the newLISP API.
The question is: what do you want to do with it? Perhaps there is a different way to achieve the same?
Lutz
Hi, Lutz!
My needs was: code analyze/edit, reformat/reindent, sanitize (wrapping the string with (quote ) before eval-string is not a way in common).
What about Cyrill?
I would definitely like access to that, too, Lutz. There are dozens of uses. Writing newnewLISP, for example :)
I wanted to do the same thing for the 'newLINT (//http)' idea--load a .lsp file as a list instead of executing it. Long after I gave up on making it, it occurred to me that perhaps doing
(eval-string (append "(quote " (read-file "file.lsp") ")"))
might do the trick. I never actually tested it though.
Quote from: "Dmi"
My needs was: code analyze/edit, reformat/reindent, sanitize (wrapping the string with (quote ) before eval-string is not a way in common).
What about Cyrill?
In fact the same: any processing of the newLISP programs in newLISP itself. My idea was to implement some experimental preprocessor: that one was probably not worth doing, but there are others.