Menu

Show posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.

Show posts Menu

Messages - rrq

#226
I just ran into the following quirk. Basically, I wanted to include stack and memory limits in a script and therefore thought I could do it in the script header line, as:
!#/usr/bin/newlisp -s 4096 -m 100
but then I discovered that only the first of these options come into play.



Eventually  I learnt that the "optional arguments" for the script interpreter are actually passed in as a single first command line argument of the whole rest of line (this is on Linux), and newlisp happily and silently(!) takes an argument of '-s 4096 -m 100' to be the same as '-s4096'. Also, it appears that the handling and delivery of optional arguments may vary across platforms, so maybe one shouldn't use them at all.



But then, how do I make the script set its limits (and other options)? Do I have to have a separate wrapper shell script for its invocation?
#227
As I understand it from having browsed the code, a list is represented in a succession of CELLs where the "contents" fields point to the list members. Thus, a list like (1 2) of two elements would be represented by 4 CELLs, two of which are  list cells and two are integer cells. The Head (aka contents) of the first list cell points to the CELL holding integer 1, and the Tail of it (aka next) points to the second list cell. Likewise, the second list cell points to the 2 cell and the nil cell (which has a special cell type).

And as an implementation level side  note, the "aux" field of a list cell is used as a short-cut that generally points to the last element of the list (or nil or true).
#228
Great. Thanks. I suppose mostly it tells me that no sane person should venture into this even if they can make a good argument for having it :-)

Fair enough; and indeed, the newlisp as is, sure is a pleasure to work with anyhow.
#229
Is there a possibility of a function that lets me pivot the execution, in the way of saving the current environment (i.e., stacks etc) into a pdl of such, then pop and continue with a saved environment?

Thus, I imagine a function, say (pivot store), that firstly makes a blob (copy) of the current exection state, then pushes that onto the given "store" (list of blobs) or, if nil, onto an internal store, then pops a blob from the internal store, before restoring this as execution state, which thus continues. (Of course, the continuation should be as an immediate return from that other call of "pivot", rather than pushing the blob again)

That kind of primitive would open the gate for cooperative multi-tasking, and allow programs with thousands of light-weight "virutally concurrent" pursuits, such as large scale simulations, as well as other domains where "parallel pursuits" design is desired.

I've started with the coding, but I'm not fully on top of the extent of things to include in the execution state blob, and wanted to check here for pointers and thoughts first.
#230
Very recently I stumbled onto the newlisp site and got amazed by the excellent  practical sense in the approach; just the right things included for scripting, and yet a proper Lisp system. Hats off for the authors!



.. I had a question, but found answers by forum search, so removed it. Now this is just praise and no question :-)
#231
It depends on the platform of course. With bash and similar, you could also have
(define (exec2 cmd) (exec (string cmd " 2>&1 ; echo $?"))
That will nicely parse and deliver the output (stdout and stderr) as a list of lines, with the addition of the return code as an additional string element at the end.