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 MenuQuote
Note that in fexprs, the danger exists of passing a parameter with the same variable name as used in the define-macro definition. In this case, the fexpr's internal variable would end up receiving nil instead of the intended value:
;; not a good definition!
(define-macro (my-setq x y) (set x (eval y)))
;; symbol name clash for x
(my-setq x 123) → 123
x → nil
#!/usr/bin/newlisp -s 100000 -m 10
(println (main-args))
(println (sys-info))
(exit) ; important
$ ./arg-test.lsp
("/usr/bin/newlisp" "-s 100000 -m 10" "./arg-test.lsp")
(491 576460752303423488 410 2 0 100000 0 102774 10701 385)
......
if(strncmp(argv[idx], "-m", 2) == 0)
{
#ifndef NEWLISP64
MAX_CELL_COUNT = abs(0x0010000 * atoi(getArg(argv, argc, &idx)));
#else
MAX_CELL_COUNT = abs(0x0008000 * atoi(getArg(argv, argc, &idx)));
#endif
continue;
}
......
(import "libc.so" "sysconf")
(constant '_SC_NPROCESSORS_ONLN 503)
(define (report pid)
(println "process: " pid " has returned"))
(define cpu-num (sysconf _SC_NPROCESSORS_ONLN))
(set 'result-array cpu-num)
(dotimes (i cpu-num)
(spawn 'p (println i)))
(until (true? (sync 10 report)))
(exit)
(dotimes (i cpu-num)
(spawn 'p (println i)))
(set 'result-array cpu-num)
(dotimes (i cpu-num)
(spawn (result-array i) (println i)))