-- deleted
hello, everyone!
as some of you may know, i am helping out with the newLISP documentation. continuing from this weekend i will be correcting and updating the newLISP manual (and the newLISP-tk introduction) in preparation for the upcoming release (and ultimately, newLISP 8.0).
if you have any "typo's", "transpo's", and|or "pet-peeves" that you want Lutz and i to know about, please post them to this forum (Win32|Linux sub-forums). i will try to incorporate as much as possible (and with Lutz's approval, of course); however, producing a easy-to-read and consistent set of documentation is the priority for now.
i may be back with a poll on things like "built-in" vs. "builtin"... ;-)
thanks in advance for your kind cooperation!
kazemori
A few things noticed in the HTML version of the newLISP manual v.7.3.15 downloaded and printed 12/6/2003 (180 pages):
page 3: paragraph 8: first sentence: should the phrase "are completely type polymorph" be "are completely type polymorphic" ..?
page 11: paragraph 1: "..., that than can be used" should be "..., that then can be used"
page 12: paragraph 3: need space character between last sentence and next to last sentence; that is, "... may contain a basic data type.cdr and car where ..." should be "... may contain a basic data type. cdr and car were ..." -- notice that I also changed the last word in this quote from "where" to "were".
page 16: second paragraph from bottom: last sentence: "To execute these function from ..." should be "To execute these functions from ..."
page 21: first paragraph in the "Switching the locale" section: second sentence: "newLISP start up trting to set ..." should read "newLISP starts up trying to set ..."
page 26: section "body": last sentence should end with "... then they get ..." instead of "... than they get ..."
page 35: section "<,>,=,<=,>=,!=>": third paragraph: "... more significant then elements ..." should be "... more significant than elements ..."
page 40: section "atan": just a request that (atan2 num-y num-x) would be a useful addition
page 41: section "begin": second sentence: "... more than one expressions in a row ..." should be "... more than one expression in a row ..."
page 43: section "catch": some weird line breaks going on between the words "... returns nil" and "and stores the error"; also need to separate the "example:" section from the body of the text
page 44: second paragraph from bottom: should not end in two periods; that is, "etc.." should be "etc."
page 46: section "collect": first sentence after the example should read (in part) "and do not have to appear in order" instead of "and no not have to appear in order"
page 53: very last line: should read "... dec will always return an integer ..." instead of "... dec will always return and integer ..."
page 63: top most example: should be '(error-text 5) => "Not an expression"'
page 82: section "intersect": second sentence should be "The two sets ... need not be unique ..." instead of "The two sets ... need not to be unique ..."
page 86: section "load": the "e.g.:" (meaning "for example") should be "i.e.:" (meaning "that is")
page 101: section "new": first sentence needs a space between "syn-new-context" and "is"
page 105: section "pack": first sentence should read "Pack one or more ..." instead of "Pack on or more ..."
page 107: section "parse": next to last paragraph in section: "... would have to bee used ..." should read "... would have to be used ..." (change "bee" to "be"); also the next sentence beginning "For further options numbers for ..." doesn't sound right to me.
page 107: section "pipe": first paragraph: last sentence "... compiles and not working on ..." should be "... compiles and is not working on ..."
page 116: section "quote": the result of the third example should be "(a b c)" instead of "(q b c)"
That as far as I got tonight.
-- Sam
P.S., Regarding "builtin" vs. "built-in" -- I vote for "built-in" because it is much more readable. In the "builtin" form, the last "i" gets visually absorbed by the neighboring "t".
A few more observations:
page 118: section "read-buffer": first paragraph: "... previous to reading get deleted." should be "... previous to reading gets deleted."
page 119: section "read-line": A question -- on UNIX-like systems, lines are delimited by linefeed (ASCII 10); in most Windows text file, lines are delimited by carriage-return/linefeed (ASCII 13+ASCII 10); does (read-line ...) swallow both the CR and LF characters on Windows systems? What about Windows files with lines delimited with only (ASCII 10) or (ASCII 13)?
page 119: section "ref": last line on page: "ref searchers for ..." should be "ref searches for ..."
page 129: section "select": last paragraph: "Selected elements can be repeated and no not ..." should be "Selected elements can be repeated and do not ..."
page 133: section "set-nth": following "This can be used in the replacement expression:" the code set 'lst '(1 2 3 4)) is missing the open left paren.
page 135: section "sort": In the first sentence, the second occurrence of the word "list" should be italicized.
page 137: section "swap": first sentence: "... is returned in there order ..." should be "... is returned in their order ..." -- but probably better as "... is returned in their original order."
page 139: section "sys-info": "The list has 6 integers ..." but I counted 7, and I'm unclear to what "depending on the host operating system" refers to unless it is the last of the 7 integers.
page 139: section "tan": "... is calculated on the result." should be "... is calculated as the result."
page 140: section "time": Does (time exp) really return the time spent on evaluation or simply the elapsed time from beginning to end of computation?
page 141: section "trace": second paragraph: "This can be changes to ..." should be "This can be changed to ..."
page 153: section "TCP/IP Socket error codes": the explanation of error 13 would read better as "Badly formed IP number"
newLISP Manual v.7.3.15 Additions Requested
page 38: section "and": would like example showing (and) with no arguments assuming that it is legal
page 105: section "or": would like example showing (or) with no arguments assuming that it is legal
Sam, thankyou very, very much for your corrections, all your notes will be worked in by the next development version.
About 'built-in' versus 'builtin', we just changed from one to the other a some versions ago. I am fine with either, is there seems to be no official rule on this?
About 'read-line': at this moment 'read-line' works the same on Win32 and Unix-like systems. The line will always break on a LF and swallow the LF. A line will break on CR only if followed by LF and then swallow both. A CR alone will only break and be swallowed if last character in the stream. (I will add this to the documentaion).
About 'atan2': this will be added to the next development version (allthough there is a feature freeze until 8.0, but this is simple and isolated enougth to add it now)
About 'time': the time is measured from calling the 'C' evaluateExpression(expr) function until it returned. Note, that once newLISP source is loaded (compiled to an internal binary format) there is no other overhead involved. So the time returned by (time (dotimes (x 1000000) expr)) does not include the translation of expr neither the overhead of 'time' but of course in this example the over head of 'dotimes'.
If you want the pure netto time of 'expr' without the 'dotimes' overhead you would do:
(- (time (dotimes (x 1000000) expr)) (time (dotimes (x 1000000))))
=> result in nano seconds per one evaluation of expr
Lutz
According to both Webster and the OED, the word is 'built-in'.
Correction:
in Input/output and file operations (7.3.16) the list has
device twice - the second should be exec.
Request:
Could the newlisp-tk manual be available as .pdf too.
Nigel
thanks to all for the manual corrections, the manuals are so important, not only from it's functional value but also as a 'visitors card' for the whole newLISP package. I always thougth, that most Open Source software lacks good documentation and always wanted to make docs a distinguishing feature in newLISP.
This is the first time I feel a bit better about it, thanks to you all! What is still pending is to check all the examples, cutting and pasting them into newLISP for execution, but that will take a longer time. I did it once several years ago, so most stuff should be Ok.
There are PDF versions of both the newlisp_manual.html and newlisp-tk.html in the development directory, ready for double sided printing.
The idea is to cut off 1 inch from the top and bottom and 3/4 inch from the sides. That gives you 7x9 manuals for binding at your local copy shop. You can use the files newlisp_manual.book and newlisp-tk.book in the distribution for customizing PDF conversion to your own gusto.
I am still looking for a HTML->PDF conversion program which gives me more control over page breaks, keeping syntax headers together etc. In the past I would import the manuals into MS Word for editing the print version, but its simply to much work, I need something automatic. At this moment HTMLDOC from http://www.easysw.com/software.html seems to be the best solution.
Lutz
Good documentation makes things much nicer, especially the one or two line examples.
I do a bunch of documentation in LaTeX. I can convert latex files to both pdf (use the ae fonts or the text will be horrible) and html. Although no frills, I have no complaints.
Eddie
hello Lutz!
wow! you close your eyes for a few days and whammo! a host of corrections!
Lutz, if you have not already integrated the suggestions from Sammo and nigelbrown, i will take care of these. some of the suggestions are actually questions, which may require something more than an edit; for these items, please let me know what you are going to do...
as it is tuesday afternoon in vancouver, i will start with this batch of corrections tonight or wednesday (at the latest). i will use the 7.3.17 text, unless you already have something "fresh from the oven".
kazemori
All of Sam's and Nigel's changes are already in 7.3.17 and all their questions have already been answered in this thread ;-).
I will release a new development release probably tomorrow Wednesday. If possible this will be the 7.4 by the coming weekend.
Lutz
Under atan2 in the document
1/4 PI != 90 degrees
1/4 PI == 45 degrees
Eddie
Thanks Eddie, will be corrected.
Also, before anybody asks why sequence of parameters is Y,X instead of X,Y: that seems to be a convention for that function.
Lutz
In 7.3.17 Function Reference:
"bool
true, nil, or expressions evaluating to true or nil.
true, nil, (X <= 10)"
example should be (<= x 10)
Nigel
The definition for atan2 in the manual doesn't make any sense. How could you possibly determine an angle from the X-axis to a point (y,x). There are infinitely many points to start from along the X-axis. I looked up atan2 and found the following definition.
The atan2() and atan2f() functions compute the principal value of the arc tangent of y/x, using the signs of both arguments to determine the quadrant of the return value. (http://www.mkssoftware.com/docs/man3/atan2.3.asp)
Quote
Also, before anybody asks why sequence of parameters is Y,X instead of X,Y: that seems to be a convention for that function.
The definition given at www.mkssoftware.comd/docs/man3/atan2.3.asp makes sense.
Because tangents are slopes and a slope is defined as the change in Y over the change in X, Y should go first. The difference in atan, and atan2 is simple. Atan takes a slope and converts it to a radian angle within -pi to pi (principle arc tangent). Atan2 takes the signs of y and x to determine the proper quadrant, takes the principle arc tangent of |y/x| and gives it the proper sign for the quadrant.
Eddie[/quote]
thanks corrections, Nigel and Eddie
Lutz
in the changes section on the Web
atan2 takes the arc tangent of Y/X not X/Y.
Eddier
thanks Eddie
Lutz
missing from newlist_keywords.txt (win32)
irr
set-nth
I didn't include the keywords file in the latest 7400rc release because I always forgot to update it and it was never current.
But here is a quick way to make it yourself:
(1) start newlisp in a shell, so there are only built-in symbols available without all the newlisp-tk stuff
(2) execute the following 3 statements from the commandline:
(device (open "keywords.txt" "w"))
(dolist (s (symbols)) (println s))
(close (device))
Now your keywords.txt file is ready in the curent directory.
The 'device' function sets the device used for the 'print' and 'println' function.
I am still looking for a nice LISP editor with keyword highlighting and avalable on Win32 and Unix platforms, you know anything? I used to work with 'J', written in Java and usable on all platforms, but I got frustrated with the long startup times.
Lutz
I modified the scheme.el in emacs to use some of the newLisp keywords. Everytime I use one that isn't highlighted, I put it in scheme.el and compile it so that it will be highlighted the next time. The only bad thing is that I have to have the extension .scm at the end of the files. If someone were willing to learn elisp (not me) they could write a special mode for newLisp. If I remember correctly, Emacs works on Windows and Unix.
There is also the SciTe editor. Works on Windows and Unix and adding keywords is very simple -- just put them into the lisp properties file. I'm not too wild about the way it indents however.
Eddie
I use my alltime-editor UltraEdit on WIN. No problem with syntax-highlighting and paranthesis checking. My only problem is that I had not decided to use a own extension for newlisp. Now I have a mix of alisp, common lisp and newlisp running with one highlight-definition. I have considered to use *.nlsp extension for newlisp.
Under the section "Floating point math and special functions," atan is listed twice. The second one should be gammaln.
Eddie
Thanks - I think I will release on Wednesday
Lutz
In case these (from manual 7.4.0 development) haven't been caught yet:
In (rest examples
(rest 'aList) => (b c d e)
unquote 'alist :
(rest aList) => (b c d e)
(rest "newLISP") => "ewLISP")
drop end bracket:
(rest "newLISP") => "ewLISP"
In (floor examples
(floor -1.5) => 2
should be => -2
Regards
Nigel
thanks, will be corrected
Lutz
A suggestion: nowhere in manual is www.newlisp.org referred/linked to.
(% definition says:
syntax: (% int-1 [int-2 ... ])
Expressions are evaluated. Each result is divided successively by the next int and the rest (modulo operation) is returned. Division by zero will cause an error.
now in Newlisp:
newLISP v7.4.0 Copyright (c) 2003 Lutz Mueller. All rights reserved.
> (/ -340 10)
-34
> (% -340 10)
6
>
I'm not sure what % is doing - whether there is some logic that is not clear
from the manual or an error/quirk of % with negatives - but I think it's
an error - see below.
The code in nl-math.c (7.3.17) is
case OP_MODULO:
if(number == 0) return(errorProc(ERR_MATH));
result %= number; break;
However the other definitions around there cast number long
viz:
case OP_SUBTRACT: result -= (long)number; break;
Has the lack of cast broken % ?
Nigel
PS I found an interesting, although long, discussion of modulo functions in programming languages and mathematics here:
http://mathforum.org/library/drmath/view/52343.html
Apologies that the previous post wandered away from pure manual corrections - back to a correction?
the manual says
(< 6 1.2 "Hello" any (1 2 3)) => true
newlisp says
> (< 6 1.2 "Hello" any (1 2 3))
nil
and
> (< "hello" any)
nil
The manual says :
When mixed type expressions are compared, their types are compared in the following order (low to high).
Atoms: nil, true, integer, float, string, symbol, primitive Lists: quoted list/expression, list/expression, lambda , lambda-macro
The string, symbol comparison returns nil? Should the manual have a different comparison order?
Nigel
(< 6 1.2 "Hello" any (1 2 3)) ; wrong
fails becuase of (< 6 1.2) also 'any' ans (1 2 3)should be quoted:
(< 1.2 6 "Hello" 'any '(1 2 3)) => true
(< "Hello" 'any) => true
will be corrected in the manual
Lutz
Manual correction?
Manual says
(sort '((3 4) "hi" 2.8 8 b) => (8 2.8 "hi" b (3 4))
as stand should be
(sort '((3 4) "hi" 2.8 8 b)) => (8 2.8 "hi" b (3 4))
however:
> (sort '((3 4) "hi" 2.8 8 b))
(2.8 8 "hi" b (3 4))
>
This means the bit about comparing different types viz
If two expressions of different type get compared, then the lower type is sorted before the higher type in the following order:
Atoms: nil, true, integer, float, string, symbol, primitive
is not correct as integer and float get compared as numbers not as
types. This also applies to the < discussed above.
Nigel
Yes, the cast was missing in the code for %.
Following comment after reading http://mathforum.org/library/drmath/view/52343.html :
The modular function 'mod' for floats and '%' for integers work differently for negative numbers in newLISP compared to Excel. I am using the 'C' operator and the fp function fmod() (previously handcoded), which both work consistently returning :
(% -340 60) => -40
(mod -340 60) => -40
They work as of the following definition, which I also added to the manual:
>> GNU libc documentation: >>
These functions compute the remainder from the division of numerator by denominator. Specifically, the return value is numerator - n * denominator, where n is the quotient of numerator divided by denominator, rounded towards zero to an integer. Thus, fmod (6.5, 2.3) returns 1.9, which is 6.5 minus 4.6.
The result has the same sign as the numerator and has magnitude less than the magnitude of the denominator.
<<
A similar definition is also used in: http://www.opengroup.org/onlinepubs/007908799/xsh/fmod.html
Lutz
Also, I wonder what Eddie's opinion (aren't you a math person?) is on this one?
Lutz
I have never worked with a mod for floating point numbers?
As for integers, this is a can of worms. Different language compilers (even different C compilers) don't even agree on x / y. If exactly one of x and y is negative, some will round down, -3 / 2 => -2, while others will round toward 0, -3 / 2 => -1. But rumor has it that / and % should agee to x = y*(x/y) + x%y where y is not 0.
Eddie
Here are some results of different languages.
GNU C gives
-340 % 60 => -40
Perl, Python, and Ruby give
-340 % 60 => 20
According to http://www.python.org/doc/current/ref/binary.html the sign of x % y is the
same as its second argument. I would that is true for Perl and ruby as well.
Eddie
GNU 'C' does the same for mod and %, always taking the remainder of the division towards zero versus towards the smaller (more left on the numbers axis) integer multiple of the denominator.
I will stay with theirs (GNU C) for now and have documented it in the manual. I find it more intuitive and easier to understand (of course this is very subjective). The Gnu 'C' version produces the same 'magnitude' for both signs =/-, while the other method produces two different numbers.
In any case the difference between the versions is only important when dealing with negative numbers. I wonder what tools like Mathematika or Matlab do and I also wonder what the 'deeper' mathematical meaning behind this is; perhaps its just that: viewing negative numbers as magnitudes versus point on a line starting at infinitive negative?
Lutz
Tonight, I will dig up my number theory book and see what it has to say.
Eddie
What's the latest newLISP Users Manual and Reference? I've noticed a few more typos in v.7.4.0 but want to make sure I'm reading the latest revision before I post anything.
the latest one is always the latest in:
http://newlisp.org/download/development/
Both, the source and the Windows distribution have the manuals. The rc1,rc2,rc3 versions did not distinguish with version numbers inside, they say all: 7.4.0. So the stuff in rc3 is the latest.
I am about to post the final 7.4.0 but if you have some other typos today, I delay it until tomorrow.
In the release version of 7.4.0 you will have the copyright date changed to 2004, which will be the only thing indicating the difference between release candidate versions and the fnal release.
Lutz
Just a few observations. The page 7 and page 124 notes are the most important.
page 7: "When the DLL is loaded it looks for an ini.lsp file ..." -- should that be "an init.lsp file"? If it should really be "ini.lsp", please emphasize (e.g., "yes, ini.lsp for the DLL instead of init.lsp").
page 124: syntax: (rename-file str-path) looks like (per the example) as if 'rename-file' should have two parameters.
page 145: in the paragraph describing 'trim': "... the space is assumes by default." should be "... the space character is assumed."
page 35: in the paragraph beginning "Calculations which result in value ..." -- the negation sign "-" in -2147483648 appears on a line by itself which can be confusing. Is there a way to force it to move with the body of the number to the next line?
Thanks for the corrections Sam, I have put tags around the numbers, that will hopefully keep the sign with the number during PDF conversion.
Lutz
page 88: the syntax for 'list' should have a closing parenthesis.
Thanks to all of you for helping to move newLISP forward a big step. Release 7.4.0 is available at http://newlisp.org and http://sourceforge.net/projects/newlisp
Lutz
This is late, I know, but maybe for the next update.
page 59: directory section: The last sentence should be followed by an example such as (directory "c:/").
Thanks Sam, I will continue to update the HTML and PDF manuals linked to on the newLISP home page at http://newlisp.org and put a small revision number behind the version number.
Lutz
page 107: nth-set section: the syntax definitions say "set-nth" instead of "nth-set"
page 148: unpack section: the third example (unpack "s10 f" s) doesn't eval the same on this page as it does in the 'pack' section on page 109; the example in 'pack' on page 109 is correct.
page 150: write-char section: "Writes a byte specified in int-2 to a file ..." should be "Writes the byte specified in int-byte to a file ..."
page 148: until section: "The condition in expression is evaluated." should be "The condition in exp-condition is evaluated." Also, "Evaluation is repeated until an exp-condition results in nil or the empty list ()." should be "Evaluation is repeated until exp-condition results in a value other than nil or the empty list ()."
Thanks again for your time Sam, I uploaded 'rev-2' of the HTML and PDF versions of the manual to the download directory.
Lutz
In the assoc syntax info lookup should be a link to the lookup syntax
but currently is just plain text - see:
See also replace-assoc for making replacements in association lists and lookup for an association lookup and extraction of an element in one step.
Nigel
In xml-parse syntax in manual 7.4.0 rev2
Parsing without any options:
(xml-parse (read-file "example.lsp"))
should have "example.xml"
Regards
Nigel
thanks Nigel, I will prepare and upload a rev-3 of the manual in HTML and PDF when Christmas is over tomorrow.
Lutz
revision 3 of the 7.4.0 manual is online in HTML and PDF
Lutz
In manual replace-assoc example line:
(replace-assoc 'b aList (q "I am the replacement"))
should be
(replace-assoc 'b aList '(q "I am the replacement"))
Nigel
In rev3 the fact that leading spaces are allowed in strings to convert to floats is not included - in float the example
(float "1.23") => 1.23
(float " 1.23") => nil
is there instead of
(float " 1.23") => 1.23
also trim is mentioned at bottom of discussion (no longer needed).
Allowing leading spaces has been corrected in the (integer syntax.
Nigel
Thanks for the doc corrections, doc revision 4 and development version 7.2.4 are online: http://newlisp.org/download/development/
Lutz
newLISP v7.4.0 (rev-3) Manual and Reference
page 144
time-of-day
syntax: (time) should be syntax: (time-of-day)
In syntax of +, - ...
Floating pont values which evaluate to NaN (Not a Number) are treated as 0 (zero).
could say
Floating pont values which evaluate to NaN (Not a Number), +INF, or -INF are treated as 0 (zero).
syntax of (~
says
(format "%X" (~ 0xFFFFFFAA)) => 0x55
while
> (format "%X" (~ 0xFFFFFFAA))
"55"
>
so
(format "%X" (~ 0xFFFFFFAA)) => "55"
would be clearer, or just
(~ 0xFFFFFFAA) => 0x55
In (and syntax re:
Expressions are evaluated from left to right until an exp-n evaluates to nil and nil is returned. If none of the expressions evaluates to nil the result of the last expression is returned.
I'm not sure if this is a documentation thing, a feature or a bug:
> (set 'x 10)
10
> (and (< x 100) (> x 2) "passed")
"passed"
> (and (< x 100) (> x 2) '(a b c))
(a b c)
> (and (< x 100) (> x 2) '())
nil
> (setq emptylist '())
()
> emptylist
()
> (and (< x 100) (> x 2) emptylist)
nil
>
As newlisp usually treats '() and nil differently I'm not sure why
the quoted '(a b c) is returned but the quoted '() isn't or
looks like it may be evaluated?
Nigel
In the manual '=>' always stands for the return value you would see in the console window, which would be:
(~ 0xFFFFFFAA) => 85
that is why I will correct the docs to:
(format "%X" (~ 0xFFFFFFAA)) => "55"
The reason I present the example for '~' with hex AA and 55 is, that these are well known complement patterns among the 'bit fiddleing' community.
01010101 <=> 10101010
they are sometimes used to test memory or other hardware devices reversing the bits and keeping them alternating the same time.
-----
The empty list '() and nil are both treated as not true in a boolean context, this is why:
(set 'x 50)
(and (< x 100) (> x 2) '()) => nil
evaluates to nil and not the empty list () and yes, 'and' evaluates it's arguments first, but will stop evaluating and return nil, when aboolean 'false' expression is found. I use this fact often for returning from a function (see pop3.lsp) when a failing condition is found. A 'boolean' evaluation of '() with 'and' 'or' and in conditional statements (if, while etc.) will return nil.
Lutz
Thanks for the explaination.
As that is the case, in the discussion of nil vs. () in the manual the sentence:
In newLISP nil and the empty list () are not the same as in some other LISPs. Only in conditional expressions as found in if, unless, cond, while and until they are treated as a boolean false.
could be:
In newLISP nil and the empty list () are not the same as in some other LISPs. Only in boolean and conditional expressions as found in if, unless, and, or, not, cond, while and until they are treated as a boolean false.
Nigel
PS
I see you can return '() -as expected- viz
> (and (< x 100) (> x 2) ''())
'()
>
A suggestion regarding manual discussion of contexts. It says:
All other symbols created in MAIN with exception of built-ins and symbols like true and nil are not known in other contexts. Symbols from MAIN, if used in other contexts must be prefixed with MAIN.
perhaps the globalizing function (global should have attention drawn to it here. Viz:
All other symbols created in MAIN with exception of built-ins, symbols made global using the global function, and symbols like true and nil are not known in other contexts. Symbols from MAIN, if used in other contexts must be prefixed with MAIN.
Nigel
In discussion of contexts or of (delete syntax perhaps some of Lutz's examples from this topic could be included:
http://www.alh.net/newlisp/phpbb/viewtopic.php?t=152
Nigel
re various examples:
1) it says
(set '+ add) => add <B845770D>
but
> (set '+ add)
symbol is protected in function set : +
>
see for this non-working example:
Built in functions evaluate to themselves:
add => add <B845770D>
(eval (eval add)) => add <B845770D>
(set '+ add) => add <B845770D>
+ => add <B845770D>
and:
(set 'subtract -)
(set '+ add)
subtract will behave like -. + is redefined to use the mixed type floating point mode of add.
2)
But unlike other LISPs the inside of the lambda list is still accessible in double (as shown previously):
(set 'double (lambda (x) (+ x x))
should be:
(set 'double (lambda (x) (+ x x)))
better still - for consistency have:
(set 'double (lambda (x) (+ x x))) => (lambda (x) (+ x x))
also
(set-nth 1 double '(mul 2 x)) => (+ x x) ; the old contents
is incorrect as
> (set 'double (lambda (x) (+ x x)))
(lambda (x) (+ x x))
> (last double)
(+ x x)
> (set-nth 1 double '(mul 2 x))
(lambda (x) (mul 2 x))
>
3)
(set 'lst '(nil nil nil)) => (nil nil nil))
should be
(set 'lst '(nil nil nil)) => (nil nil nil)
Nigel
re more examples
1)
(= (name 'CTAX:val) (name 'CTXB:val)) => true
should be
(= (name 'CTXA:val) (name 'CTXB:val)) => true
and for consistency
(set 'CTXA:val 123)
(set 'CTXB:val 456)
may better be
(set 'CTXA:val 123) => 123
(set 'CTXB:val 456) => 456
2)similarly for consistency and a correction
in Changing scoping and symbol protection
(set 'aVar 123)
(global aVar)
(context 'FOO)
could be made (note correction of quoting aVar in global)
(set 'aVar 123) => 123
(global 'aVar) => aVar
(context 'FOO) => FOO> ; prompt shows context
and below that
(constant 'aVar 123)
could be
(constant 'aVar 123) => 123
3)in section Variables holding contexts
(set 'ctx FOO)
ctx:x => 123
(set 'ctx:x 999)
FOO:x => 999
could be
(set 'FOO:x 123) => 123
(set 'ctx FOO) => FOO
ctx:x => 123
(set 'ctx:x 999) => 999
FOO:x => 999
4) in <<,>> it says
( >> 0x80000000 1) => 0xC0000000 ; not 0x04000000 !
now
> ( >> 0x80000000 1)
-1073741824
>
the example could be (similar to other hex example)
(format "%x" ( >> 0x80000000 1)) => "c0000000" ; not "4000000"
Nigel
re various examples
1) in apply syntax
(set 'list '(3 4 5)) => (3 4 5)
(apply * list) => 60
but
> (set 'list '(3 4 5))
symbol is protected in function set : list
>
could use
(set 'aList '(3 4 5)) => (3 4 5)
(apply * aList) => 60
2) in atan2 syntax:
(div (acos 0) (atan2 1 1) => 2
should be
(div (acos 0) (atan2 1 1)) => 2
3) in catch syntax examples because in the apply example we did
(set 'func sqrt) => sqrt
if you just work through entering the examples you can get
(set 'func sqrt) => sqrt <406C2E>
...
(catch (func 3 4) 'result) => true
I guess the answer to 'Who would do that!?' is 'Me'
Note also that (set 'func sqrt) => sqrt <406C2E>
4)in (ceil syntax
(ceil -1.5) => 1
should be
(ceil -1.5) => -1
5) in chop syntax for consistency
(set 'str "newLISP")
could be
(set 'str "newLISP") => "newLISP"
below that is an error:
(set 'lst '(a b (c d) e)
is missing a ), should be
(set 'lst '(a b (c d) e)) => (a b (c d) e)
6) in char syntax perhaps
(map char (sequence 1 255)) ; will print current character set
could say
(map char (sequence 1 255)) ; will print current character set in a list
Nigel
re various examples
1) cons syntax
(cons a '(b c)) => (a b c)
should be
(cons 'a '(b c)) => (a b c)
and
(cons (+ 3 4) (* 5 5)) => (12 25)
should be
(cons (+ 3 4) (* 5 5)) => (7 25)
or
(cons (* 3 4) (* 5 5)) => (12 25)
2) in context? syntax the examples
(set 'foo:q "hola")
(set 'ctx foo)
(context? ctx) => true ; ctx contains context foo
should use FOO to follow on from previous examples or
should create a lowercase foo context to use.
3) in cos syntax rather than
pi => 3.141592654
using
(set 'pi 3.141592654) => 3.141592654
makes example self sufficient
4) in crit-chi2 syntax it says
(crit-chi2 0.01 4) => 13.277
but
> (crit-chi2 0.01 4)
0.2971091866
>
below that says
(crit-z 0.999) => 3.090232
> (crit-z 0.999)
3.090232372
>
5) in date-value for
(date-value 2002 2 28) => 1080777600
I get 1014854400 on WinXP Pro - probably a windows thing?
Nigel
A comment on above checking of manual examples -
I've tried to add some simple automation to the process of checking manual examples - my steps were
1) from Internet Explorer save the manual as a text file (save as) called newlispman.txt.
2) define some lisp functions to step through file lines and if one contains a => then display line and ask if eval-string should be applied to it - if y then do eval-string on it and print result - I visually compare result with expected output as displayed
the functions in tryexamples.lsp are:
(define (tryexamples fileh )(while (read-line fileh)(if (find "=>" (current-line))(doify (current-line)))))
(define (doify str) (begin (print "n" (current-line) "nDo it?") (if (= (read-line) "y") (print "n=>" (eval-string (first (parse str "=>")) "syntax error")))))
then in newlisp-tk I do
(load "tryexamples.lsp")
(tryexamples (open "newlispman.txt" "read"))
then I step through the examples - some lines are not examples or incomplete parts of multiline examples or not suitable for execution then I say n.
This is why I suggest consistent use of => in example lines where possible.
So far I'm up to the (device syntax entry.
Nigel
Thanks again for all your time in checking the manual and suggesting improvements.
regarding (set '+ add):
since 7.3.0 (constant '+ add) has to be used to redefine primitives, as built-in fucntions are protected symbols since version 7.3.0 . These examples will be taken out and put into 'constant' instead.
regarding (set 'function sqrt) => sqrt <406C2E>
the display of <406C2E> is just a visual thing to show that a bulit-in function is displayed. (fuction 10) => 3.16227766 will work Ok. This will be shown more consistently in the manual. The hexadecimal code displayed will be different on different platforms and states of the OS.
regarding (crit-chi2 0.01 4):
this should be:
(crit-chi2 0.99 4) ;; not 0.01 but 1-0.01
regarding (date-value 2002 2 28):
1014854400 is the correct result and the same on all OSs and timezones, the returned value is always Universal Time.
Lutz
All of Nigel's last corrections are online in revision 5 of the documentation:
http://newlisp.org/download/newlisp_manual.html
http://newlisp.org/download/newlisp_manual.pdf
Happy new Year Nigel! (the first one on this board to cross the date-line)
Hans-Peter, you are next?
Lutz
>Hans-Peter, you are next?
Don't sure where all other member are located.
For me are 5.5 hours remaining.
Happy new Year to all newlispers!
Happy New Year!
My earlier posts on this thread were actually 5pmish 31Dec local time which is GMT minus 10h - the board time adjustments must have made them look this year.
A correction for the www.newlisp page:
XML functios and SXML support
needs functions.
Re manual - Lutz you mentioned setting memory limits but I can't see that in the command line switch topic of rev5.
Nigel
re various examples
1) dolist
(dolist (x '(a b c d e f g)) (print x)) => abcdefg
could say
(dolist (x '(a b c d e f g)) (print x)) =>prints abcdefg returns g
2)
(dotimes (x 10) (print x)) => 9
could say
(dotimes (x 10) (print x)) => prints 0123456789 returns 9
Nigel
re various examples
1) floor syntax
(floor -1.5) => 2
should be -2 viz
> (floor -1.5)
-2
2) (fv
(fv (div 0.07 12) 240 775.30 -100000) => 0.55
but
> (fv (div 0.07 12) 240 775.30 -100000)
-0.5544645052
>
Nigel
There is this topic:
Licensing
newLISP and newLISP-tk are licensed under version 2 of the GPL (General Public License).
where the link is:
file:///C:/newlisp/newlisp_manual.html#GNU
but must be:
file:///C:/newlisp/newlisp_manual.html#GNUGPL
re various examples
1)
(gammai 4 5) => 0.734974
full result:
=> 0.7349740847
2) (index
(index symbol? '(1 2 d 4 f g 5 h)) => (3 4 5 7)
should be
(index symbol? '(1 2 d 4 f g 5 h)) => (2 4 5 7)
3) (integer?
(integer? (integer 1.00) => true
should be
(integer? (integer 1.00)) => true
4) (npv
(npv 0.2027 '(500 400 300 200 100)) => 999.9983704 ; ~ 1000
but
> (npv 0.2027 '(500 400 300 200 100))
1000.033848
5) (last
(last '(a b (c d)) => (c d)
should be
(last '(a b (c d))) => (c d)
6) (last
(set 'var '(1 2 3 4) => (1 2 3 4)
should be
(set 'var '(1 2 3 4)) => (1 2 3 4)
7) (net-lookup
(net-lookup "209.24.120.224" => "www.nuevatec.com"
(net-lookup "www.nuevatec.com" => "209.24.120.224"
should be?
(net-lookup "209.24.120.224") => "www.nuevatec.com"
(net-lookup "www.nuevatec.com") => "209.24.120.224"
8) (normal
says
(normal 10 3 10) =>
(6.5517812 6.57125 10.72219 8.133062 9.291025
8.66425 7.97812 7.17125 11.39094 11.34456)
but
> (normal 10 3 10)
(7 6.563476562 11.93945312 6.153320312 9.98828125 7.984375 10.17871094
6.58984375 9.42578125 12.11230469)
>
and
(normal 0 1) => -0.3964
but
> (normal 0 1)
0.6630859375
>
9) (not
(not (not (< 1 10)) => true
should be
(not (not (< 1 10))) => true
10) (nth
(nth 3 "newLISP") => "N"
should be
(nth 3 "newLISP") => "L"
Nigel
re various examples
1) (pow
(pow 100 2) => 100
should be
(pow 100 2) => 10000
2) (prob-chi2
(prob-chi2 10 6) => 0.125
full result
=>0.1246520195
3) (pv
(pv (div 0.07 12) 240 775.30)) => 100000.1373
should be?
(pv (div 0.07 12) 240 775.30) => 100000.1373
however
> (pv (div 0.07 12) 240 775.30)
-100000.1373
4) (regex
(regx {"} "abc"def") => (""" 3 1)
should be
(regex {"} "abc"def") => (""" 3 1)
5) (rest
(rest (rest alist)) => (d e)
should be
(rest (rest aList)) => (d e)
6) (rest
(first (rest "newLISP") => "e"
should be
(first (rest "newLISP")) => "e"
7)
(sequence 0 1 0.2) => (0 0.2 0.4 0.8 1)
should be
(sequence 0 1 0.2) => (0 0.2 0.4 0.6 0.8 1)
8) (sort
(sort '((3 4) (2 1) (1 10)) => ((1 10) (2 1) (3 4))
should be
(sort '((3 4) (2 1) (1 10))) => ((1 10) (2 1) (3 4))
Nigel
re various examples
1) (sort
(sort '((3 4) "hi" 2.8 8 b) => (2.8 8 "hi" b (3 4))
should eb
(sort '((3 4) "hi" 2.8 8 b)) => (2.8 8 "hi" b (3 4))
Nigel
thanks for all the corrections Nigel, a comment to (normal ...)
The 'normal' , 'random' and 'rand' functions will cause different values on each computer executed and on each invocation, so it is natural that the documentation will show something different (but I think you where referring to the precision of the numbers). All rely on a pseudo random generator, which can be initialized using the 'seed' function. Using seed repeatable random sequences can be generated.
Lutz
I did not yet put in the description for the memory limiting commandline switch ( -m N , where N is megabytes of max cell mem permitted), because of all the corrections we are doing on the manual, which I always post online for 7.4.0 users i the new revision.
This way I don't need to update two versions of the manual, and can make corrections available to users not using development versions. New features will always be shortly explained in the CHANGES file.
Lutz
The floor example has an error.
(floor -1.5) => -2
The definition of atan2 is incorrect in the index but correct in the body.
Eddie
Thanks for all of the corrections, revision 6 of 7.4.0 is online at:
http://newlisp.org/download/newlisp_manual.html
http://newlisp.org/download/newlisp_manual.pdf
Lutz
A few typos in v.7.4.8:
in the 'swap' command, "In the second form the charcaters ..." should be "In the second form the characters ..."
in the 'swap' command last sentence before example should end with "... the list or string."
in the 'symbol?' command, "= >" in the first example should be "=>"
thanks for the corrections
Lutz
Sam,
I am preparing some pages for a new section on the http://newlisp.org/news/ site for the 'Tips&Tricks' section.
I wonder if you give me permission to publish your 'roman.lsp' code. It is a nice small piece of newLISP code ideal for that section.
There will also be a small (and hopefully growing) collection of 'Code Snippets' with very short functions like 'allocate', 'cwd' etc, which I collected on this site and from my own stuff.
Lutz
Lutz,
You are more than welcome to use my code. FYI, I wrote it originally in muLISP on an old DOS box. After I rewrote it just recently in newLISP, I read an article about Roman Numerals that suggests that not every numeral I generate is "correct" -- whatever "correct" means in Roman Numeral-land. When I have a little time I will reread the article and perhaps update my code to comply with its recommendations. In the meantime, the code is yours. I hereby testify that the code is my own creation and not the property or invention of anyone else.
There is an error in the 7.5.1 manual under Contexts as Classes
The last line should be
JD-001:balance =>123.45
Eddie
Under the heading
"Hash tables" should be "Hash Tables"
"newLisp" should be "NewLisp"
"very efficient with" should be "very efficiently with"
Eddie
thanks Eddie
Lutz
'newLISP' should always be written with lower case 'new' and uppercase 'LISP', it's a trademark.
On 'Hash tables' I am not sure. I don't capitalize nouns (except for the first one) in any other heading, or should I ?
Lutz
Uh oh.
Quote
For books and other titles, capitalize the first and last word, as well as all the nouns, pronouns, adjectives, verbs and adverbs. Also capitalize any conjunction or preposition that is at least four letters long.
Trademarks are capitalized, but the generic product is not. It is Post-it notes, not Post-it Notes.
Source: http://www.alh.net/newlisp/phpbb/posting.php?mode=reply&t=119
I've always heard that we should always capitalize the first letter of the first word of a sentence, but with trademarks, I'm not sure. Maybe the site above will help.
Eddie[/quote]
Before I had capitalization in all the headings, but then decided, that it looked to heavy, I still do it on the main section titles and perhaps will go one more level deeper.
To Ryon's comment: I didn't mean to be picky on how anybody here on the forum writes the word 'newLISP', but in the manual and website I try to be consistent about it.
Other news: I did some benchmarks of newLISP comparing it to Perl, Python and Guile (a GNU Scheme). The results are positively surprising and I am preparing a webpage for it the coming weekend.
The next development version (7.5.2) which is a precursor to 8.0 later this year also includes arrays! as a new datatype in newLISP. They are also already included in the benchmark, have increased the executable size by less than 2k and are well integrated into the language in general.
Lutz
Hi Lutz,
re: 7.5.2 -- thanks for the arrays! Very nice.
There may be a couple of typos in the 'array' function.
1) The first line of code following "To convert a list back to an array ..." should be (I think) "(set 'aList '((1 2) (3 4))) => ((1 2) (3 4))".
2) Should the line beginning "Lists are modified using the usual ..." read "Arrays are modified using the usual ..."?
3) Following the line beginning "The function array? can be ..."
a) "(array? (list myarray) => nil" should be "(array? (array-list myarray)) => nil"
b) "(array 3 4 (sequence 1 4)))" should be "(set 'myarray (array 3 4 (sequence 1 4)))"
c) "(list myarray) => ((1 2 3 4)(5 6 7 8) (9 10 11 12))" should be "(array-list myarray) ..."
The corresponding examples under 'array-list' and 'array?' are correct.
thankyou Sam, reading this section again and putting in your corrections this (chilly, even here in Florida) Sunday morning, I realized that the whole piece was a mess. This happens when you write/change several times the documentation before you start coding. I also rearranged some paragraphs and took some double stuff out. "rev-1" is in the development directory:
http://newlisp.org/download/development/newlisp_manual.html
Lutz
In manual (7.5.8) info on symbol? should first example be
(set 'x 'y) => y
to fit the text that follows it:
syntax: (symbol? exp)
Expression exp is evaluated and returns true only if the value is a non-primitive symbol and otherwise returns nil. Note that symbol? only evaluates to true on symbols which are not built-in primitives.
example:
(set 'x 'var) => var
(symbol? x) => true
(symbol? (first '(var x y z))) => true
The first statement sets the contents of x to the symbol y. The second statement than checks the contents of x. The last example checks the first element of a list.
The manual has some examples that fail because of the default protection of built-in functions viz:
Built in functions evaluate to themselves:
add => add <B845770D>
(eval (eval add)) => add <B845770D>
(set '+ add) => add <B845770D>
last line fails:
> (set '+ add)
symbol is protected in function set : +
>
The correct version is in the manual down further:
constant has to be used to rename symbols of built-in primitives instead of set, because all built-in function symbols are protected by default against accidental overwriting.
(constant '+ add)
Also incorrect:
example:
;; use underscores on symbols
(define-macro (setq _x _y) (set _x (eval _y)))
(setq x 123) => 123
viz:
> (define-macro (setq _x _y) (set _x (eval _y)))
symbol is protected in function define-macro : (setq _x _y)
>
continued
for the define-macro I guess the way is:
> (define-macro (mysetq _x _y) (set _x (eval _y)))
(lambda-macro (_x _y) (set _x (eval _y)))
> (constant 'setq mysetq)
(lambda-macro (_x _y) (set _x (eval _y)))
>
Thanks for the corrections Nigel. Also, the statement that 'symbol?' would not evaluate to 'true' on symbols of primitives is of course nonsense:
(symbol? 'print) => true ; of course
Lutz
I added 'constant' protection checking to all functions which change the contents of a symbol (called destructive functions).
So now using these functions on symbols protected with 'constant' will cause an error message as described in the manual previously. Look for it in 7.5.9 due in a few days.
Lutz
will it protect against maybe? less direct changes viz:
> (constant 'a '(a B c))
(a B c)
> (replace 'B (eval (quote a)) 'Z)
(a Z c)
> (setq x 'a)
a
> (replace 'Z (eval x) 'w)
(a w c)
> a
(a w c)
>
I guess it would but just checking
It is Ok, 'eval' is the only function returning symbol contents without copying it for usage in macros, but this case handled.
Lutz
The syntax entry for (float in manual still says
str must start with space(s), a number digit or the + or - sign.
when starting with decimal point is now valid viz
> (float ".5")
0.5
Also -.5 is a valid C float viz
#include <stdio.h>
int main () {
double f;
f = -.5;
printf("%gn",f);
}
compiles with gcc
but
> (float ".5")
0.5
> (float "-.5")
nil
> (float "-0.5")
-0.5
>
this will be changed, there is also a new chapter in the docs about syntax of variable names and numbers
Lutz
I had to roll back one of the changes in 7.5.9 and posted a 7.5.10 this morning: http://newlisp.org/download/development/
Lutz
Still fixing constant protection and iteration, protection inside 'dotimes and 'for also rolled back in 7.5.11:
http://newlisp.org/download/development/
Lutz
and more constant 'trauma', version 7.5.12
http://newlisp.org/download/development/
Lutz
ps: I'll try to make this the last one today :)
For the new syntax section can I suggest rather than
"Integers start with a + or - sign followed by a number of digits from 0 to 9. Any other character will makr the end of a number."
the text (or similar):
Integers are one or more digits, optionally preceeded by a + or - sign. Any other character will mark the end of the integer or may be part of the sequence if parsed to a float (see float syntax below).
The last sentence is because
> (parse "1E")
("1" "E")
> (parse "1E1")
("1E1")
>
A request:
could the alphabetic access links
viz:
Functions in alphabetical order
!+-*/<>= A B C D E F G I J L M N O P Q R S T U W X
be placed into the manual so that it is on screen when the manual is first called up (in 'standard' res on 800x600 screen say).
I call up help and see the manual title splash (again) then have to start scrolling around to find the function links.
I suggest maybe placing just under
"newLISPtm
For LINUX, FreeBSD, Mac OSX, Solaris and Win32
Users Manual and Reference v.7.5.12"
and before the
"Copyright © 1991-2004 Lutz Mueller. www.nuevatec.com. All rights reserved."
then it would be immediately visible.
Nigel
The next manual will have a link to itself where it says: "Functions in groups"
You bookmark this and it will position the functions group list with the alphabetical index underneath fitting on smaller screens.
Lutz
I know some people HATE frames, BUT, when they are done properly ...
You could have a frame with the index at the top or the side. The docs that come with Java use this method, although you have to go through trees of information with all the classes they have. An index at the side, sure would make navigating the commands easier.
Eddie
Lutz, if you would like me to make the three frames, frameset, index, and body. I would be glad to do it and e-mail them to you.
Eddie
If this could be done in a way where newlisp_manual.html doesn't need to change, that would be fantastic! So we would have two additional files (1) the manual_frame.html and (2) newlisp_index.html.
Thanks
Lutz
Done!
Eddie
Beautiful, thankyou, it is online here:
http://newlisp.org/download/development/manual_frame.html
Lutz
I like it - thanks
things where misssing in the index and some other small fixes in the manual, now rev-2:
http://newlisp.org/download/development/manual_frame.html
Lutz
Oops! What did I leave out of the index?
Eddie
No problem, it was from version 7.3.x and missed 'source' and the array section.
Lutz
correction : index item for date is:
Time and date functions
date return the current date and time in a string
should say something like:
Time and date functions
date converts a data-value type integer to date and time in a string form
Re documentation of cammandline -
I've noted where doit.lsp is (println "hello there") that:
C:newlisp>newlisp doit.lsp -e "(println 10)"
hello there
10
10
C:newlisp>newlisp -e "(println 10)" doit.lsp
10
10
That is, newlisp will do lisp files if they are before the -e directive
I'll change the man page synopsis section to reflect that.
The way the code works is, taking each option one by one, so you could have lisp files before and after the options. The -p -d options are special in the sense that they hang in the first connection.
Lutz
If options are taken in order could we have one like -e but that doesn't exit on completion but is like a file in that position so you could do (if it was say -l for lisp)
newlisp -l "(println {doing file 1})" file1.lsp -l "(println {doing file 2})" file2.lsp -e "(println {completed, exiting})"
Too much code to for a little feature, which can easily be achieved otherwise, i.e. putting those message in the files themselves or writing a shell script.
Lutz
Fair enough
BTW you can also put several expressions in to the -e :
newlisp -e "(dothis) (load {somefile.lsp}) (dothat) (etc)"
of course 'somefile.lsp' should not and with (exit)
Lutz
Yes, that achieves the same, thanks for pointing it out.
Documentation for the 'normal' function is unusually sparse. That is, I can't find it.
Oops, it is out of the sort order after 'net-sessions' before 'new' ;-), will correct this in 8.0 final, meanwhile:
http://newlisp.org/download/newlisp_manual.html#normal
you can also get it from the index "Floating point math and special functions"
Lutz
looking at the docs of replace shows inconsistencies viz
replace
syntax: (replace exp-key list exp-replacement)
syntax: (replace str-key str-data exp-replacement)
syntax: (replace str-pattern str-text exp-replacement int-option)
syntax: (replace exp list)
...
String replacement without regular expression
If all arguments are strings, replace replaces all occurrences of key-str in str-text with str-replacement and returns the changed string (previous to v.7.2.4 the number of changes). The expression in exp-replacement is evaluated for every replacement.
could be
replace
syntax: (replace exp-key list exp-replacement)
syntax: (replace str-key str-text exp-replacement)
___________________^^^^^^
syntax: (replace str-pattern str-text exp-replacement int-option)
syntax: (replace exp list)
...
String replacement without regular expression
If all arguments are strings, replace replaces all occurrences of str-key in str-text with
_______________________________________________^^^^^^
evaluated exp-replacement and returns the changed string (previous to v.7.2.4 the number
^^^^^^^
of changes). The expression in exp-replacement is evaluated for every replacement.
eg
> (setq n 1)
1
> (replace "aa" "ssaaggaahh" (append "aa" (string (inc 'n))))
"ssaa2ggaa3hh"
>
thanks Nigel, this will be corrected
Lutz
command now in 8.0.2:
(apply date-value '(now)) => 1014834090
should be:
(apply date-value (now)) => 1014834090
Thanks for the correction, rev1 of the docs in HTML and PDF format is online:
http://www.newlisp.org/index.cgi?page=Documentation
Lutz
**
net-listen is a blocking function call and does not return until somebody tries to connect to the listening port.
**
I think ment here is that net-accept is blocking.
**
Shared library module for Linux/BSD versions -->
(import "/usr/lib/newlisp.so" "newlispEvalStr")
(get-string (dllEvalStr "(+ 3 4)")) => "7"
must be
(import "/usr/lib/newlisp.so" "newlispEvalStr")
(get-string (newlispEvalStr "(+ 3 4)")) => "7"
***
thanks for the corrections - lutz
** net select **
little typo ->
In the second syntax net-selectM can check for a list of sockets in list-sockets.
the "M" is too much...
Small typo in float in Users Manual and Reference v.8.0.6:
float
syntax: (float exp [exp-default] )
If the expression in exp evaluates to a number or a string a conversion to an integer is returned.
obviously
"a float is returned"
Nigel
Thanks Nigel, and thanks to anybody else taking the time to read the manual and find places for improvement. The manual should be one of the distinguishing features of newLISP. We are close to release 8.1, which will include a Freshmeat announcement and some advocacy pages on the newlisp.org web site. That will bring a lot of new curious users trying newLISP and reading, browsing the manual.
Lutz
Regarding manual updates:
Perhaps some more context discussion and examples could be there.
I've been fiddling around with how to create and populate one context from another and found that I had difficulty thinking out how some of the symbol
resolution process within a macro occurs. I thought with
(define-macro (makecontext _ctxstr _doc) (begin
(context (symbol (eval _ctxstr)))
(set 'docs _doc)))
that
(makecontext "TEST1" "this is test1")
would create a context TEST1 which it does
but the docs symbol is in MAIN not in TEST1, I presume
because the docs symbol is resolved before context creates
and switches into the context - or am I missing something else?
eg
newLISP v8.0.6 Copyright (c) 2004 Lutz Mueller. All rights reserved.
> (makecontext "TEST1" "this is test1")
"this is test1"
TEST1> (symbols)
()
TEST1> MAIN:docs
"this is test1"
TEST1>
<split your reply into another thread if appropriate>
Nigel
additionally with regard to the next release:
could either
modules like httpd be included in self installing win exe
or
a zip file with just the modules (ie not whole package source) be available in downloads.
Nigel
The context function switches the context for subsequent translation of code. When the docs symbol gets translates the current context is MAIN. By the time the function runs all symbols already have their places in some context. In that macro only a statemens like (load ..) (symbols str) (eval-str ...) etc would be influenced by the previous context statement. It is a very common error to think symbols some how can switch contexts during runtime.
To populate a context from another context use (new OldCtx 'NewCtx)
Regarding modules and example programs, yes perhaps I should include some in the windows distribution, or have an extra archive for it. Not all programs are suited for lading them from the newLISP-tk frontend though. I think I go with an extra archive including both, the examples and modules directory.
Lutz
Her is another way you code your example correctly:
(define (makecontext ctxstr doc)
(set 'temp (context))
(set 'ctx (context (symbol ctxstr)))
(set 'ctx:docs doc)
(context temp))
The example makes use of context variables to hold the old context in temp for switching back ansd the context variable ctx, which can be used to refer to the new created context.
Lutz
Thanks Lutz - works like a charm.
The reason I'm working on it is as a way to provide a lexical closure to simulate a
common lisp defun. I'll let the forum know how it goes.
Nigel
Hi Lutz,
A few corrections for the manual. More later, perhaps.
-- Sam
GENERAL
-- sometimes you write "newlisp" and sometimes "newLISP"
COMMAND LINE OPTIONS AND DIRECTORIES
-- "and load ot if present" should be "and load it if present"
-- "the programtext is evaluated" should be "the program text is evaluated"
-- "newlisp exits otherwise" should be "newlisp exits; otherwise"
STACK SIZE
-- "loading one ore more" should be "loading one or more"
MAXIMUM MEMORY USAGE
-- "is shown as 8,l388,l608" should be "is shown as 8,388,608"
-- "counsumed" should be "consumed"
NEWLISP AS A TCP/IP SERVER (last paragraph)
-- "the the tags" should be "the tags"
-- "used in newLISP-tk a Tcl/Tk front-end" should be "used in newLISP, a Tcl/Tk front-end"
THE INITIALIZATION FILE INIT.LSP
-- "but is can be found" should be "but can be found"
DIRECTORIES ON LINUX, BSD, OSX
-- "POP3 mail etc." should be "POP3 mail, etc."
EVALUATION RULES AND DATA TYPES
-- the sentence beginning "nil are boolean ..." should be "nil and true are boolean data types and evaluate to themselves"
-- (last paragraph in this section) "In LISP built-in functions, which do not ..." should be "In LISP, built-in functions which do not ..."
dont forget the newlisp.so for (sys-info) :-)
net-listen ->
(net-listen 1002 "192.168.1.120" 1002 "udp")
must be ->
(net-listen 1002 "192.168.1.120" "udp")
Thanks to Sam and Norman for manual corrections.
I suggest the following for 8bit OS version numbers:
bit 7 UTF-8 version
bit 6 Library version
bit 5 unused
bit 4 unused
bit 3 OS platform
bit 2 OS platform
bit 1 OS platform
bit 0 OS platform
this will allow for a total of 16 different platforms (6 currently used) with 4 categories of flavors, currently using 2 for UTF-8 and Lib
so for the library versions I will add 64, and for UTF-8 flavor 128 to the OS-platform numbers
Lutz
Yes... good idea to go bit-wise for version numbering...
net-connect
wrong link in "net-send" in think sentence ->
The function call in the example will return a socket number which can be used in a subsequent net-send to send UDP data packets.
Re documentation of rpm use:
Downloading and installing rpm without signature checking gives 2 warnings - probably as expected but as this may be disconcerting to a linux newbie so perhaps some statement that
it is expected or how to avoid it may be worthwhile. (ie how to use the signature)
Nigel
Installed rpm
On installing rpm (to system mdk 9.1) when clicking for help in newlisp-tk I get an error:
The file /usr/share/doc/newlisp/manual_frame.html cannot be found.
similarly for newlisp-tk.html
because the files are in
/usr/share/doc/newlisp-8.0.6
Nigel
PS I see it was a newlisp-tk.config from an earlier time - when I deleted it
and regenerated it with save settings all was well.
Perhaps a hint on that could be in the manual install section.
I don't think you should get a warning messages becuase the rpms are signed? What kind of warning messages do you get? Which version are you installing? Did you get this warnings also in earlier installations?
The documentation is installed in /usr/share/doc/newlisp-x.x.x and in /usr/share/newlisp/doc . newlisp-tk requests the documentation from /usr/share/newlisp/doc not from the versioned directory. Look into your newlisp-tk.config in your home directory. Perhaps you have a wrong spec. in there from an earlier installation?
Lutz
Re install:
selecting the rpm from within Gnome Nautilus and selecting open with software installer
the messages I get are
The following packages have bad signatures:
/home/nigel/newlisp-8.0.6-1mdk.i586.rpm
Do you want to continue installation ?
after saying OK I get
The signature of the package 'newlsip-8.0.6-1mdk.i586.rpm' is not correct.
gpg: Signature made Tue 8 Jun 2004 01:52:27 AM EST using DSA key ID 3F83F9A6
gpg: Can't check signature: public key not found
Do you want to install it anyway?
to which I say OK. I've seen a hint on the r-project site forewarning of such errors from
their package and advising to ignore them. Probably just has to do with the default checking
behaviour when invoked from Nautilus?
Re manual locations
see my edited entry above- I did have an old newlisp-tk.config in my home directory.
Nigel
When I install from the command line with:
rpm -i newlisp-8.0.6-1mdk.i586.rpm
I do not get this warning. I thought gpg verification of rpm packages is optional, perhaps you have to download the rpm-gpg-signature and place it somewhere on your system (on your gpg keyring?) ?. Does this also happen when you install manually?
Lutz
No not with manual install :
[root@p800 nigel]# rpm -e newlisp-8.0.6
[root@p800 nigel]# rpm -i newlisp-8.0.6-1mdk.i586.rpm
[root@p800 nigel]# rpm -e newlisp-8.0.6
[root@p800 nigel]# rpm -iv newlisp-8.0.6-1mdk.i586.rpm
Preparing packages for installation...
newlisp-8.0.6-1mdk
[root@p800 nigel]#
I think it is a general policy of the Mandrake gui rpm installers to check
sigs by default.
I will try setting up sig checking etc to check it on a my system.
Nigel
The only reason I am signing these RPMs is, that somewhere I read that RedHat and Mandrake are only accepting signed RPMs for inclusion in their distributions.
I wonder if all that RPM stuff flowing around on the Internet is signed or not? Should I drop signing? Or should I document the warning messages, where - on the website? (after installation it's too late). Another possibility would be offering both: signed and unsigned versions of RPMs (which means more release/maintenance work :-( )
Lutz
I think the mandrake gui will also warn if a totally unsigned rpm
is selected - probably putting an information statement to the effect that
warnings should be expected if gpg signing is not set up should be on the download directory readme, FAQ (probably needed) Installation section, and website link to rpm download. From memory R-project recommmends manual install but also advises a warning may occur if other methods are used. I think the signing should stay.
Nigel
In the doc of 'net-send-to' of 8.1.0 RC1:
'See also and net-listen with "udp" option.'
The hyperlink to 'net-listen' contains the 'and'.
'For blocking short UDP transactions see and net-receive-udp.'
The hyperlink to 'net-receive-udp' contains the 'and'.
In the doc of 'net-send-from' of 8.1.0 RC1:
'For blocking short UDP transactions see and net-receive-udp.'
The hyperlink to 'net-receive-udp' contains the 'and'.
re gpg signature on rpm
after doing:
[root@p800 nigel]# gpg --import newlisp-8.0.6-signature-pub-key.asc
gpg: key 3F83F9A6: public key "Lutz Mueller (newlisp.org) <lutz@nuevatec.com>" imported
gpg: Total number processed: 1
gpg: imported: 1
[root@p800 nigel]# rpm -e newlisp-8.0.6
[root@p800 nigel]#
when the rpm was selected in nautilus and opened with software installer all
proceeded with any comment regarding gpg signature. The .asc file
was the page http://www.newlisp.org/downloads/newlisp-8.0.6-signature-pub-key
saved as a .asc file from within Mozilla. A brief paragraph on doing the gpg --import
may be worthwhile in the docs.
Nigel
I know the manual clearly states that (log (exp 1)) = 1 and (exp (log 1)) = 1 which means that log in the natural log. However, in every math text I have ever read or used, log x means the common logarithm of x and ln x is the natural logarithm of x. The common logarithm has a base of 10. In other words (pow 10 (log x)) = x given x > 0 and (log (pow 10)) = x.
Could you change log x to ln x and add log x to be the common log to make newLISP more inline with mathematics?
Eddie
I know the manual clearly states that (log (exp 1)) = 1 and (exp (log 1)) = 1 which means that the newLISP log is the natural log. However, in every math text I have ever read or used, log x means the common logarithm of x and ln x is the natural logarithm of x. The common logarithm has a base of 10.
Could you change log x to ln x and add log x to be the common log to make newLISP more inline with mathematics?
Eddie
I know the manual clearly states that (log (exp 1)) = 1 and (exp (log 1)) = 1 which means that the newLISP log is the natural log. However, in every math text I have ever read or used, log x means the common logarithm of x and ln x is the natural logarithm of x. The common logarithm has a base of 10.
Could you change log x to ln x and add log x to be the common log to make newLISP more in line with mathematics?
Eddie
Sorry for the repeats for some reason when I clicked the submit it gave an error. So I copied and pasted the message so that I could try again. But, when I came back it was posted 3 times.
Eddie
There seems to be a difference in programming languages and math books. In all programming languages I checked i.e. in 'C', Java and Perl, log() is the natural logarithm. I adopted the programming way, because most programmers are not mathmaticians. I agree that Math should have the 'say' on this issue, but I think I have to stay inside programming language conventions.
You could do: (constant (global 'ln) log) to get a global natural log for 'ln'
Lutz
Thanks Hans-Peter for the manual corrections, they will be in the next revision.
Thanks Nigel for the "gpg --import" tip I will include all this on an "Installation" page on the newlisp.org web site.
Lutz
Ok. I'd forgotten what the other languages did, I just assumed that they used ln instead of log. I use ln x in mathematics so much It took me by supprise when (ln x) gave an error.
Eddie
Just checking if the boards works again ... yes it does ... thanks Ryon for fixing this.
There is now a link to an updated INSTALL file on the site in the documentation section.
lutz
A suggestion:
instead of
Without using step (1) the RPM package manager will issue warning
message but correctly install the package.
perhaps
Without using step (1) the RPM package manager will issue signature warning
messages to which it is safe to reply OK. The package will correctly install.
Just to make the safety of it explicit.
Nigel
thanks Nigel, I worked it in
lutz
As a freshmeat announcement is palnned which will attract those from
outside the lisp community and new users perhaps a FAQ would be
worth having on the documentation page (or directly in link list).
If I look at a new language/program I often look for a FAQ as it is
usually set up as a quick intro (which could also be delt with on an
"About" page) and highlights if any issues apply.
Most of it could be extracted from the current manual but be in more
question and answer form.
Topics beyound usual Installation etc could be
Relation to other Lisps and Scheme.
Approach to GUI implementation.
Scoping.
CGI Scripting.
Thoughts?
Nigel
For some time I have two pages in the works (1) Why newLISP? and (2) Myths about newLISP. I haven't been very happy with these mostly because of the format, they are written in. I think redoing the info contained in these pages in a FAQ format is the idea I needed. It also gives me the opportunity to merge both pages into one format, thanks Nigel.
Lutz
There is a new version of the 8.1.0 manual in: http://newlisp.org/downloads/development/newlisp_manual.html which has new paragraphs "UDP Communications" in the functions 'net-listen' and 'net-connect'.
Except for updating the Mac OSX library import interface code, there have been no code changes since version 8.1.0-rc2. The plan is, to release 8.1.0 during the coming week. I am still working on an FAQ.
I wonder If Todd from Arizona State U. is reading this to give me a feedback about the new UDP functionality and the updated Mac OSX interface. I have re-tested the library 'import' function on OSX 10.2 - Darwin 6.8, but not used it else.
Lutz
A couple of FAQ typos
uses onlyu the most
Westenr World
Also
(define (double c) (+ x x)) ; defines a new function to double numbers
runs over the dotty margin.
Nice FAQ
Nigel
I agree ... nice FAQ!
(define (double c) (+ x x))
should be
(define (double x) (+ x x))
Thanks Nigel and Sam for your corrections and encouraging comments about the FAQ, it will probably grow over time.
Lutz
Further FAQ typos
"most deal with Common LISP or Scheme, to different older standards of LISP"
? should be
"most deal with Common LISP or Scheme, two different older standards of LISP"
"but for a few applications with big data amounts a random access in lists gets to slow."
? should be
"but for a few applications with big data amounts a random access into lists gets too slow."
newLISP has very powerful scaleable symbol processing.
is?
newLISP has very powerful scalable symbol processing.
you will only need to set uou locale lovale using the newlISP function set-locale.
???
you will only need to set your locale using the newLISP function set-locale.
Nigel
Memory management corrections:
from de-referencing memory objects due to new assignments or change of those memorys object in there contents.
?is
from de-referencing memory objects due to new assignments or change of those memory objects in their contents.
If this un-referenced memory were not taken care of by deletion than newLISP would run out
is?
If this un-referenced memory were not taken care of by deletion then newLISP would run out
stored directly in newLISPs LISP cells
is?
stored directly in newLISP's LISP cells
Matrix function in newLISP will allocate memory for matrix space than perform matrix operations like multiplication or inversion more efficient on those matrices before converting them back to LISP cells and freeing memory space for the matrices.
is?
Matrix functions in newLISP will allocate memory for matrix space then perform matrix operations like multiplication or inversion more efficiently on those matrices before converting them back to LISP cells and freeing memory space from the matrices.
You may not agree with all suggestions.
Nigel
In the v8.1.2 manual section on 'expand', the phrase "expand is when composing lambda expressions:" should be "expand is useful when composing lambda expressions:". Also, it appears that (expand list sym1 sym2) is equivalent to (expand (expand list sym1) sym2) instead of simultaneous expansion as the following illustrates:
> (set 'a 'b 'b 'a)
a
> a
b
> b
a
> (expand '(a b) 'a)
(b b)
> (expand '(a b) 'a 'b)
(a a)
> (expand '(a b) 'b 'a)
(b b)
thanks for the correction and your observation is correct: expand works incrementally:
(set 'a '(b c))
(set 'b 1)
you will get:
(expand '(a b c) 'a 'b) => ((1 c) 1 c)
I will mention this in the manual
Lutz
ps: expand 'reduces' like apply:
(apply expand '((a b c) a b) 2) => ((1 c) 1 c)
Hello Lutz,
In the manual "net-select" the example below is
confusing because net-listen is none-blocking by itself aleady..
==== net-select ====
set 'listen-socket (net-listen 1001))
; wait for connection
(while (not (net-select listen-socket "read" 1000))
(if (net-error) (print (net-error))))
(set 'connection (net-accept listen-socket))
(net-send connection "hello")
Yes, but the 'net-select' checks the listen-socket for the blocking 'net-accept' call. The (net-listen ..) is before the net-select. So is waits in the (while ...) loop until something is ready to accept on the listen-socket.
Perhaps the naming of the socket as 'listen-socket' is confusing? perhaps I just should call it 'socket' ?
Also, just posted 8.1.3 with the Solaris 'get-url' fix
Lutz
In Manual definition of define
"define
syntax: (define (sym-name [sym-param-1 ...]) [body-1])
syntax: (define sym-name exp )
Defines a new function sym-name with optional parameters sym-param-1 .... define is equivalent to assigning a lambda expression to sym-name. When calling a defined function, all arguments are evaluated and assigned to the variables in sym-param-1 ..., then the body-1 ... expression(s) are evaluated.
"
it probably should be
syntax: (define (sym-name [sym-param-1 ...]) [body-1 ...])
as this is consistent with "then the body-1 ... expression(s)"
and with how it works viz.
> (define (sayhello) (setq thehello "hi") "hello2")
(lambda () (setq thehello "hi") "hello2")
> thehello
nil
> (sayhello)
"hello2"
> thehello
"hi"
>
Maybe a comment along the lines that "the return value from a
function is the value of the last evaluated body-1 ... evaluation".
Nigel
Thanks Nigel for the doc corrections.
There is a new Tutorial about importing libraries at: http://www.newlisp.org/index.cgi?page=Compiling_and_Importing_Libraries
Lutz
Hello Lutz,
Just a reminder...
The feature request from sometime ago is not documented.
(It was that i remembered it :-)
Missing is in de manual ->
(command-line nil)
Under linux this will also disable signaling handling display:
user reset - (c)ontinue, e(x)it, (r)eset:
Thanks Norman, I willl update the documentation
Lutz
ps: you know that 8.2.1 is online?
Hi Lutz,
The Framed manual from 8.2.1 does not allow any "searching" anymore
in de newlisp_index.html..?
Norman.
... it never did, what do you mean? But you always can click in the frame and hit Ctrl-F, that still works at least in my Firefox browser. newlisp_index.html did not change except for the new functions added.
If you like to put #function-name into the URL don't use the framed version.
Lutz
Yes i thought it was strange too... Mmm also did not work in my "Links" browser.. Somehow i kicked my machine softly and it oke again... :-) probably the C64 Muzak im running currently via MP3 my machine doesnt like ;-)
Hi lutz,
Minor issue...
Perhpas an enhancement for the folling two function in the manual wil
clarify a little bit more...
file-info
Returns a list of information about the file or directory in str_name. newLISP uses the POSIX system call stat() to get the following information:
-->
Returns a list of information about the file, directory, socket, pipe in str_name. newLISP uses the POSIX system call stat() to get the following information:
file?
Checks for the existence of a file in str-name. Returns true if the file exists and is readable else returns nil.
-->
Checks for the existence of a file, directory, socket, pipe in str-name. Returns true if the file exists and is readable else returns nil.
- sockets and pipes are numbers, file-info takes only a name.
- on file? I just realize the existence is enough, no permissions seem to be required, and I will change that in the docs
thanks
Lutz
Hi Lutz,
I've sent you an email with an attachment. There was a fair bit of context which enlarged the file thereby making it too large to post here.
Lucas.
Hi Lutz ,
I got a PM from you to say that the mail might have been dropped.
So here is a link to the tarball.
http://homepages.paradise.net.nz/~j_gauss/wix/lucas.tgz
** since removed -- Lutz now has it **
This was just a first pass over the docs yielding about 80 possible errors/typos.
Reject or accept each as you deem appropriate.
Lucas.
thanks very much for all the corrections
Lutz
A quick look at the latest manual (8.2.7) indicates that you've fixed the little typos. Thank you very much -- now I can read without tripping ;-)
But the first typo was hard to pick up: nuevatAc used instead of nuevatEc. It occurs as a hypertext link in the last line of the paragraph that comes just before the "Deprecated Functions" section. (I checked the link just in case the company registered both names :-)
I'll do another quick pass over the manual looking for more typos.
Thanks for catching nuevatAc.com ... that's a biggy ... and in the 'license' chapter! how could that happen? I need some kind of spelling support in VI, which is my HTML editor, any suggestions?
Lutz
Only a few this time.
http://homepages.paradise.net.nz/~j_gauss/wix/7diff.txt
some slips may be hard to pick up: lib|d|emo vs lib|b|emo
and semaphore vs sempahore because lines are the same length.
Quote from: "Lutz"... I need some kind of spelling support in VI, which is my HTML editor, any suggestions?Lutz
Maybe VI macros that can use [ai]spell on the current buffer? Or a macro that writes out a tmp file and runs [ai]spell on that and hooks back the result?
2996c2996
< version 8.2.7 espressions in exp-1 ... where not evaluated.
Apart from the slip indicated in the diff, 'where' should be 'were'.
Sorry.
... and still are not evaluated (changed it back) ...
thanks Lucas
Lutz
chapter ->
List processing, flow control and integer arithmetic
tells ->
and pick an argument at random and evaluate it
should be "amb"
Norman.
Thanks, we will have a new development version, which fixes some localization issues, in a short time
Lutz
Oops, my mistake. Have not read all.
; on Linux - suppresses the leading 0
; suppressing leading 0 on Win32 using #
should be near together.
In the manual I have it in one sentence under the table of formatting characters.
In Germany you can just do: (set-locale "") and get: "German_Germany.1252" In the file qa_comma it says (set-locale "german") but that is for Linux and might not work on Win32.
I also realized that on my German Windows installation (my mothers laptop ;-)) the word "Mitteleuropaeische Zeit" for (date (date-value) 0 "%z") was misspelled, they wrote the umlaut 'ae' as an o with a ~ (tilde) on top. So this is a MS problem. But they got it right in "Maerz" doing the ae umlaut as 'a' with two dots on top.
Lutz
Shortcut 'Ap' jumps to 'apply' and not to 'append' which is before apply in alphabetical order.
Thanks for catching this
Lutz
Excuse me for my bad English :( ,
but manual_frame.html may be better, if titles of groups
in newlisp_index.html will be referenses to titles of groups
in section 4 of newlisp_manual.html.
See function UNLESS:
(set 'x 1000) => 1000
(unless (< x 100) "small" "big") => "big"
Why?
'unless' works like 'if not' so:
(set 'x 1000)
(if (< x 100) "small" "big") => "big"
but
(unless (< x 100) "big" "small") => "big"
Lutz
It is error in documentation for newlisp v.8.4.10 of course :)
Yes, the second 'unless' has "big" "small" in the wrong sequence, thanks for catching this.
Lutz
timer
--> After the time in seconds spceified in
signal
--> If 'nil is specified the signal will defaul to
Hi Lutz,
Perhpas a small note in the manual 8.7.2 regarding the Inetd configuration.
Its not nesseary to run "/usr/bin/newlisp -c" as root, its even very dangerous
to do that without removing newlisp functions from the core (see my slimline.lsp trick to do that)...
Still a remark in the manual could state that installing newlisp in Inetd.conf
you better run it as a seperate user.. i.e. ->
net-eval stream tcp nouser:nogroup /usr/bin/newlisp -L -c program
PS: If you still run newlisp as Root from Inetd then the handy thing is that
you dont have to become Root user to do things like "net-ping" with "net-eval" ;-)
Regards, Norman.
Thanks, I will add this
Lutz
I think some more documentation is needed on the requirement for updating init.lsp to catch the changed behaviour of (load between stable 8.6 and stable 8.7 - but I'm not sure of the best way to deliver it.
1)One option is for the the win32 installer package to include the CHANGES file and init.lsp in a version named subdirectory (so it is available as an example but won't clobber a user's init.lsp). Currently I believe this files are only part of the source download but I think they're important enough docs to be in the installer package.
2)Alternatively, a note regarding the change and example of the required change to init.lsp could go in the user manual at (load.
3)Another option would be to have an 'Upgrading from previous version" section in the manual or readme that would address any such issues explicitly.
Possibly a combination of 1) and 3)?
How this topic came about -
I installed stable 8.7.1 on win32 over my previous stable 8.6.0 and newlisp refused to start while complaining that .init.lsp could not be found. It took me a bit of digging and downloading the source to have my attention drawn to the need for adjusting init.lsp for the new behaviour.
CHANGES does say:
8.6.5-7
'ramdomize' looped on listlen 1
'load' now throws an eror when the file cannot be found or returns
the value of the last expression in the file evaluated. Before 'load'
returned 'nil' when file was not found and else 'true'. Note that this
required a change in init.lsp to catch error when trying to load
$HOME/.init.lsp
...
and tne new init.lsp does have
(constant (global '$HOME) (or (env "HOME") (env "USERPROFILE") (env "DOCUMENT_ROOT")))
(if $HOME (catch (load (append $HOME "/.init.lsp")) 'error)
instead of
(constant (global '$HOME) (or (env "HOME") (env "USERPROFILE") (env "DOCUMENT_ROOT")))
(if $HOME (load (append $HOME "/.init.lsp")))
but this information is only in the source tree. The installer does, of course, have the manual which describes the (load behaviour in 8.7 but doesn't draw attention to the implications for init.lsp. By the time you're reading the 8.7 manual the 8.6 manual is overwritten so what has changed between versions is not clear.
Nigel
Next time I will put a link to the http://newlisp.org/downloads/newLISP_87_Release_Notes.html on the http://newlisp.org/index.cgi?page=Downloads page instead of having it only on the http://newlisp.org/index.cgi?Documentation page.
And perhaps inside that release note a more prominent 'upgrade' section at the beginning, where these kind of dangerous situations are documented more explicetly.
Lutz
ps: sorry for the hassles ;)
ps2: added a remark/link on the download page
Hi Lutz,
No hassles really - just had to use my brain.
Perhaps the release notes could be an appendix at the end of the newlisp manual? I'd like them in some form in the installed directory for reference.
Having a current example init.lsp (maybe called init.lsp.example to stop it clobering a user's init.lsp) in the install package should be considered.
Nigel
Function chop absent in "List processing, flow control and integer arithmetic"
in file newlisp_index.html.
Hi Lutz,
In looking at a html2latex.lsp converter I've run newlisp_manual.html through tidy ( http://tidy.sourceforge.net/ ) which can convert to xml (xhtml) which I'm planning to analyse with newlisp xml functions.
Tidy reports this apparent mark up error
line 11958 column 21 - Error: <t> is not recognized!
line 11958 column 21 - Warning: discarding unexpected <t>
line 11958 column 34 - Warning: discarding unexpected </str>
which relates to html:
<p>As an additional <t>str-option</str> <tt>"non-block"</tt> or <tt>"n"</tt> can be specified
I guess it should be "str-option" ?
Nigel
A warning from tidy (that occurs a few times):
line 63 column 1 - Warning: missing <li>
relates to starting an unordered list within and ordered (to get the bullets under a heading) but not making the unordered list an item.
You have:
<h3>Users Manual</h3>
<ol>
<li><a href="#introduction">Introduction</a></li>
<li><a href="#deprecated">Deprecated functions and future changes</a></li>
<li><a href="#options">Command line options, startup and directories</a></li>
<ul>
<li><a href="#stack_size">Stack size</a></li>
<li><a href="#max_mem">Maximum memory usage</a></li>
<li><a href="#prompt">Suppressing the prompt</a></li>
<li><a href="#tcpip_server">newLISP as a TCP/IP server</a></li>
<li><a href="#demon">TCP/IP demon mode</a></li>
<li><a href="#demon_handler">Demon mode with handler function</a></li>
<li><a href="#direct_exec">Direct execution mode</a></li>
<li><a href="#logging">Logging I/O</a></li>
<li><a href="#cmd_help">Command line help summary</a></li>
<li><a href="#initialization">The initialization file <tt>init.lsp</tt></a></li>
<li><a href="#directories_unix">Directories on Linux, BSD, OSX</a></li>
<li><a href="#directories_win32">Directories on Win32i/newLISP-tk</a></li>
</ul>
<li><a href="#shared-lib">Shared library module for Linux/BSD</a></li>
etc.
The idea would be to move the </li> from
<li><a href="#options">Command line options, startup and directories</a></li>
to the end of the <ul></ul> block.
as suggested in
http://www.htmldog.com/guides/htmlbeginner/lists/
Nigel
PS rather than post 'tidy' warnings and their 'fixes' in bits I'll make my next post a summary and a diff. The html with 'fixes' should display the same (browsers can usually guess what was meant and display that) but will be easier to analyse and translate.
Thanks Nigel, for the HTML corrections, fixed all the list-in-list ocurrences in the index section.
Lutz
Hi Lutz,
Here is a diff, corrected version first (quite are few are replacing <p>...<p> with <p>...</p>, closing '<a' with a '>', adding a missed = after href - it includes the </li> stuff you've already addressed:
*** newlisp_manual.html Fri Jan 27 13:50:17 2006
--- c:Program Filesnewlispnewlisp_manual.html Mon Nov 07 23:52:14 2005
***************
*** 36 ****
! <h2>Users Manual and Reference v.8.7.1</h2></center>
--- 36 ----
! <h2>Users Manual and Reference v.8.7.1 <font size="-2"> </font></h2></center>
***************
*** 62 ****
! <li><a href="#options">Command line options, startup and directories</a>
--- 62 ----
! <li><a href="#options">Command line options, startup and directories</a></li>
***************
*** 76 ****
! </ul></li>
--- 76 ----
! </ul>
***************
*** 79 ****
! <li><a href="#expressions">Evaluating newLISP expressions</a>
--- 79 ----
! <li><a href="#expressions">Evaluating newLISP expressions</a></li>
***************
*** 83 ****
! </ul></li>
--- 83 ----
! </ul>
***************
*** 88 ****
! <li><a href="#indexing">Indexing elements of strings, lists and arrays</a>
--- 88 ----
! <li><a href="#indexing">Indexing elements of strings, lists and arrays</a></li>
***************
*** 93 ****
! </ul></li>
--- 93 ----
! </ul>
***************
*** 96 ****
! <li><a href="#return">Early return from functions, loops, blocks</a>
--- 96 ----
! <li><a href="#return">Early return from functions, loops, blocks</a></li>
***************
*** 99,100 ****
! <li><a href="#flow_and_or">Using <tt>and</tt> or <tt>or</tt></a>
! </ul></li>
--- 99,100 ----
! <li><a href="#flow_and_or">Using <tt>and</tt> or <tt>or</tt></a></li>
! </ul>
***************
*** 109,110 ****
! </ul></li>
! <li><a href="#context_objects">Programming with context objects</a>
--- 109,110 ----
! </ul>
! <li><a href="#context_objects">Programming with context objects</a></li>
***************
*** 118 ****
! </ul></li>
--- 118 ----
! </ul>
***************
*** 125 ****
! </ul></li>
--- 125 ----
! </ul>
***************
*** 135 ****
! <li><a href="#functions">Functions in groups</a>
--- 135 ----
! <li><a href="#functions">Functions in groups</a></li>
***************
*** 154 ****
! </ul></li>
--- 154 ----
! </ul>
***************
*** 436 ****
! At first newLISP is started as a server:</p>
--- 436 ----
! At first newLISP is started as a server:<p>
***************
*** 497 ****
! systems newLISP may not be able to reconnect at all times.</p>
--- 497 ----
! systems newLISP may not be able to reconnect at all times.<p>
***************
*** 595 ****
! <tr><td><tt>newlisp -l -p 4711
newlisp -l -d 4711</tt></td>
--- 595 ----
! <tr><td><tt>newlisp -l -p 4711
newlisp -l -d 4711</td>
***************
*** 597 ****
! <tr><td><tt>newlisp -L -p 4711
newlisp -L -d 4711</tt></td>
--- 597 ----
! <tr><td><tt>newlisp -L -p 4711
newlisp -L -d 4711</td>
***************
*** 681 ****
! can be converted using <a href="#get-string">get-string</a>.</p>
--- 681 ----
! can be converted using <a href="#get-string">get-string</a>.<p>
***************
*** 683 ****
! <p>The first example shows how <tt>newlisp.so</tt> is imported from newLISP itself.</p>
--- 683 ----
! <p>The first example shows how <tt>newlisp.so</tt> is imported from newLISP itself.<p>
***************
*** 898 ****
! Floating-point numbers are IEEE 754 64-bit double floats.</p>
--- 898 ----
! Floating-point numbers are IEEE 754 64-bit double floats.<p>
***************
*** 1083 ****
! lambda expressions in newLISP evaluate to themselves.</p>
--- 1083 ----
! lambda expressions in newLISP evaluate to themselves.<p>
***************
*** 1118 ****
! to parameters to work as user-defined, anonymous functions:</p>
--- 1118 ----
! to parameters to work as user-defined, anonymous functions:<p>
***************
*** 1233 ****
! see <a href="#purelisp">purelisp.lsp, the consistency of newLISP</a></p>
--- 1233 ----
! see <a href="#purelisp">purelisp.lsp, the consistency of newLISP</p>
***************
*** 1278 ****
! in turn is an array.</p>
--- 1278 ----
! in turn is an array.<p>
***************
*** 1511 ****
! version of newLISP.</p>
--- 1511 ----
! version of newLISP.</a>
***************
*** 1785 ****
! <a NAME="flow_catch_throw"></a>
--- 1785 ----
! <a NAME="flow_catch_throw"><a>
***************
*** 2090 ****
! symbols in MAIN visible to other contexts use the function <a href="#global">global</a>:</p>
--- 2090 ----
! symbols in MAIN visible to other contexts use the function <a href="#global">global</a>:<p>
***************
*** 2139 ****
! context by explicitly prefixing them with the context symbol:</p>
--- 2139 ----
! context by explicitly prefixing them with the context symbol:<p>
***************
*** 2151 ****
! <p>In this example the built-in function <a href="#new">new</a> is overwritten
--- 2151 ----
! In this example the built-in function <a href="#new">new</a> is overwritten
***************
*** 2258 ****
! <a name="context_rules"></a>
--- 2258 ----
! <a name="context_rules"</a>
***************
*** 2266 ****
! translation symbols are created.</p></li>
--- 2266 ----
! translation symbols are created.</p>
***************
*** 2275 ****
! for forever.</p></li>
--- 2275 ----
! for forever.</p>
***************
*** 2281 ****
! context.</p></li>
--- 2281 ----
! context.</p>
***************
*** 2382 ****
! using the function <a href="#new">new</a>. Note that OO programming purists would
--- 2382 ----
! using the function <a href"#new">new</a>. Note that OO programming purists would
***************
*** 2778 ****
! <tr><td><tt>system.listMethods</tt></td><td>Returns a list of all method names</td></tr>
--- 2778 ----
! <tr><td><tt>system.listMethods<tt></td><td>Returns a list of all method names</td></tr>
***************
*** 2978 ****
! a shape similar to a Latin small <tt>w</tt>.</p>
--- 2978 ----
! a shape similar to a Latin small <tt>w</tt>.<p>
***************
*** 3891 ****
! <a href="#find">find</a> and <a href="#regex">regex</a></td>
--- 3891 ----
! <a href="#find">find</a> and <a href"#regex">regex</a></td>
***************
*** 4847 ****
! <td><a href="#semaphore">semaphore</a></td>
--- 4847 ----
! <td><a href="#semaphore">semaphore<a></td>
***************
*** 6030 ****
! <P>Arrays are modified and accessed using the usual functions for lists:</p>
--- 6030 ----
! <P>Arrays are modified and accessed using the usual functions for lists:<p>
***************
*** 6394 ****
! from each other:</p>
--- 6394 ----
! from each other:<p>
***************
*** 6764 ****
! symbols, which have been protected in their home context.</p>
--- 6764 ----
! symbols, which have been protected in their home context.<p>
***************
*** 7173 ****
! <center><table>
--- 7173 ----
! <center>
***************
*** 7818 ****
! <p>While <tt>do-until</tt> goes through the loop at least once, <a href="#until">until</a>
--- 7818 ----
! <p>While <tt>do-until</tt> goes through the loop at least once, <a href"#until">until</a>
***************
*** 7850 ****
! <p>While <tt>do-until</tt> goes through the loop at least once, <a href="#until">until</a>
--- 7850 ----
! <p>While <tt>do-until</tt> goes through the loop at least once, <a href"#until">until</a>
***************
*** 8943 ****
! <font size=+2>"%w.pf"</font>
--- 8943 ----
! <font size=+2>"%w.pf"
</font>
***************
*** 8950 ****
! <font size=+2>w</font>
--- 8950 ----
! <font size=+2>w
</font>
***************
*** 8958 ****
! <font size=+2>p</font>
--- 8958 ----
! <font size=+2>p
</font>
***************
*** 8968 ****
! <font size=+2>f</font>
--- 8968 ----
! <font size=+2>f
</font>
***************
*** 9910 ****
! <p>See also <a HREF="#first">first</a>, <a HREF="#rest">rest</a> and <a href="#nth">nth</a>.</p>
--- 9910 ----
! <p>See also <a HREF="#first">first</a>, <a HREF="#rest">rest</a> and <a href"#nth">nth</a>.</p>
***************
*** 9948 ****
! an array or the number of characters in a string.</p>
--- 9948 ----
! an array or the number of characters in a string.<p>
***************
*** 10338 ****
! in newLISP evaluate to themselves.</p>
--- 10338 ----
! in newLISP evaluate to themselves.<p>
***************
*** 10994 ****
! fashion. To send data back to the address and port received with <a href="#net-receive-from">
--- 10994 ----
! fashion. To send data back to the address and port received with <a href-"#net-receive-from">
***************
*** 11032 ****
! and receive.</p>
--- 11032 ----
! and receive.<p>
***************
*** 11476 ****
! <p>For blocking short UDP transactions see <a href="#net-send-udp">net-send-udp</a>
--- 11476 ----
! <p>For blocking short UDP transactions see <a href="#net-send-udp>net-send-udp"</a>
***************
*** 11958 ****
! <p>As an additional str-option <tt>"non-block"</tt> or <tt>"n"</tt> can be specified
--- 11958 ----
! <p>As an additional <t>str-option</str> <tt>"non-block"</tt> or <tt>"n"</tt> can be specified
***************
*** 12086 ****
! <tt>ld</tt> the same way internally.</p>
--- 12086 ----
! <tt>ld</tt> the same way internally.<p>
***************
*** 12755 ****
! where directory access rights are configured.</p>
--- 12755 ----
! where directory access rights are configured.<p>
***************
*** 13128 ****
! and is swallowed if it is last character in the stream.</p>
--- 13128 ----
! and is swallowed if it is last character in the stream.<p>
***************
*** 13133 ****
! specified in int-file obtained from a previous <a HREF="#open">open</a> statement.</p>
--- 13133 ----
! specified in int-file obtained from a previous <a HREF="#open">open</a> statement.<p>
***************
*** 13256 ****
! not to be doubled in a regular expression pattern which itself is delimited by quotes.</p>
--- 13256 ----
! not to be doubled in a regular expression pattern which itself is delimited by quotes.<p>
***************
*** 13670 ****
! with the normal syntax rules for symbols, are serialized using a <a href="#symbol">sym</a>
--- 13670 ----
! with the normal syntax rules for symbols, are serialized using a <a href"#symbol">sym</a>
***************
*** 13692 ****
! stored in the system variables <tt>$0</tt> to <tt>$15</tt>.</p>
--- 13692 ----
! stored in the system variables <tt>$0</tt> to <tt>$15</tt>.</tt></p>
***************
*** 14099 ****
! See the file LOCALIZATION in the newLISP source distribution for details.</p>
--- 14099 ----
! See the file LOCALIZATION in the newLISP source distribution for details.<p>
***************
*** 14235 ****
!
--- 14235 ----
!
***************
*** 14281 ****
! The memory address or handle can be assigned to a variable for later reference.</p>
--- 14281 ----
! The memory address or handle can be assigned to a variable for later reference.<p>
***************
*** 15195 ****
! <a NAME="time-of-day"></a>
--- 15195 ----
! <a NAME="time-of-day"</a>
***************
*** 16311 ****
! <a NAME=tcpip_error_codes></a>
--- 16311 ----
! <a NAME=tcpip_error_codes</a>
***************
*** 17585 ****
!
--- 17585 ----
! <p></p>
***************
*** 17821 ****
! <center><p>PREAMBLE</p></center>
--- 17821 ----
! <p><center>PREAMBLE</center></p>
***************
*** 18058 ****
! of promoting the sharing and reuse of software generally.</p>
--- 18058 ----
! of promoting the sharing and reuse of software generally.
***************
*** 18065 ****
! <p>NO WARRANTY</p></center>
--- 18065 ----
! <p>NO WARRANTY</center></p>
I'll put the updated file on my site tonight and post the link.
There are still some issues - mainly that a name= shouldn't have a '?' in it
see http://www.w3.org/TR/html401/types.html#type-name
but the targets 'array?' etc do (maybe change the name= to arrayp etc.
The remaining warnings from 'tidy' are:
line 25 column 1 - Warning: <body> proprietary attribute "leftmargin"
line 329 column 1 - Warning: <table> lacks "summary" attribute
line 592 column 1 - Warning: <table> lacks "summary" attribute
line 933 column 1 - Warning: <table> lacks "summary" attribute
line 1250 column 1 - Warning: <table> lacks "summary" attribute
line 1591 column 1 - Warning: <table> lacks "summary" attribute
line 2777 column 1 - Warning: <table> lacks "summary" attribute
line 2989 column 1 - Warning: <table> lacks "summary" attribute
line 3530 column 1 - Warning: <table> lacks "summary" attribute
line 3661 column 1 - Warning: <table> lacks "summary" attribute
line 4042 column 1 - Warning: <table> lacks "summary" attribute
line 4075 column 1 - Warning: <table> lacks "summary" attribute
line 4300 column 1 - Warning: <table> lacks "summary" attribute
line 4323 column 1 - Warning: <table> lacks "summary" attribute
line 4325 column 1 - Warning: <td> proprietary attribute "witdh"
line 4356 column 1 - Warning: <table> lacks "summary" attribute
line 4394 column 1 - Warning: <table> lacks "summary" attribute
line 4433 column 1 - Warning: <table> lacks "summary" attribute
line 4467 column 1 - Warning: <table> lacks "summary" attribute
line 4697 column 1 - Warning: <table> lacks "summary" attribute
line 4820 column 1 - Warning: <table> lacks "summary" attribute
line 4868 column 1 - Warning: <table> lacks "summary" attribute
line 4916 column 1 - Warning: <table> lacks "summary" attribute
line 5160 column 1 - Warning: <table> lacks "summary" attribute
line 5208 column 1 - Warning: <table> lacks "summary" attribute
line 5310 column 1 - Warning: <table> lacks "summary" attribute
line 5374 column 1 - Warning: <table> lacks "summary" attribute
line 6141 column 1 - Warning: <a> attribute "name" has invalid value "array?"
line 6238 column 1 - Warning: <a> attribute "name" has invalid value "atom?"
line 6912 column 1 - Warning: <a> attribute "name" has invalid value "context?"
line 7173 column 9 - Warning: <table> lacks "summary" attribute
line 7666 column 1 - Warning: <a> attribute "name" has invalid value "directory?"
line 7923 column 1 - Warning: <a> attribute "name" has invalid value "empty?"
line 8493 column 1 - Warning: <a> attribute "name" has invalid value "file?"
line 8737 column 1 - Warning: <a> attribute "name" has invalid value "float?"
line 9703 column 1 - Warning: <a> attribute "name" has invalid value "integer?"
line 9865 column 1 - Warning: <a> attribute "name" has invalid value "lambda?"
line 9914 column 1 - Warning: <a> attribute "name" has invalid value "legal?"
line 10087 column 1 - Warning: <a> attribute "name" has invalid value "list?"
line 10207 column 1 - Warning: <a> attribute "name" has invalid value "macro?"
line 10569 column 1 - Warning: <a> attribute "name" has invalid value "NaN?"
line 11626 column 1 - Warning: <a> attribute "name" has invalid value "nil?"
line 12020 column 1 - Warning: <table> lacks "summary" attribute
line 12463 column 1 - Warning: <a> attribute "name" has invalid value "primitive?"
line 12493 column 1 - Warning: <table> lacks "summary" attribute
line 12885 column 1 - Warning: <a> attribute "name" has invalid value "quote?"
line 14801 column 1 - Warning: <a> attribute "name" has invalid value "string?"
line 14957 column 1 - Warning: <a> attribute "name" has invalid value "symbol?"
line 15460 column 1 - Warning: <a> attribute "name" has invalid value "true?"
line 15564 column 1 - Warning: <table> lacks "summary" attribute
line 16054 column 1 - Warning: <table> lacks "summary" attribute
line 17389 column 1 - Warning: <table> lacks "summary" attribute
line 17804 column 1 - Warning: <table> lacks "summary" attribute
Info: Doctype given is "-//W3C//DTD HTML 4.0 Transitional//EN"
Info: Document content looks like HTML Proprietary
53 warnings, 0 errors were found!
The table summary attribute should be used to describe
the table structure. It is very helpful for people using
non-visual browsers. The scope and headers attributes for
table cells are useful for specifying which headers apply
to each table cell, enabling non-visual browsers to provide
a meaningful context for each cell.
For further advice on how to make your pages accessible
see http://www.w3.org/WAI/GL. You may also want to try
"http://www.cast.org/bobby/" which is a free Web-based
service for checking URLs for accessibility.
You are recommended to use CSS to specify the font and
properties such as its size and color. This will reduce
the size of HTML files and make them easier to maintain
compared with using <FONT> elements.
To learn more about HTML Tidy see http://tidy.sourceforge.net
Please send bug reports to html-tidy@w3.org
HTML and CSS specifications are available from http://www.w3.org/
Lobby your company to join W3C, see http://www.w3.org/Consortium
Nigel
>
Posted
Manual with edits as per diff above:
http://users.cyberone.com.au/nbrown/newlisp/corrected/newlisp_manual.html
xml (xhtml) version created by 'tidy -n -ascii -asxhtml':
http://users.cyberone.com.au/nbrown/newlisp/corrected/newlisp_manual.xml
The diff as in prev post:
http://users.cyberone.com.au/nbrown/newlisp/corrected/diff.txt
tidy errors as in prev post:
http://users.cyberone.com.au/nbrown/newlisp/corrected/xmlerrors.txt
Nigel
Thanks Nigel, I will do the HTML corrections and post a v.8.7.10 with the corrected newlisp_manual.html over the weekend.
The only issue is the predicates ending with a question mark. Help functions rely on things like http://newlisp_manual.html#list? , i.e. the text is highlighted with the mouse, than right-mous-button/menu/help etc..
Perhaps you can just run a script over this before doing the Tex conversion?
Lutz
Here is the 8.7.10 manual incorporating all your corrections except predicate question marks:
http://newlisp.org/downloads/development/Nigel/newlisp_manual.html
Lutz
Thanks Lutz for the edited version.
Regarding list? etc the '?' will keep the manual nonstandard html/xml accepted only by the grace/whim of the browsing application. While it could be massaged on the way to latex I feel finding a correct representation in the html is a solution for the longer term usefulness of the manual.
Perhaps when calling the manual the calling program should perhaps convert any unacceptable characters by substitution according to a translation table eg
? -> _questionmark_ (underscores are valid)
so reference would be name=#list_questionmark_
Nigel
Hi Lutz,
I'm looking into the help linking and noted:
1. doc location setting
Using newlisp 8.7.9 compiled on Suse 10 86_64 I tried the "text is highlighted with the mouse, than right-mous-button/menu/help" and found the context-sensitive help tried to link to /usr/share/newlisp/newlisp_manual.html while the manual is at /usr/share/newlisp/doc/newlisp_manual.html.
Looking at the newlisp-tk.tcl code the default location settings are:
set Ide(HelpFile) "/usr/share/newlisp/newlisp_manual.html"
set Ide(HelpTopic) "/usr/share/newlisp/doc/manual_frame.html"
set Ide(HelpTopic-tk) "/usr/share/newlisp/doc/newlisp-tk.html"
looks like HelpFile location needs the /doc/ added
2. This looks like code for context-sens help in newlisp-tk.tcl:
proc CommandHelp { widget } {
global selectionBuff Ide
catch [set selectionBuff [selection get -displayof $widget ]]
exec $Ide(HelpProgram) $Ide(HelpFile)#$selectionBuff
}
to implement replacing ? with _questionmark_ I used :
proc CommandHelp { widget } {
global selectionBuff Ide
catch [set selectionBuff [selection get -displayof $widget ]]
regsub -all {?} $selectionBuff {_questionmark_} safeselectionBuff
exec $Ide(HelpProgram) "file://$Ide(HelpFile)#$safeselectionBuff" &
}
Notes:
1. I added & to exec line to make it non-blocking
2. Added file:// as without the file:// mozilla (1.7.11) couldn't find the link
3. changed href within newlisp_manual.html to, for example,:
<a NAME="array_questionmark_"></a>
4. changed manual location:
set Ide(HelpFile) "/usr/share/newlisp/doc/newlisp_manual.html"
So all hrefs could be made to meet the standard.
It works!
Nigel
Thanks for fixing the Tcl file Nigel,
I suggest 'p' instead of '_questionmark_'. This is shorter to type for people, who do "newlisp_manual.html#list?" in a brower manually, now they do "newlisp_manual.html#listp".
The 'p' stands for predicate and is a suffix used instead of '?' in some other LISPs. In fact older newLISP HTML manuals used the p.
I will post an updated version of newlisp_manual.html 8.7.10 later.
Lutz
Hi Lutz,
The reasion I suggested _questionmark_ is that listp is a likely name for a user to choose for ther own defined predicate function (especilly if they have an oldLisp background) - I was looking for a substitution that was unlikely to result in a naming clash. For a shorter form how about list_qm etc? Or maybe list__p, ie double underscore, and a manual note that double underscore is best not used in user defined names?
Nigel
I understand, but think they would confuse even more if they chose a 'listp' as a function name, I think I will leave it with the p, it also would leave them the freedom, to do things like:
> (constant 'listp list?)
list? <97D0>
> (listp '(a s d f))
true
>
to redefine to the 'old' ways
Lutz
Fair comment. Having P is more standard.
Nigel
I would like to suggest the need for some clarifying text for the Bayesian Chain example. The example as worked requires the assumption that retesting events are statistically independent. For a worked example see the test paper Q4 parts g) and h) http://math.usask.ca/~bickis/courses/stats246/as203.pdf and the answer at http://math.usask.ca/~bickis/courses/stats246/as203.html .
The confounding issue is that if there is something that makes the test positive in a person that is unrelated to the disease in question but that is always going to be there then retest results can't be meaningfully chained.
Maybe add qualifying lines to the example so it reads:<start-text>
example:
(bayes-query '(test-positive) Data true)
=> (0.3076923077 0.6923076923)
If the testing is modified so that any negative result is interpreted as a negative but a positive result is retested and considered a positive only if the retest is a positive, and assuming that the results of the test and retest are statistically independent we have:
(bayes-query '(test-positive test-positive) Data true)
=> (0.64 0.36)
(bayes-query '(test-positive test-positive test-positive) Data true)
=> (0.8767123288 0.1232876712)
The example shows that a person may have to be tested several times positive to be classified as sick with confidence.
Regarding the requirement of statistical independence, two tests would be nearly independent if the variation in test results were due to variation in the lab that was not related to the patient. However, they would not be independent if there was variation among patients as to how readily the disease could be diagnosed. So if, for example, the test involved measuring some enzyme in the blood, then independence between retests would be expected if the lab quantitation was imprecise. Independence would not be expected if some other blood component unrelated to the disease was present in some individuals and this component interfered with the measurement of the enzyme.
<end-text>
The last paragraph is a straight copy from the exam answers mentioned above - if you were generally happy with the tone of the suggested wording then I could rework the lifted section or seek permission (although technically it is possibly too small a part of the whole to be a copyright violation that would be the 'right thing to do')
I will also use the working as set out in the web reference to check the results.
Nigel
PS another way of explaining the issue is here http://www.merck.com/mrkshared/mmanual/section21/chapter295/295e.jsp
viz
the results of the various tests are often assumed to be conditionally independent (ie, the likelihood of a given test result depends on the gold standard diagnosis alone rather than on the gold standard and results of the other test), and the performance characteristics of the second test can be conditioned only on the gold standard for diagnosis.
I think I've found a small error in the online Manual and Reference.
In 13. Dynamic and lexical scoping, the example
(define (print-vars)
(print "X=" x " Y=" y " Z= " z "n")
is missing a closing parenthesis.
Thanks Ryon, will be corrected,
Lutz
The next example seems to be a little off also:
(define (inc-symbol x y)
(inc x))
(set 'y 200)
(inc-symbol 'y 123) => 246
y => 999 ; y is still 999
Not tryin' to pick on you today!
The more corrections, the better ;)
Lutz
in 8.8.0 manual (webpage) the "Co" index points to 'cons instead of
'Command-line
http://www.newlisp.org/downloads/newlisp_manual.html#cons
May I offer a corrected entry for "real-path" in the manual?
-- Sam
<a NAME="real-path"></a>
<h2><font color="#DD0000">real-path</font></h2>
syntax: (real-path [str-path])
<p>Returns the full path from a relative file path given in str-path.
If path is not given, <tt>"."</tt> (for the current directory) is assumed. </p>
example:
(real-path) => "/usr/home/fred" ; current directory
(real-path "./somefile.txt") => "/usr/home/fred/somefile.txt"
<p>The output length is limited by the OS's maximum allowed path length. If
<tt>real-path</tt> fails, e.g., because of a nonexistent path, <tt>nil</tt> is returned.</p>
Thanks Sam, for correcting this!
Lutz
8.8.9 doc has 3 occurance of 'default functors' where it should be 'default function' (I think)
Quote from: "Hans-Peter"8.8.9 doc has 3 occurance of 'default functors' where it should be 'default function' (I think)
I looked this up in Wikipedia, as I, too, was unsure whether "functors" was correct. My reading led me to believe that "functor" (i.e., a function object) is likely what Lutz is specifying here. We'll see what Lutz says.
m i c h a e l
Quote from: "Hans-Peter"3 occurance of 'default functors' where it should be 'default function'
Just got to the part in the manual you reference and you're right. It should be default function and not default functor. I confused an earlier mention of 'functor' for your corrections. Thanks for pointing these out, Hans-Peter.
m i c h a e l
Both 'function' and 'functor' should be used. Some times the default form of 'foo' for 'foo:foo' is not used as a function but rather as a handle for a data object in those cases it is called the 'default functor'. Use 'default function' only when meaning an executable function. Use 'default functor' when referring to it as a data object.
Lutz
... sometimes the distinction is blurry:
(set 'foo:foo '(a b c d e f g))
(foo 3) => d
in this case of implicit indexing the 'default functor' referring to a data object is used as a function overloaded with 'nth' functionality. So in this case its a little bit of both a 'functor' and a 'function'. But also in this case I would prefer to call it 'functor'.
Lutz
Here are the three places in the manual (before the function reference) where the term "functor" is used:
Like Scheme, newLISP also evaluates the functor part of an expression
Using default functors can simplify the syntax further
;; pass an object by reference with default functor
Based what Lutz has said in the preceding two posts, it seems that all references to functor here should stay as is.
m i c h a e l
Hi Lutz,
Still I found a small issue in the menual of 8.9.0 i could not fix right away...
I picked up my linux machine since 2 months and downloaded 890
opened the manual in FireFox 1.5.0.3 and it seems its unable
to handle the following quotes in HTML...
<span class="arw">⇒</span>
This generated a very strange charater instead of an arrow, changing
the document language or page codig did not work..its odd...
Any idea? because i think <span class="arw">⇒</span> is just
an official quote.. and under windows it works..
PS: I dont use any default language settnigs on my linux machine,
its pure a default rollout...
Norman.
Hi Norman,
Thanks for mentioning this. Seems you became a bit of a guinea pig here ;-)
I now see that ⇒ is not supported for all users. We could try →, », or ›, as these are all more openly adopted by browsers. Lutz's call.
As the manual is part of someone's first impression of newLISP, it can't be the first thing to cause them a problem! This one's mine, again. Sorry Lutz.
m i c h a e l
aaahh im always the little pig that has to deal with the wolf ;-)
The →, », or › all work fine here..
Personaly i prefer the → but the › is more newlisp prompt like..
Norman.
Reading the fine manual - a few minor typos and infelicities.
Section 18: UTF
Quotedate converts date number to string (when used with the third argument)/td>
Syntax section
Quotecontext
A An expression evaluationg to a context or namespace, or a variable symbol holding a context.
Quote
multiply multiplies to matrices
Quotebayes-train counts items in lists for Bayesian or frequentist analysis
Quotelist? checka if expression is a list
macro? checka if a lambda-macro expression
main-args geta command line arguments
Quoteprocess launches a child process, remap standard I/O and standrad error
Function section
amb
QuoteOn of the expressions exp-1 ... n is selected at random and the evaluation result is returned.
append
QuoteIn the first form append works on lists and all list-n ... are appended to form a new lisp. The original lists are unchanged.
append-file
QuoteIf the file does not exists it gets created, in this case append-file works identical to write-file.
array
QuoteArrays in newLISP are used whenever randomly indexing into a big list gets to slow. Only a subset of list functions can be used with arrays. For a more detailed discussion see the chapter about arrays in the userers manual.
QuoteIf not enough initializers are found in the list than the list is repeated until all elements of the array are initialized.
atan
QuoteThe arctangent function of num-radians is calculated an returned.
bayes-query
Quotein the default R.A. Fisher method priors are not not passed on via chaining, but probabilities are compounded using the CHi2 method.
bayes-train
QuoteEach token in D is a content addressable symbol in D containing a list of ferquencies of that token describing how often it occurs in each category. String tokens are prepended with an undersocre _ before converting them to a symbol in D. A total symbol is built containing the totals in each categorie. The symbol total should not be part of symbols passed in a categoy Mi.
QuoteNote that these examples are for demo purposes. In reality trainings sets may contain thousands or millions of words, especially when training natural language models. But small data sets may be used when then the frequency of symbols just describes already known proportions. In this case it may be better to describe the model data set explicitely without the bayes-train function:
define
QuoteThe return value of define is the assigned lambda expression. When calling a user defined function, it's return value is the last expression evaluated in the function body.
Quotelambda or fn expressions may be used by itself as an anonymous function without being defined into a symbol:
QuoteTrying to redefine ant protected symbol will cause an error message.
define-macro
QuoteNew functions can be created which behave just like built-in functions delaying evaluation fo certain parameters or accessing parameters inside list expressions passed as parameters like the built-in functions for flow control.
format:
QuoteIn newLISP format will automatically convert from inter to floating point numbers or from floating point to integer if the format strings requires it:
continued....
Function reference
define-macro
Quote A function with this chracteristic is called the default function.
QuoteA third possibility is too refer to passed parameters using args:
QuoteSee also expand do do variable expansion explicit without evaluation of the expanded expression.
device
Quoteint may also be a the file handle previously obtained from opening a file using open.
dolist
QuoteOpionally a condition for early loop exit may be defined in exp-break.
QuoteAn internal system variable $idx keeps track of the current offset into the list and can be accessed duwing execution of dolist:
do-while
Quote If the evaluation of exp-condition is nil, then the do-while expression is finished, else the the expressions in body get evaluated again.
error-event
QuoteSee also the also the function catch for a different possibility to handle errors and the function throw-error to throw user defined errors.
eval-string
QuoteIf the string contains more then one expressions, the result of the last evaluation is returned.
exec
QuoteIn this example cgiProc could be a cgi processor like Perl or newLISP receiving processing standard input, which would be supplied by a string contained in the variable query.
expand
Quoteexpand reduces it's parameter list similar to apply.
factor
QuoteFor numbers smaller than 2 or for numbers which are to big factor returns nil.
file?
QuoteThe existence of a file does not imply anything about it's read or write permissions.
fn
QuoteThe function is mapped on to a list of arguments usiung map. The seconnd example shows sorting strings by length.
for
QuoteOpionally a condition for early loop exit may be defined in exp-break.
get-string
QuoteWhen giving a string as an argument get-string will take it's address as the argument. Because get-string always breaks off at the first first 00- (zero) character it encounters, it can be used to get a string out of a buffer:
invert
QuoteThe function will throw and error if the matrix cannot be inverted.
irr
QuoteThe next line demonstrates the the relation between irr and npv.
QuoteIn the last example securities where purchased initially for 5000 then for another 2000 3 month later
legal?
QuoteThe token in string is checked if a legal symbol in newLISP source code. Non legal symbols can be created using the sym function, i.e. symbols containing spaces, quotes or other characters not allowed. Non legal symbols are created frequently when using symbols for for associative data access:
letex
QuoteThe function args is used to access the un-evalutuated argument list from define-macro.
load
QuoteBy default files which do not contain context switches with get loaded in to the MAIN context.
member
Quote(member "" "newLISP") ? "newLISP")
name
QuoteIf the expression in bool evaluates to anything else than nil the name of the context, where the symbol belongs to, is returned.
net-connect
Quotenet-select or net-peek can be used to check for incoming commications in a non-blocking fashion.
net-eval
QuoteThe following example illustrates the difference between the default evaluated and raw mode or net-eval:
QuoteThe last to statements reveal that in the default evaluated
QuoteThe example waits for a connections on port 1234,
new-listen
QuoteOptionally an interface IP address or name can be specified in str-ip-addr to listen on a specified address on computers with more then one interface card.
QuoteSee the examples: UDP client and UDP server in the manuals appendix for a working example.
net-ping
QuoteOptionally a timeout parameter to wait for an answer can can be specified in int-timeout in milli seconds.
QuoteIn the seconds syntax net-ping is run in batch-mode.
QuoteUsage of this this parameter can speed up return from the function before the timeout specified.
net-ping
QuoteWhile in broadcast mode net-ping sends out only one packet, which is received by multiple addresses, batch-mode explicitely generates multiple packets, one each for a target address.
... to be continued
I just realised that you might consider this post-release week to be the wrong time to send in a long list of minor corrections! Sorry!
It's just that I didn't have so much time earlier this month, and I spent some of the available time on the Introduction. Also, I gathered that the document was already being edited and didn't want to spend the time going through an older version or having to synchronise editing versions, etc.
With Michael's help we will publish manual revisions frequently as they come available. The next will be this Sunday.
So just keep those manual bugs coming on this thread as they jump into your eyes and Michael will work them in to his convenience, and make sure to always be based on the last version published.
Lutz
I've started so I'll finish:
net-receive
QuoteWhen calling gettime The program connects to port 13 of the server netcom.com.
net-receive-udp
QuoteOn Win32 is more bytes arrive net-receive-udp returns nil.
new
QuoteThe example refers to contexts in variables and merges context foo into into bar.
normal
QuoteIn the first form normal returns a list if int-n of random continuously distributed floating point numbers with a mean of float-mean and a standard deviation of float-stdev.
nth-set
QuoteSets the nth in int-nth element in a list
QuoteAn index out of bound always picks the last or first
QuoteSee also the set-nth, which works like nth-set but returns the whole changed expression instead of the replaced element and is slower when doing replacements in a larger lists or string buffers.
pack
QuoteThe > and < specifiers ca be used to switch
post-url
QuoteAs a last parameter an optional timeout value in milli seconds can be spcified in int-timeout
process
QuoteNot all applications usable interactive in a console are suited for remapping their standard I/O channels.
randomize
QuoteUse seed to seed the generator at for a different starting point.
read-buffer
Quote If no news bytes have been read sym-buffer will contain nil.
read-key
QuoteThe last example an be used to check return sequences from navigation and function keys.
replace
QuoteSetting the the option bit 0x8000 in in-option will force replace to replace only the first occurrence.
QuoteThe last form of replace has only two arguments an expression expr and list This form removes all expr found in list.
save
QuoteWhen saving contexts system variables symbols and all other symbols who's name starts with the $ character are not saved.
semaphore
QuoteWhen making a call to a semaphore with a negative value in int-wait, which would try to decrement the semaphore beyond zero, the function call will block until an other process or thread signals the semaphore with a positive value in int-signal.
QuoteThe -1 is trying to decrement the semaphore, which is not possible because it's value is already zero.
sequence
Quote Generates a sequence of numbers from num-start to num-end and with a optional step size of num-step.
share
QuoteTherefore shared strings should be stored after other shared number fields or reside on there own shared memory page.
QuoteInstead of spcifying a symbol containing the signal handler a function can be spefied directly.
QuoteWhen importing kill make always sure it receives integer numbers for the signal number.
source
QuoteSystem symbols starting with the $ character are only serialized when mentioned explicitely.
sub
QuoteAny floating point calculation with NaNalso returns NaN.
time
QuoteIn first the example 450 milliseconds were spent to evaluate (myprog x y z).
timer
QuoteWith default option 0 real time is measured, 1 mesaures only the time the CPU spends processing in the process or thread owning the timer and 3 is a combination of both, called profiling time.
trace
QuoteIf an expression occurs more then once in a function, always the first occurrence of in the executing function will be highlighted (bracketed).
trace-highlight
QuoteOptionally two more string can be specified for str-header str-footer which control the separator and prompt. There is a maximum of 15 characters for the header and 31 for the footer
QuoteThe first example replace the default "#" with a ">>" and "<<".
unify
QuoteUnbound variables start with an upper-case character to distinguish them from symbols. unify returns nil when the unification process fails and returns a list of variable associations on success or and empty lists when no variables where bound, but the match was still successfull.
QuoteThe above algorithm could be written differently by omitting expand in the definition of prove-rule and pass the environment e as an parameter to the unify and query functions.
unpack
QuoteThe > and < specifiers ca be used to switch between little endian and big endian byte order when packing or unpacking:
utf8
QuoteConverts UCS-4 encoded Unicode of 4 byte integers per character in str into UTF-8 character strings in str to .
write-buffer
QuoteThis method is much faster then using append when concatenating to a string in place.
xml-parse
QuoteWhen tags are translated into symbols using option 8, a context can be specified in sym-context if no context is specified all symbols will be created in the current context.
QuoteNote that using the option number 16 a @ symbol is added to attributes lists.
And that's that. Enough English, time for some newLISP... :-)
Michael - great job already! Sorry to give you some more manual labour. A bit like the Zen monk sweeping the gravel... ;-)
Quote from: "cormullion"Michael - great job already! Sorry to give you some more manual labour. A bit like the Zen monk sweeping the gravel... ;-)
Thanks for all of your manual digging, cormullion. Unfortunately, you may have dug some post holes where the swimming pool is going, since I haven't gotten to those parts yet ;-)
For the 8.9.0 release, Melissa and I edited up to the reference section. I'm just now getting to "Functions in alphabetical order." Maybe as part of the release notes, we can indicate where the editing has left off.
I'll start making the changes cormullion mentioned and keep chipping away at the reference section.
m i c h a e l
cormullion: Is this payback for the "Introduction" side-by-side? ;-)
No! :-) But I have to do something constructive after all the silly mottoes...
(newLISP (not (just (a (parenthetical (language))))))
Quote from: "cormullion"silly mottoes
:-(
Quote from: "cormullion"(newLISP (not (just (a (parenthetical (language))))))
:-)
m i c h a e l
The manual gives this example for 'name':
(set 'ACTX:var 123)
(set 'sym 'ACTX:var)
(string sym) => "ACTX:var"
(name sym) => "var"
(name sym true) => "ACTX"
It doesn't work for me.
newLISP: "Is this really a whole language in 212KB?"*
( * comment from an email I received recently ...)
The example was written before the introductin of sym as a shorter form of symbol. This is how it works using sm as variable name instead od the protected sym:
(set 'ACTX:var 123)
(set 'sm 'ACTX:var)
(string sm) => "ACTX:var"
(name sm) => "var"
(name sm true) => "ACTX"
Lutz
I changed the manual to match what Lutz has written here. Also, I think the use of 'sym in net-receive's example -- the call to net-receive-line's second argument -- should be changed, as well. Is this correct? Otherwise, the rest of the manual checks out.
m i c h a e l
Yes Michael, that is corrrect, thanks
Lutz
Adding a missing intruction for the manual ;-)
Old ->
To exit the newLISP shell on Linux/UNIX, press Ctrl-D; on Win32, type (exit) or Ctrl-C, then the x key.
New ->
To exit the newLISP shell on Linux/UNIX, press Ctrl-D; on Win32, press Ctrl-Z and then Enter or type (exit) or Ctrl-C, then the x key.
Ctrl-Z + enter work to quit the EOF on OS/2 and Windows ;-)
Hi Norman,
Thanks for the change. It now reads:
QuoteTo exit the newLISP shell on Linux/UNIX, press Ctrl-D. On Win32, press Ctrl-Z or type (exit), then Enter; or press Ctrl-C, then the x key.
m i c h a e l
Perhpas the manual should also have a summerised overview on
what a certain OS has or not has on functionality compaired to another
OS.
Like ->
(fork) This mode is not available on Win32.
(reset true) This mode is not available on Win32.
(semaphore int-id) This form is not available on Win32.
...
...
...
Norman.
We will put a small chapter in the first part of the manual. Perhaps a table showing the differences.
Lutz
The Manual 8.9.3 section on format doesn't display some text properly in IExplorer 6.0 (WinXP). It gives tiny text. It seems to be choking on the 'plus1'
Firefox 1.5 handles it OK
problem area is
a href="#string">string</a>
can be used to insure correct data types and avoid error messages.</p>
<p>The format string has the following general format:</p>
<span class='plus1'>"%w.pf"</span>
<p>The percent <tt>%</tt> sign starts a format specification. To display a
percent sign <tt>%</tt> inside a format string double it: <tt>%%</tt></p>
<span class="plus1">w</span>
<p>Width of field. Data is right aligned, else whe...
I don't know anything about span class to suggest a fix. Trying "plus1" and plus1 (no quotes) doesn't help.
Nigel
Hi Nigel,
Thanks for pointing this out. I'm only just now learning the ins and outs of html and css, so this suggestion may not work (also, I don't have IE). I noticed in the style section at the top, the style span.plus1 has double quotes around the +1. I removed the quotes to see if effected the browser I'm using, and it seems fine. If this does not work, maybe another way of saying +1 is possible that would make IE happy.
m i c h a e l
I am puzzled that both Nigel and Michael report the opposite of what I am seeing, for me on the Mac OS X PowerBook its fine with the quotes on the latest FireFox and Safari browsers. Perhaps we should switch back to put the font spec explicitely. The CSS span.plus1 definition is only used once in the manual anyway. All other span tags seem to work fine (most of them for colors).
Lutz
Agreed :-)
m i c h a e l
·
Hi Lutz,·
·
·
Here some remark on the manual, I just pointed them out to make perhpas the difference ·
a lillte bit more clear, not that I have heard anyone complaining so far ;-) But some points·
below might be confusing and can only be discovered when digging into the C code. ·
·
·
·
*** here is what they actualy do, but what is not realy read from the manual ***·
·
(! "argument")·
The '! command determines whether or not a command-processor ("command.com","cmd.exe","sh") is present ·
and executes the argument directly on the command-processor.·
·
(exec "argument" [stdout] )·
The 'exec command pipes the command towards the command-processor and returns the stdout of the executed argument.·
·
·
(process "argument" [in] [out] )·
The 'process command executes an argument and returns directly towards newlisp without waiting, ·
the IO of the executed argument goes through the current defined stdin and stdout or if defined differently through those.·
·
***·
·
·
** Also a small remark on ->·
·
The current description of 'Exec uses the word "process" this could be confusing and intepreted as a C-Process behaviour.·
·
The current 'process function is compaired with '!, thought it is not the same.·
·
·
And perhpas the whole process header should be re-thought?
syntax: (process str-command)
syntax: (process str-command int-pipe-in int-pipe-out [int-win32-option])
syntax: (process str-command int-pipe-in int-pipe-out [int-pipe-error])
You are talking about pipes, but that not true (based on the manual inteprettion that is ;-) it should be device! like this ->
syntax: (process str-command)
syntax: (process str-command device-in device-out [int-win32-option])
syntax: (process str-command device-in device-out [device-error])
Because interaction trough opened files is also possible i.e. with (device .....)
like ->
>(device (open "myfile" "write"))
3
>(process "cmd" 0 3)
Norman.
Actually both 'exec' and 'process' start processes doing a fork() internally. 'exec' uses popen(), which internally uses fork() and 'process' uses fork() explicitly and doing a dup() for the optional pipes specified and stdin and stdout. The difference is that 'exec' also invokes a shell process to handle the comman specified in the 'exec' parameter.
On UNIX you may use file handles instead of pipe handles and sockets will probably work too, but on Win32 I have my doubts, that file handles will work for the pipe parameters in 'process', but I have not tried it. If this really works on Win32, I can include this in the manual.
Lutz
Hi Lutz,
On the semaphore part..
I think the function explenation of "semaphore" could be a little
shorter... Its now quiet a long text to read where its not realy needed.
... explenation on what a semaphore is
... actions and result
... example
And something like this inside the function-text ->
;; init semaphores
(semaphore)
;; assign a semaphore to sid
(set 'sid (semaphore))
;; put sid semaphore in wait state (always -1)
(semaphore sid -1)
;; run sid semaphore previously put in wait (always 1)
(semaphore sid 1)
;; run sid semaphore with X times a skip (backward or forward) on the function
(semaphore sid X)
;; release sid semaphore system wide (always 0)
(semaphore sid 0)
Norman.
I agree, those examples explain it a lot better than the words. I will put in your examples, but leave it up to Michael to shorten the English explaining the different synyaxes when he comes to letter S.
Lutz
Yes he's doing a nice job ;-) quite some work though!
Here is another semphore example... perhpas usefull ->
;;
;; File : sem.lsp
;; Comment : fork with semaphore
;;
;; semaphore actions
(constant 'wait -1 'run 1 'release 0)
(define (shout counter channel)
(while (<= counter 20)
(begin
(write-line (string counter) channel)
(sleep 100)
(semaphore sid wait)
(inc 'counter))))
(define (listen channel)
(setq y "")
(while (!= y "20")
(begin
(println "* " (setq y (read-line channel)))
(sleep 100)
(semaphore sid run))))
;; create io communication pipes
(map set '(in out) (pipe))
;; create a semaphore 'sid
(setq sid (semaphore))
;; init the semaphore to inactive
(semaphore sid)
;; fork the functions
(fork (shout 0 out))
(fork (listen in))
;; release the sid system wide!
(semaphore sid 0)
(exit)
The output is this ->
# newlisp sem.lsp
* 0
* 1
* 2
* 3
* 4
* 5
* 6
* 7
* 8
* 9
* 10
* 11
* 12
* 13
* 14
* 15
* 16
* 17
* 18
* 19
* 20
8.9.8 doc for 'int'
QuoteIf str is invalid, integer returns nil as a default value if not otherwise specified.
should read:
QuoteIf str is invalid, int returns nil as a default value if not otherwise specified.
since integer is deprecated.
Hans-Peter: Thank you for catching this. The manual has been updated with your change.
Norman: I've made a note to include your code changes and intend to add them when we get to the S's. Thanks for the great examples! (I learn best from examples :-)
m i c h a e l
Rev 12 of the newLISP Users Manual and Reference is online:
http://newlisp.org/downloads/newlisp_manual.html
Its includes the changes from 'integer' -> 'int'
Thanks to Michael for edits in the 'N' letter
Lutz
Hello Lutz,
Perhaps a remark on the manual for 'read-file, as from 9.0.0 there are more
options with read-file i think its a good idea to mention these ->
* read-file used from within a script always will execute the file (if its a newlisp file)
that its reading, except when the script that uses the read-file function has
an explicit (exit).
But because read-file now also has "file://" support , there is a way around
the use of an (exit). The NOT use of an (exit) is often done during testing
of a script.
;; this will execute the file when no (exit) is supplied afterwards.
(setq buffer (read-file (main-args 2)))
;; this also will execute the file when no (exit) is supplied afterwards.
(setq buffer (read-file (append "file://" (main-args 2))))
;; this will NOT execute the file!, BUT 1 backdraw, you cant use
;; an append on file:// + filename, that will execute again, as above!
(setq buffer (read-file "file://myscript.lsp"))
PS: the explicit (exit) actualy goes for read-buffer too.
a global workarround on the automatic execute is i.e.the example below
within a script while its executed from the command-line like ->
---script
#!/usr/bin/newlisp
(setq buffer (read-file (rest (chop (main-args 2)))))
---command line
./prog.lsp {readme.lsp}
Norman.
'read-file' does not execute any files ist just reads them, and there is nothing special about the "file://" prefix.
What you arte experiencing is the fact that your first script, because it does not exit, consumes the argument of the second program. For this reason it is always important that a script exits. If a script does not exit than newlisp will try and load arguments which where meant to be consumed by the script.
Let me explain with an example:
#!/usr/bin/newlisp
# this is program: main
(println (main-args))
(set 'buff (append "file://" (main-args 2)))
(exit)
and the second program:
;program: test
(println "hello world")
(exit)
now run it from the shell:
~> ./main test
("/usr/bin/newlisp" "./main" "test")
~>
Only the statement in main is executed showing the contents of main-args. Then the (exit) statement in main keeps newLISP from loading test (which already has been read by main) and it exits.
Now lets delete the exit statement in main and run again:
~> ./main test
("/usr/bin/newlisp" "./main" "test")
hello world
~>
newLISP loads main and executes the statements in main reading the file test, then because the exit in main is missing, newLISP also loads the second file test and executes the (println ...) statement.
You see nothing is executed here by 'read-line'. Never forget to put an (exit) statement at the end of your scripts, or newLISP will try to consume the comand line arguments, which where meant for the script.
Lutz
Thanks Lutz, for the explenation...
Latest manual... some small misplaced "" in net-eval
example:
(net-eval "192.168.1.94" 4711 "(+ 3 4")) → 7
(net-eval "192.168.1.94" 4711 "(+ 3 4") 1) → nil ; timeout to short
(net-eval "192.168.1.94" 4711 "(+ 3 4") 1000) → 7
should be ->
example:
(net-eval "192.168.1.94" 4711 "(+ 3 4)" ) → 7
(net-eval "192.168.1.94" 4711 "(+ 3 4)" 1) → nil ; timeout to short
(net-eval "192.168.1.94" 4711 "(+ 3 4)" 1000) → 7
Remarkt for the manual since the introduction of UNIX local sockets!
Do not use "newlisp -c -d 4177 myfile.lsp is you want to load the file "myfile.lsp"
because this will remove the file "myfile.lsp" and create a local UNIX socket called "myfile.lsp="
Use "newlisp -c myfile.lsp -d 4177" if you want to load a file in deamon mode!
just lost 1/2 gig of data ;-) (long life the backup system "copy-file ;-)
9.2.5 manual section "directory"
(directory "." "\.c") → ("foo.c" "bar.c")
(directory "." {.c}) → ("foo.c" "bar.c")
should be ->
(directory "." ".c$") → ("foo.c" "bar.c")
(directory "." {.c$}) → ("foo.c" "bar.c")