The 9.4.0 newLISP manual

Notices and updates
Kazimir Majorinc
Posts: 388
Joined: Thu May 08, 2008 1:24 am
Location: Croatia
Contact:

Post by Kazimir Majorinc »

I noted that length requires constant time in Newlisp, and that is some advantage over other Lisp dialects where it is linear. Maybe it deserves to be mentioned in the function reference.

Kazimir Majorinc
Posts: 388
Joined: Thu May 08, 2008 1:24 am
Location: Croatia
Contact:

Post by Kazimir Majorinc »

"integer" appears to be alias for "int" but is not documented in manual.
On the other side, "int?" is not defined as predicate, but "integer?" is.

I think it is the best to define both as aliases - "int" and "integer"; "int?" and "integer?" and also to document both. (Such aliases, short and long seem to be good practice to me.)

cormullion
Posts: 2037
Joined: Tue Nov 29, 2005 8:28 pm
Location: latiitude 50N longitude 3W
Contact:

Post by cormullion »

I thought integer might have been deprecated in 2004... (Before my time...) Lutz will know - or you could try to find old release notes...

rickyboy
Posts: 595
Joined: Fri Apr 08, 2005 7:13 pm
Location: Front Royal, Virginia

Post by rickyboy »

cormullion wrote:I thought integer might have been deprecated in 2004... (Before my time...) Lutz will know - or you could try to find old release notes...
See item 3 here.
(λx. x x) (λx. x x)

newdep
Posts: 2019
Joined: Mon Feb 23, 2004 7:40 pm
Location: Netherlands

Post by newdep »

Lutz,

Regarding newlisp 10.0

Have you ever considered porting the documentaion to windows chm format?
Not sure how much work it takes but its a nice format that reads good too.


Norman
-- (define? (Cornflakes))

cormullion
Posts: 2037
Joined: Tue Nov 29, 2005 8:28 pm
Location: latiitude 50N longitude 3W
Contact:

Post by cormullion »

I'm not sure it would easy. And I think Microsoft have announced they're moving away from that format to another one. Also, I don't think it's easy to develop on systems other than Windows.

newdep
Posts: 2019
Joined: Mon Feb 23, 2004 7:40 pm
Location: Netherlands

Post by newdep »

chm just is so easy to click on actualy and Voila you have a nice windowed
manual that runs on everything that has windows on it..

But i agree chm is from the OS2 days and its time for Microsoft to invent
their own stuff for once ;-)


I think Ill continue with porting the the Newlisp manual then to my JAVA
manual viewer by use of GS...(always a pleasure to use domestic tools ;-)
-- (define? (Cornflakes))

newdep
Posts: 2019
Joined: Mon Feb 23, 2004 7:40 pm
Location: Netherlands

Post by newdep »

For release 10.0

perhpas the left pane index could get a little more extention?

! +-*/% Ab Ap B Ca Co Da Di Em Ev Fa Fn G I J La Li Ma Me Na Ne No O Pa Q Ra Reg Sa Sh St T U W X


more function now exist and this small index jumps over functions...
Not realy an issue but would walking through the manual a little more
smooth...


! +-*/% Ab An Ap B Ca Co Da Di Em Ev Fa Fn G I J La Li Lo Ma Me Na Ne Ni No Nu O Pa Pe Pi Q Ra Re Ro Sa Se Si Sg Sh So St Sy Ta Ti Un Up Ut Wa Wr X Ze
-- (define? (Cornflakes))

newdep
Posts: 2019
Joined: Mon Feb 23, 2004 7:40 pm
Location: Netherlands

Post by newdep »

For release 10.0

another document extention...

Could the Chapters listed on the left frame ->

List processing, flow control and integer arithmetic
String and conversion functions
Floating point math and special functions
Matrix functions
Array functions
..
..

Also "be" a link that points to the description of these...
-- (define? (Cornflakes))

HPW
Posts: 1377
Joined: Thu Sep 26, 2002 9:15 am
Location: Germany
Contact:

Post by HPW »

setq is not a valid jump target any more.

file:///C:/Programme/newlisp/newlisp_manual.html#setf

does work but

file:///C:/Programme/newlisp/newlisp_manual.html#setq

does not.
Hans-Peter

newdep
Posts: 2019
Joined: Mon Feb 23, 2004 7:40 pm
Location: Netherlands

Post by newdep »

9.9.9.3

Manual states, which does not work anymore due to inc/dec changes->




Functions with memory

A default function can update the lexically isolated static variables contained inside its namespace:

;; a function with memory

(define (Gen:Gen x)
(if Gen:acc
(inc 'Gen:acc x)
(set 'Gen:acc x)))

(Gen 1) → 1
(Gen 1) → 2
(Gen 2) → 4
(Gen 3) → 7

gen:acc → 7
-- (define? (Cornflakes))

Lutz
Posts: 5279
Joined: Thu Sep 26, 2002 4:45 pm
Location: Pasadena, California
Contact:

Post by Lutz »

Thanks, I am working all this week on documentation, so any corrections are specially welcome this week.

newdep
Posts: 2019
Joined: Mon Feb 23, 2004 7:40 pm
Location: Netherlands

Post by newdep »

init.conf.example has a wrong directory for lynx.

"lynx /usr/share/newlisp/doc/newlisp_manual.html#%s"

should be (according to the Makefile) ->

"lynx /usr/share/doc/newlisp/newlisp_manual.html#%s"


On the otherhand? You could change it with this ->
(but the html is very nice too)


;; --- command line help
(define-macro (help func-name)
(if (find func-name "|+*-") (push "\\" func-name))
(set 'html-text (join (find-all (format {(syntax: \(%s.*?)} (name func-name) )
(read-file "/usr/share/doc/newlisp/newlisp_manual.html")) "\n"))
(println (replace "<.*?>" html-text "" 0))
"" )
-- (define? (Cornflakes))

xytroxon
Posts: 296
Joined: Tue Nov 06, 2007 3:59 pm
Contact:

Post by xytroxon »

Errata:

http://newlisp.nfshost.com/downloads/de ... anual.html

A sneaky html / frames problem with this section in the manual:

---------
4. Functions in alphabetical order

! +-*/% Ab Ap As Ba Ca Cl Co Cu De Di Do En
Ex Fi Fl Ga Gl In La Li Ma Mu Net New Nt Pa
Pr Ra Rea Reg Sea Seq Sl St Sy Ti Tr Ut Wr

Appendix...
-------

When reading the newLISP manual in HTML format, no frames, clicking on any of the above links opens another (one) copy of newlisp_manual.html in my browser...

The problem is caused by the links being in the form:

Code: Select all

 <a href="..." target="body">
when no parent frame is present...

So the links in newlisp_manual.html should be in this form:

Code: Select all

 <a href="...">
Note: target="body" does not cause a problem when clicking these links from this section of the newlisp_manual.html in the frames version. That is, when the manual_frame.html page is used to view the manual.

---------

set-ref-all * <- uses asterisk instead of ! (exclamation point) as used by all other destructive functions

----------

-- xytroxon
"Many computers can print only capital letters, so we shall not use lowercase letters."
-- Let's Talk Lisp (c) 1976

Lutz
Posts: 5279
Joined: Thu Sep 26, 2002 4:45 pm
Location: Pasadena, California
Contact:

Post by Lutz »

Thanks for all the manual corrections. An updated version is available here:

http://www.newlisp.org/downloads/develo ... anual.html

newdep
Posts: 2019
Joined: Mon Feb 23, 2004 7:40 pm
Location: Netherlands

Post by newdep »

Missing brackets ->

manual 9.9.9.4

8. Lambda expressions in newLISP

(set 'double (lambda (x) (+ x x)) <---- missing )
(set 'double (fn (x) (+ x x)) <---- missing )
-- (define? (Cornflakes))

newdep
Posts: 2019
Joined: Mon Feb 23, 2004 7:40 pm
Location: Netherlands

Post by newdep »

The define function is just a shorter way of assigning a lambda expression to a symbol:

(define (double x) (+ x x))) → (lambda (x) (+ x x))
(double 123) → 246


should be ->

(define (double x) (+ x x)) → (lambda (x) (+ x x))
(double 123) → 246
-- (define? (Cornflakes))

newdep
Posts: 2019
Joined: Mon Feb 23, 2004 7:40 pm
Location: Netherlands

Post by newdep »

according to the manual ->

A lambda list can be manipulated as a first-class object using any function that operates on lists:

(setf (double 1) '(mul 2 x)) → (lambda (x) (mul 2 x))
double → (lambda (x) (mul 2 x))
(double 123) → 246



But that gives ->


# No Symbol reference found!
-- (define? (Cornflakes))

Lutz
Posts: 5279
Joined: Thu Sep 26, 2002 4:45 pm
Location: Pasadena, California
Contact:

Post by Lutz »

The example in the manual is wrong, because '(double 1)' will be evaluated returning 2, its the ambiguity of implicit indexing versus function call, therefore 'nth' has to be used:

This is the correct example:

Code: Select all

(setf (nth 1 double) '(mul 2 x)) => (mul 2 x)
double => (lambda (x) (mul 2 x))

newdep
Posts: 2019
Joined: Mon Feb 23, 2004 7:40 pm
Location: Netherlands

manual 9.9.95

Post by newdep »

Use the constant function (which works like set) to protect the symbol from subsequent alteration. Using the setq or setq function eliminates the need to quote the variable symbol.


should be ->
Use the constant function (which works like set) to protect the symbol from subsequent alteration. Using the setq or setf function eliminates the need to quote the variable symbol.

(setq should be setf, the link is oke though...)
-- (define? (Cornflakes))

newdep
Posts: 2019
Joined: Mon Feb 23, 2004 7:40 pm
Location: Netherlands

Post by newdep »

9.9.95 typo...

syntax: (copy exp)

Make a copy from evaluating expression in exp. Some built-in functions are destructive, changing the original contents of a list, array or string they are working on. With copy their behvior can be made non-destructive.


should be "behavior"
-- (define? (Cornflakes))

DrDave
Posts: 126
Joined: Wed May 21, 2008 2:47 pm

Add an example or two to EXEC?

Post by DrDave »

I was looking at some functions in the manual and noted EXEC enables launching a process, such as another newlisp process (among others), and passing a command to it. For example,

Code: Select all

(exec "newlisp" "(+ 3 4)" )  -->
7 
true
For those that use newLISP quite a lot, I'm sure that the text in the manual is sufficient. But for new folks, or those that aren't hard-core users (I'm in that group), a couple of examples of code that really works would be very helpful.

I suspect that this could be useful if a blocking function needs to be called. So rather than calling the blocking function in the first newlisp process, launch a second newlisp process and call the blocking function and somehow capture the result. It is not clear to me how to capture the result from the second process. To where does the result go? How to determine if the result is availalble (maybe run a timer and check for wherever the result goes being true? Or somehow check for the final return value of true?)
...it is better to first strive for clarity and correctness and to make programs efficient only if really needed.
"Getting Started with Erlang" version 5.6.2

Lutz
Posts: 5279
Joined: Thu Sep 26, 2002 4:45 pm
Location: Pasadena, California
Contact:

Post by Lutz »

Note that when using the second syntax of 'exec' feeding stdin to the process. Only 'true' or 'nil' is returned. The '7' you are seeing is only stdout of the process showing up in the your console terminal. Only when not feeding stdin, the output of the process is collected and comes back in a list:

Code: Select all

> (exec "newlisp -e '(+ 3 4)'" )
("7")
> 
For what you are suggesting 'process' with the pipes option may be the better solution, because you can set up a non-blocking bidirectional communication and use 'peek' to check if something is ready on the input pipe:

Code: Select all

> (map set '(myin nlout) (pipe))
(3 4)
> (map set '(nlin myout) (pipe))
(5 6)
> (process "/usr/bin/newlisp" nlin nlout)
15763
> (write-buffer myout "(+ 3 4)\n")
8
> (peek myin)
2
> (read-line myin)
"7"
> (write-buffer myout "(exit)")
6
> (peek myin)
0
> 
Look also into 'net-eval' which allows you to distribute processes on different machines on a network. Its blocking but can also be event driven when a node has a result ready.

If you are on Mac OS X, Linux or other Unix you should also look into newLISP's Cilk API with the functions 'spawn', 'sync' etc.

DrDave
Posts: 126
Joined: Wed May 21, 2008 2:47 pm

Post by DrDave »

Thanks for the explanation.

This code doesn't work for me (Windows XP pro, newLISP 9.3.0)

Code: Select all

> (exec "newlisp -e '(+ 3 4)'" )
("7")
> 
Here is the result I get

Code: Select all

("" "missing parenthesis : \"...'(+                         \\168\225\\\"\"")
(There are probably more spaces betwee the + and \\, but I didn't count them all.)
...it is better to first strive for clarity and correctness and to make programs efficient only if really needed.
"Getting Started with Erlang" version 5.6.2

Lutz
Posts: 5279
Joined: Thu Sep 26, 2002 4:45 pm
Location: Pasadena, California
Contact:

Post by Lutz »

Try this:

Code: Select all

> (exec {newlisp -e "(+ 3 4)"})
("7")
>
Quotes are not permitted on Windows as token delimiters on the command line, using curly braces as the outer string delimiters you can use double quotes inside.

ps: redundant parentheses removed
Last edited by Lutz on Fri Nov 28, 2008 1:42 am, edited 1 time in total.

Post Reply