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 - nanxiao

#1
In the code example of net-eval manual(http://www.newlisp.org/downloads/newlisp_manual.html#net-eval">//http://www.newlisp.org/downloads/newlisp_manual.html#net-eval):  



......
; communicating via Uix local domain sockets

newlisp -c /tmp/mysocket


It should be Unix not Uix.
#2
Hi Ralph,



Got it! Thanks for your reply!



Best Regards

Nan Xiao
#3
Hi all,



Greeting from me!



When studying define-macro(http://www.newlisp.org/downloads/newlisp_manual.html#define-macro">//http://www.newlisp.org/downloads/newlisp_manual.html#define-macro), I am a little confused with following statement:
Quote
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


Could anyone elaborate why the fexpr's internal variable's name couldn't be same as parameter's name?



Thanks very much in advance!



Best Regards

Nan Xiao
#4
@ralph.ronnquist:



Thanks very much for your help!
#5
@Lutz:



Got it! Thanks very much for your time and response!
#6
Hi all,



Greeting from me!



I try arg-test program in http://www.newlisp.org/downloads/CodePatterns.html#toc-2">//http://www.newlisp.org/downloads/CodePatterns.html#toc-2:  



#!/usr/bin/newlisp -s 100000 -m 10
     
(println (main-args))
(println (sys-info))

(exit) ; important


Using current stable 10.7.1, the result of running arg-test is like this:  

$ ./arg-test.lsp
("/usr/bin/newlisp" "-s 100000 -m 10" "./arg-test.lsp")
(491 576460752303423488 410 2 0 100000 0 102774 10701 385)


The "Maximum number of Lisp cells constant" of sys-info is 576460752303423488 , but from the source code:



......
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;
        }
......


It seems MAX_CELL_COUNT is not changed and "-m" option doesn't take effect.



Best Regards

Nan Xiao
#7
Hi all,



Greeting from me! I am a newbie of newLISP, and want to implement a simple feature which launches processes according to CPU number:  

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


I know following code will let p gets only one result:

(dotimes (i cpu-num)
(spawn 'p (println i)))


I want to use an array to hold every process's return value, but following code is not invalid:

(set 'result-array cpu-num)

(dotimes (i cpu-num)
(spawn (result-array i) (println i)))


So how can I get return value of every spawn process iteration in for-loop? Thanks very much in advance!



Best Regards

Nan Xiao