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

Topics - ssqq

#1
When `rest` or `chop` or `filter` a list, empty list would be create.

But many function that process list would throw error with empty list (first last rest nth).

So newlisper need treate empty list as special list to avoid code crash.



If index empty list return nil, then would simplify coding processing list.



(set '@lst (process @lst))
(cond
   ((symbol? (first @lst) (dosth ..))
   (true ..))
#2

> (define (show-args) (println (args)))            
(lambda () (println (args)))                        
> (show-args 1 2 3)                                
(1 2 3)                                            
(1 2 3)                                            
> (define (show-args,@x) (println (args)))          
(lambda (, @x) (println (args)))                    
> (show-args 1 2 3)                                
(3)                                                
(3)                                                
> (define (show-args @x, @y) (println @x (args)))  
(lambda (@x , @y) (println @x (args)))              
> (show-args 1 2 3)                                
1()                                                
()                                                  
>
#3
Anything else we might add? / case design
August 22, 2016, 07:12:05 AM

(constant 'Type 1)

(define (check-type x)
  (case
    (Type (println "it is Type"))
    (true (println "it is not Type"))))

(check-name 1)

(exit)

==> it is not Type



For: case

syntax: (case exp-switch (exp-1 body-1) [(exp-2 body-2) ... ])



The result of evaluating exp-switch is compared to each of the[size=150] unevaluated [/size]expressions exp-1, exp-2,



I want to know Why make case expression with unevaluated?
#4

> {[{]}

ERR: string token too long : "[{]}"
> {[{]}

ERR: string token too long : "[\{]}"
;; nnn also could not recognize in {..}
> {123}
"\123"

#5
Anything else we might add? / -nan is not number
August 01, 2016, 01:56:39 AM
-nan (NaN) should not return true with number?



> (set 'nan (sqrt -1))
> (number? nan)
true ;; should return nil


Also advise with inf. I think all NaN and Inf are "error status" that may not throw error immediatly.

So they isn't value.
#6
I don't know how resume stack space in newLISP.



If I use one function do too much thiings, then the stack of function may occur stack overflow?



If i reject the return value when call other function, then would avoid stack overflow?



If anyone could give me some advise?
#7
ERR: call or result stack overflow in function set : term

When I see this error, I think the stack size is too small. How to enlarge it in default?
#8
newLISP in the real world / dangrous true?
July 27, 2016, 05:32:01 AM
if you use true? as checking function for list, be attention to: blank list -> '(), would not match it.




> (true? '())
nil



If you often use it, advise you use :



> (define (bool x) (if (nil? x) nil true))
> (for-all bool '(1 2 3 4 () 6))
#9
I re-design these two tools now:



tidy newlisp:

could find loss ")" or more ")". while, letn, dotimes all indent two space.



https://github.com/songzan/newlisp-spp/blob/master/tools/lint.lsp">https://github.com/songzan/newlisp-spp/ ... s/lint.lsp">https://github.com/songzan/newlisp-spp/blob/master/tools/lint.lsp



usage: > newlisp tidy.lsp target.lsp



lint nelisp:

could check un-declare symbol and un-used symbol.



https://github.com/songzan/newlisp-spp/blob/master/toos/lint.lsp">https://github.com/songzan/newlisp-spp/ ... s/lint.lsp">https://github.com/songzan/newlisp-spp/blob/master/toos/lint.lsp



usage: newlisp lint.lsp target.lsp



or you could puts them in your bin path:



newlisp -x lint.lsp lint
chmod 755 lint
sudo mv lint /usr/bin/lint
newlisp -x tidy.lsp tidy
chmod 755 tidy
sudo mv tidy /usr/bin/tidy
#10
I want check a variable value till another process send it to it, then do other thing. How to design it?




(while (check-var-is-true) (do-some-thing))

#11
When I add a array to list, then index it, it would became list in silent.



newLISP v.10.7.0 32-bit on Windows IPv4/6 libffi, options: newlisp -h

> (array? ((list 1 (array 3 '(1 2 3)) 3) 1))    
nil
> (list? ((list 1 (array 3 '(1 2 3)) 3) 1))    
true


I think array as value, when transfer to expression, it should be in definitely.



When I add a list to array, then index it, it also is list

> (list? ((array 3 '(1 (2 3) 4)) 1))
true
#12

> (empty? (array 2 '(1 2)))
ERR: list or string expected : (1 2)


I think any check function could accept any type of data.
#13
some newLISP builtin function is destructive, If user want design destructive function, how to make it?



for every argument passed into user function is value, not reference only if value is stored in a functor.
#14
I found '() is not nil or true? value:



> (nil? '())
nil
> (true? '())
nil
> (empty? '())
true
> (list? '())
true
> (= '() '())
true


for nil and true is only bool value in newLISP, so everything should be judged with nil? or true?
#15

> (define a:a)
ERR: context expected in function define : a
> (define b:b)
ERR: context expected in function define : b
> (define c:c)
ERR: context expected in function define : c
> (define d:d)
ERR: context expected in function define : d
> (define e:e)
ERR: context expected in function define : e
> (define f:f)
nil
#16
I think first lambda expression should is 'lambda:



> (first (lambda (x y) (+ x y)))
lambda
> (first (fn (x y) (+ x y)))
fn
> 'lambda
lambda
> 'fn
fn
> (cons 'fn '((x y) (+ x y)))
(fn (x y) (+ x y))


Why newLISP use args as first elements of lambda expression?

Why could not quote *lambda* and *fn*?
#17
Anything else we might add? / add function defined?
July 06, 2015, 01:44:33 AM
I think newlisp  should add function *defined?*, for all not defined variable is *nil*.




> (defined? 'var) ; --> nil
> (set 'var nil)
> (defined? 'var) ; --> true
> (delete 'var)
> (defined? 'var) ; --> nil

#18
I like newLISP.



If put the source code to github. maybe more people could participate in this Project.



If Add some function used 'Test` in newLISP core like this:


        ( is (expression args) result, messsage))
                 ( ok expression-is-true message)


Then could add some test-case in core. So many people could see sample in source code.



Add Core-Module-List in newLIsp.com, with registered download address, then We could write code to download module, install it then test it automatically.
#19
I write a tool for checking un-declare symbol of newLISP code, it need improve more.



https://github.com/songzan/Spp/blob/master/strict.lsp">https://github.com/songzan/Spp/blob/master/strict.lsp



If you want test it, pls link it first (or change default *main-args* number):



On Winxp:



       > newlisp -x strict.lsp strict.exe

       > strict your-script.lsp



On Linux:



      > newlisp -x strict.lsp strict

      > chmod 755 strict

      > ./strict your-script.lsp



1. all un-declare symbol would output an warning.

2. all un-used symbol declared with *local*, *let*, *letn*, *letex* would output an warning.

3. all symbol declared with *set* or *setq* in *lexical scope* would throw an warning.



todo:



1. could not check the symbols *import* from C module

2. could not check *other* context symbols.

3. could not check symbol created with *new* or *bind*.

4. warning message have not the line number and pos message.



welcome give me some suggest.
#20
When I use the key of *up* *down* *right* *left* in REPL with Ubuntu 14.04 shell:




ssqq@X61:~$ newlisp
newLISP v.10.6.0 32-bit on Linux IPv4/6 UTF-8, options: newlisp -h

> ^[[D^[[C^[[B^[[A^[[A^[[C



I try other shell or ssh tool, same problem. If I missed some compiler file when built newLISP?