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

#21
newLISP newS / couriose with args
May 29, 2007, 03:06:37 AM
Just for fun :-)
(define-macro (ttt1 a) (eval a))
(define (ttt) (ttt1 (args)))
(ttt)
> ()
(ttt 1)
> ()

;The workaround:
(define (ttt) (let (x (args)) (ttt1 x))
(ttt 1)
> (1)
#22
newLISP newS / funlib improvements
May 25, 2007, 12:03:48 PM
funlib.lsp - my library set of useful global functions is now documented with newlispdoc.

http://en.feautec.pp.ru/SiteNews/funliblsp">//http://en.feautec.pp.ru/SiteNews/funliblsp
#23
newLISP newS / global? check
May 22, 2007, 11:40:29 PM
Hi, Lutz!



The function, you suggested eraly isn't working anymore and always returns nil.
(define (global? s)
  "(global? 'sym) - return 'sym if it is global, otherwise - nil"
  (let (mask (if (= (pack "d" 1) "0001") 0x02000000 0x00000200))
    (= (& (get-int (last (dump s))) mask) mask)))
#24
newLISP newS / newlispdoc trouble
May 14, 2007, 01:00:51 AM
;; @syntax (test <t1> (<t2> <t3>) (<t4> <t5>) ...)
;; test

generates
Quotet4

syntax: (test t1 (t2 t3) (t4 t5) ...)

test

should be:
Quotetest

syntax: (test t1 (t2 t3) (t4 t5) ...)

test


Also it would be cool to have a trick for a short one line description to pruduce similar:
Quotetest - a test function

syntax: (test t1 (t2 t3) (t4 t5) ...)

test
#25
newLISP newS / sqlite3.lsp unsigned long int bug
May 11, 2007, 01:52:01 AM
sqlite3.lsp incorrectly handle the numbers greater than 2**32:



Newlisp:
QuoteIntegers are 64-bit numbers (including the sign bit, 32-bit before version 8.9.7). Valid integers are numbers between -9,223,372,036,854,775,808 and +9,223,372,036,854,775,807.


SQLite:
QuoteINTEGER. The value is a signed integer, stored in 1, 2, 3, 4, 6, or 8 bytes depending on the magnitude of the value.


sqlite.lsp
SQLITE_INTEGER
      (push (sqlite3_column_int pstm i) row -1))

From SQLite API:
* int* sqlite3_column_int(sqlite3_stmt*, int iCol)

The Fix:
(SQLITE_INTEGER
      (set 'pstr (sqlite3_column_text pstm i))
      (if (= pstr 0)
         (push nil row -1)
         (push (int (get-string pstr)) row -1)))
#26
Anything else we might add? / split xml stream
May 11, 2007, 01:00:07 AM
Dealing with jabber protocol, I want to get the sequence of separate xml statements from continuous xml stream, which is coming from server.



I can net-receive a buffer, consists of one xml statement and a start part of tne next statement.... or I can get a partial single xml statement...



In common, to handle this, I want to get all closed statements from the string buffer and leave the last unclosed (if exists) in the string buffer for appending further net-receive results to it.



As I can see, xml-parse can get the stream of statements and also survives unclosed xml statements at the end of the stream. But how can I find the point where I must to split buffer into "already closed statements" and "not yet closed last statement" parts?



If there is no a standard way for this, probably it will be possible to extend xml-parse function so it will return some positioning informaition and also a signal that the final upper-level xml statement is unclosed?
#27
Anything else we might add? / XML DTD
March 27, 2007, 07:43:30 AM
Hey, guys!



Does anybody have a DTD tools for newlisp?

I need to send and receive a huge xml data, which must be syntactically checked.

This isn't an internet application - only an interface to specialized communication system.
#28
newLISP and the O.S. / exec, slash and Win98 trouble
March 20, 2007, 06:54:08 AM
Just found that using
(exec "disk:/somewhere/in/the/deep/prog.exe")
isn't works under Win89 with regular slashes. but works with backslashes.



newLISP 9.1.1 on Win32

Win98SE



The same newlisp on W2k works fine both ways.
#29
newLISP newS / sqlite3.lsp column type bug
March 02, 2007, 05:24:23 AM
We just found a small bug in sqlite3.lsp :



When some column in the multirow result of a select has a NULL value in the first row and non-null values in the subsequent rows, then all values of this column in the result of (sql3:sql ...) function will be nil.

I.e.:

if the result of a select is:

val1|val2
1|null
2|4
3|5

then the result of a (sql3:sql "select * from ... order by val1")

will be

((1 nil)
 (2 nil)
 (3 nil))

This is caused by the optimization trick that fetches the column's values only from the first row of an sql result:

(if (empty? col-types) (set 'col-types (get-types pstm num-cols)))

should be

(set 'col-types (get-types pstm num-cols))

to fetch actual column types from each row.
#30
newLISP in the real world / sqlite3.lsp library path
February 21, 2007, 11:31:47 PM
/usr/share/newlisp/sqlite3.lsp has the code for cross-platform autodetection of library's place.
(if
        ; LINUX and BSDs
        (< (& 0xF (last (sys-info))) 3) (set 'library "/usr/local/lib/libsqlite3.so")
        ; Mac OSX / Darwin
        (= (& 0xF (last (sys-info))) 3) (set 'library "/usr/lib/libsqlite3.0.dylib")
        ; Solaris
        (= (& 0xF (last (sys-info))) 4) (set 'library "/usr/local/lib/libsqlite3.so")
        ; MinGW, Win32
        (> (& 0xF (last (sys-info))) 4)
                (set 'library (string (env "PROGRAMFILES") "/sqlite3/sqlite3.dll"))
        true (println "Cannot load library OS not supported"))

Unfortunately, Debian Linux (and I think, at least Ubuntu too) have libsqlite library in /usr/lib/libsqlite3.so.0

Also, I think that all modern package-oriented Lunux distros have libsqlite in /usr/lib despite of library's name.



Lutz,

Can you correct this in sqlite3.lsp (or to extend an autodetection)?

...or simply to insert something like:
(if
        ; predefined place
        MAIN:libsqlite-path (set 'library MAIN:libsqlite-path)
        ; LINUX and BSDs
        (< (& 0xF (last (sys-info))) 3) (set 'library "/usr/local/lib/libsqlite3.so")
.......
#31
newLISP newS / trace logic
February 20, 2007, 07:30:03 AM
dmi@stone:~$ cat >a.lsp
(define (func1)
 (trace true)
 (print "in func1"))

(define (func2)
 (print "in func2"))

(func1)
(func2)
dmi@stone:~$ newlisp a.lsp
in func1
-----

(define (func2 )
  #(print "in func2")#)


[-> 2 ] s|tep n|ext c|ont q|uit >

It was expected that "trace" condition will affect (print "in func1"), but it was arised too late. Probably, (trace) works not in the current function, but in next user-defined which _will_ be called...
#32
newLISP and the O.S. / (timer) through midnight
November 21, 2006, 11:49:17 PM
Hi, Lutz!



The "ticker" example from the manual stops working after midnight under Win2k. (not tested under *nix).
(define (ticker)
 (println (date))
 (timer 'ticker 1.0)
)

Wed Nov 22 23:59:54 2006
Wed Nov 22 23:59:55 2006
Wed Nov 22 23:59:56 2006
Wed Nov 22 23:59:57 2006
Wed Nov 22 23:59:58 2006
Wed Nov 22 23:59:59 2006
Thu Nov 23 00:00:00 2006

...and no more output is produced



How can I pass into the next day?



newlisp v.9.0.
#33
newLISP newS / introducing named parameters
September 27, 2006, 01:28:56 PM
Hi, guys!



I have rediscovered a nice old way for making some functions more familiar :-)

Now you can write something like this:
(:send-email
  To "dmi@feautec.pp.ru"
  Through "feautec.pp.ru"
  From "losthost@narod.ru"
  Subject "test subj"
  Body "test body")

With the function ":"
(define (pair lst)
  "(pair lst) - fast pair even number of members"
  (array-list (array (/ (length lst) 2) 2 lst)))

(define-macro (: fun)
  (apply (sym fun MAIN nil)
         (letn (pairs
                 (map (fn (x) (list (eval (sym (first x) fun nil))
                                    (eval (x 1))))
                      (pair (args)))
                m (apply max (map first pairs))
                argl (array (+ 1 m)))
                (dolist (l pairs)
                  (nth-set (l 0) argl (l 1)))
                (array-list argl))))

(global ':)

...and following preparations:
(load "/usr/share/newlisp/smtp.lsp")

(context 'send-email)

(set 'From 0 'To 1 'Subject 2 'Body 3 'Through 4)

(define (send-email:send-email from to subj msg srv)
  (SMTP:send-mail from to subj msg srv))

(context 'MAIN)


In other words, if you want to define a function with named arguments, you must define it as a context default function, and also put in this context all keyword symbols and assign them a positional indexes of corresponding parameters in the function's argument's list.
#34
newLISP newS / let/letn proposal
September 20, 2006, 02:13:41 PM
From time to time I using the construction
(map set '(a b c ...) (something that returns a list))
Unfortunately, the most of such applications (for me) requires predefinition of a, b and c as local scope symbols, i.e.:
(let (a nil b nil c nil)
  (map set '(a b c ...) (something that returns a list)))

From this point it seems to be useful to extend let/letn with such rule:
(let (sym1 expr1 (sym2 sym3 sym4) expr234)
  body)


will be evaluated as:
(let sym1 expr1 sym2 nil sym3 nil sym4 nil)
  (map set '(sym2 sym3 sym4) expr234)
  body)

I.e., if in the declaration part of "let" the interpreter encounters not a symbol, but a list, then it does such expanison.

This can relaitively easy be modelled with some macro, but it seems to be nice standard feature. imho.
#35
newLISP newS / Russian introduction for programmers
September 13, 2006, 01:56:55 AM
After a year with newLISP I have written an introduction to it for Russian programmers.

The main goal is to show the fun of newLISP (and whole LISPs) versus traditional procedural and OOP languages.

This isn't a complete manual – only the most attractive language's features are shown here.

Here is it: http://en.feautec.pp.ru/store/fun-of-newlisp.html">http://en.feautec.pp.ru/store/fun-of-newlisp.html
#36
newLISP newS / base64-dec segfault
September 08, 2006, 06:48:40 AM
(base64-dec "=3D")
generates a bunch of zeroes and segfault

instead of 3D there may be other two characters

newlisp 8.9.8 on linux
#37
Anything else we might add? / (fn ...) vs '(lambda ...)
September 05, 2006, 02:10:08 PM
Guys!



How can be properly described the _practical_ difference between using:

(fn (x) (do-something-with x))

versus

'(lambda (x) (do-something-with x))

?

Now I finishing a brief introduction to newLISP (in Russian), targeted to non-LISP programmers. I need the proper words here to consolidate two of my examples...
#38
newLISP newS / set-nth trouble?
August 17, 2006, 07:45:31 AM
Hi, Lutz!



This looks like a list boundary crossing in set-nth:
newLISP v.8.9.3 on Linux, execute 'newlisp -h' for more info.

> (string? '())
nil
> (set-nth -1 '() 2)
()
> (string? '())
2
>
#39
Proud to present the first really working beta release of "newlisp ncurses console" project.



http://en.feautec.pp.ru/SiteNews/NewlispConsole">//http://en.feautec.pp.ru/SiteNews/NewlispConsole



Highlighting, formatting, completion, history and other nice things.

http://en.feautec.pp.ru/store/nlc.png">



I've start using it at work about 2 months ago, so the basic alpha testing is passed ;-)
#40
Found interesting "feature":
newLISP v.8.8.8 on linux, execute 'newlisp -h' for more info.

> (context 'CTX)
CTX
CTX> (context 'TEST)
TEST
TEST> (context 'CTX)
CTX
CTX> (symbols)
(CTX:TEST)
CTX> (set 'TEST:a 0)

context expected in function set : CTX:TEST

In other words, if we call (context 'SOMETHING) from inside the other context, we occasionally got a symbol in that context, that will interfere with new context's name.