RFC open on newLISP documentation

Started by kazemori, November 28, 2003, 02:34:32 PM

Previous topic - Next topic


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">http://www.mkssoftware.com/docs/man3/atan2.3.asp)

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 http://www.mkssoftware.comd/docs/man3/atan2.3.asp">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.



thanks corrections, Nigel and Eddie



in the changes section on the Web

atan2 takes the arc tangent of Y/X not X/Y.



thanks Eddie



missing from newlist_keywords.txt (win32)




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.



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.



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.



Thanks - I think I will release on Wednesday



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




thanks, will be corrected



A suggestion: nowhere in manual is http://www.newlisp.org">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)


> (% -340 10)



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


      case OP_SUBTRACT:       result -= (long)number; break;

Has the lack of cast broken % ?


PS I found an interesting, although long, discussion of modulo functions in programming languages and mathematics here:



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



> (< "hello" any)


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?



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