Menu

Show posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.

Show posts Menu

Topics - pjot

#1
Whither newLISP? / Benchmarking
July 30, 2009, 02:02:46 AM
newLisp guru's,



What would be the best code, if possible one-liner, to benchmark the performance of newLisp?



Greetings

Peter
#2
The 64bit compilation works fine:


Quote
peter@AsteroidRider:~/installation/newlisp-10.0.0$ make -f makefile_linux64LP64

gcc -Wall -pedantic -Wno-uninitialized -Wno-strict-aliasing -Wno-long-long -c -O2 -g -DLINUX -DNEWLISP64 -DREADLINE newlisp.c

gcc -Wall -pedantic -Wno-uninitialized -Wno-strict-aliasing -Wno-long-long -c -O2 -g -DLINUX -DNEWLISP64 -DREADLINE nl-symbol.c

gcc -Wall -pedantic -Wno-uninitialized -Wno-strict-aliasing -Wno-long-long -c -O2 -g -DLINUX -DNEWLISP64 -DREADLINE nl-math.c

gcc -Wall -pedantic -Wno-uninitialized -Wno-strict-aliasing -Wno-long-long -c -O2 -g -DLINUX -DNEWLISP64 -DREADLINE nl-list.c

gcc -Wall -pedantic -Wno-uninitialized -Wno-strict-aliasing -Wno-long-long -c -O2 -g -DLINUX -DNEWLISP64 -DREADLINE nl-liststr.c

gcc -Wall -pedantic -Wno-uninitialized -Wno-strict-aliasing -Wno-long-long -c -O2 -g -DLINUX -DNEWLISP64 -DREADLINE nl-string.c

gcc -Wall -pedantic -Wno-uninitialized -Wno-strict-aliasing -Wno-long-long -c -O2 -g -DLINUX -DNEWLISP64 -DREADLINE nl-filesys.c

gcc -Wall -pedantic -Wno-uninitialized -Wno-strict-aliasing -Wno-long-long -c -O2 -g -DLINUX -DNEWLISP64 -DREADLINE nl-sock.c

gcc -Wall -pedantic -Wno-uninitialized -Wno-strict-aliasing -Wno-long-long -c -O2 -g -DLINUX -DNEWLISP64 -DREADLINE nl-import.c

gcc -Wall -pedantic -Wno-uninitialized -Wno-strict-aliasing -Wno-long-long -c -O2 -g -DLINUX -DNEWLISP64 -DREADLINE nl-xml.c

gcc -Wall -pedantic -Wno-uninitialized -Wno-strict-aliasing -Wno-long-long -c -O2 -g -DLINUX -DNEWLISP64 -DREADLINE nl-web.c

gcc -Wall -pedantic -Wno-uninitialized -Wno-strict-aliasing -Wno-long-long -c -O2 -g -DLINUX -DNEWLISP64 -DREADLINE nl-matrix.c

gcc -Wall -pedantic -Wno-uninitialized -Wno-strict-aliasing -Wno-long-long -c -O2 -g -DLINUX -DNEWLISP64 -DREADLINE nl-debug.c

gcc -Wall -pedantic -Wno-uninitialized -Wno-strict-aliasing -Wno-long-long -c -O2 -g -DLINUX -DNEWLISP64 -DREADLINE pcre.c

gcc newlisp.o nl-symbol.o nl-math.o nl-list.o nl-liststr.o nl-string.o nl-filesys.o nl-sock.o nl-import.o nl-xml.o nl-web.o nl-matrix.o nl-debug.o pcre.o  -g -lm -ldl -lreadline -lncurses -o newlisp

strip newlisp

peter@AsteroidRider:~/installation/newlisp-10.0.0$ file newlisp

newlisp: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), dynamically linked (uses shared libs), stripped


Now, if I start the default 'opengl-demo.lsp' with newLisp as 64bit executable, we see a blue screen and no teapot.



Obviously, something goes wrong when passing values to the 64bit OpenGL libraries....?



I have changed the program like this:

 (begin
    (set 'GL_LIB "/usr/lib64/libGL.so")
    (set 'GLUT_LIB "/usr/lib64/libglut.so"))


And also verified if the libraries really were 64bit:


Quote
peter@AsteroidRider:~/installation/newlisp-10.0.0/examples$ file /usr/lib64/libGL.so

/usr/lib64/libGL.so: symbolic link to `libGL.so.1'

peter@AsteroidRider:~/installation/newlisp-10.0.0/examples$ file /usr/lib64/libGL.so.1

/usr/lib64/libGL.so.1: symbolic link to `libGL.so.169.09'

peter@AsteroidRider:~/installation/newlisp-10.0.0/examples$ file /usr/lib64/libGL.so.169.09

peter@AsteroidRider:~/installation/newlisp-10.0.0/examples$ file /usr/lib64/libGL.so.169.09

/usr/lib64/libGL.so.169.09: ELF 64-bit LSB shared object, x86-64, version 1 (SYSV), stripped

peter@AsteroidRider:~/installation/newlisp-10.0.0/examples$ file /usr/lib64/libglut.so      

/usr/lib64/libglut.so: symbolic link to `libglut.so.3'

peter@AsteroidRider:~/installation/newlisp-10.0.0/examples$ newlisp opengl-demo.lsp

peter@AsteroidRider:~/installation/newlisp-10.0.0/examples$

peter@AsteroidRider:~/installation/newlisp-10.0.0/examples$ file /usr/lib64/libglut.so.3

/usr/lib64/libglut.so.3: symbolic link to `libglut.so.3.7.1'

peter@AsteroidRider:~/installation/newlisp-10.0.0/examples$ file /usr/lib64/libglut.so.3.7.1

/usr/lib64/libglut.so.3.7.1: ELF 64-bit LSB shared object, x86-64, version 1 (SYSV), stripped


Any idea what may go wrong?



Regards

Peter
#3
Hi Lutz,



It seems the link.lsp does not work?


Quote
[peter:apps]$ cat test.lsp

(println "Hello world")

(exit)

[peter:apps]$

[peter:apps]$ newlisp test.lsp

Hello world

[peter:apps]$ newlisp /usr/share/newlisp/util/link.lsp

newLISP v.10.0.0 on OSX IPv4, execute 'newlisp -h' for more info.



> (link "/usr/bin/newlisp" "bla" "test.lsp")

true

> (exit)

[peter:apps]$

[peter:apps]$ chmod 755 bla

[peter:apps]$ ./bla

newLISP v.10.0.0 on OSX IPv4, execute 'newlisp -h' for more info.



>

>


So after executing the new binary the newLisp prompt appears.... Any idea what may be wrong here...?



Thanks, Peter
#4
newLISP and the O.S. / GTK2 has been ported to MacOS X
October 15, 2008, 11:15:21 AM
All,



Now also the Mac is able to run GTK applications. The GTK port does not require an additional X-server, but completely depends on Quartz.



Website: http://gtk-osx.sourceforge.net/">http://gtk-osx.sourceforge.net/



Further notes can be found here:



http://developer.imendio.com/projects/gtk-macosx">http://developer.imendio.com/projects/gtk-macosx





It opens the possibility for newLisp to run GTK user interfaces on MacOSX also :-)



Regards

Peter
#5
Anything else we might add? / Timeout in (get-url)
June 14, 2008, 06:04:34 AM
Hi,



According to the manual:
Quote
(get-url "http://www.nuevatec.com">http://www.nuevatec.com" 3000)



The optional argument int-timeout can specify a value in milliseconds. If no data is available from the host after the specified timeout, get-url returns the string ERR: timeout. When other error conditions occur, get-url returns a string starting with ERR: and the description of the error.


Now if I run the following using a random IP address:

(get-url "http://11.12.13.16" 50)


...we are waiting forever for an answer. It seems that the timeout does not really expire...? Also for other URL's this seems to be a problem. Am I doing something wrong?



Peter
#6
Gentlemen,



With the upcoming GTK-server 2.2.4 it is now possible to use any kind of GTK widget, also from external libraries like 'gtkmozembed'.



This code implements a minimal Mozilla webbrowser with newLisp.



#!/usr/bin/newlisp
#
# Testing GtkMozEmbed - PvE - april 22, 2008 GPL.
#
# A very minimal webbrowser! Use with GTK-server 2.2.4 or later.
# Change paths to configfile and/or GTK-server where necessary.
#
#-------------------------------------------------------------------

(global 'in 'out)

(set 'cfgfile (open "/etc/gtk-server.cfg" "read"))

(cond ((not cfgfile)(println "No GTK-server configfile found! Exiting...")(exit)))

(while (read-line cfgfile)
    (when (starts-with (current-line) "FUNCTION_NAME")
(set 'func (chop ((parse (current-line) " ") 2)))
(set 'lb (append {(lambda()(setq s "} func {")(dolist (x (args))(setq s (string s " " x)))(write-line s out)(read-line in))}))
(constant (global (sym func)) (eval-string lb))))

(close cfgfile)

(constant (global 'NULL) "NULL")

# ---------------------------------------------------------------
# IMPORTANT!
#
# The script 'run-mozilla.sh' sets some environment
# variables before executing the
# webbrowser binary. The 'gtkembedmoz' widget
# must be linked together with the other
# Mozilla libs using 'LD_LIBRARY_PATH' in order
# to be used successfully.
#
# ---------------------------------------------------------------

(set 'LIB ((exec "dirname `locate libgtkembedmoz.so -n 1`") 0))
(env "LD_LIBRARY_PATH" LIB)

# Setup standalone gtk-server using STDIN
(map set '(in gtkout) (pipe))
(map set '(gtkin out) (pipe))
(process "/usr/bin/gtk-server stdin" gtkin gtkout)

# Define minimal GUI
(gtk_init NULL NULL)
(set 'win (gtk_window_new "0"))
(gtk_window_set_title win {"A minimal webbrowser!"})
(gtk_window_set_position win 1)
(gtk_window_set_default_size win 700 500)
(gtk_window_set_icon_name win "mozilla")

# Set the componentpath of gtkembedmoz also
(gtk_moz_embed_set_comp_path LIB)

# Store a temporary profile in /tmp so my profile will be save
(gtk_moz_embed_set_profile_path "/tmp" "mozilla")

# Create the widget
(set 'moz (gtk_moz_embed_new))
(gtk_container_add win moz)

# Load some URL
(gtk_moz_embed_load_url moz "http://www.newlisp.org")

# Show it all
(gtk_widget_show_all win)

# Mainloop
(do-until (= (gtk_server_callback "wait") win))

# Exit GTK and newLisp
(gtk_server_exit)
(exit)


http://www.gtk-server.org/beta/browser.jpg">



Regards!
#7
newLISP in the real world / (net-close) keeps socket
April 07, 2008, 06:22:49 AM
Hi,



After a TCP connection has been closed, the socket still has a handle. Example with DAYTIME protocol:

newLISP v.9.3.0 on Linux, execute 'newlisp -h' for more info.

> (set 'socket (net-connect "10.227.180.20" 13))
3
> (net-receive socket 'buf 1024)
27
> buf
"07 APR 2008 15:19:12 CESTrn"
> socket
3
> (net-close socket)
true
> socket
3


After a successfull (net-close), should the socket not contain a 'nil'?



Peter
#8
Hi,



In some languages (C, AWK, Scriptbasic) it is possible to add a value to the same variable like this:

value+=5


This actually means 'value = value + 5'.



In newLisp this has to be written as:

(set 'value (+ value 5))


Can we have maybe a new operator like '+=', '-=' and so on, so these type of calculations can be written as  follows:

(set 'value (+= 5))

- or even better:

(+= 'value 5)


What do you think?



Peter
#9
Hi,



Pending the issue of the http://www.alh.net/newlisp/phpbb/viewtopic.php?t=2243">previous post, I tried to solve it in a different way.



Similar to other core Unix programs, I tried to use a pipe to the STDIN of newLisp, but it fails. Below taken from the command prompt:
Quote
peter[~]$ echo "help" | awk '{print}'

help

peter[~]$ echo "help" | sed {}

help

peter[~]$ echo "help" | cut -f1

help

peter[~]$ echo "help" | newlisp -e "(println)"



nil


So how can I accept stdin to the newLisp binary and perform a task with it?



If newLisp wants to integrate in a Unix environment then it would be great if this works!



Thanks
#10
Hi,



With Kornshell, it is easy to embed AWK and passing variables and vaules to the AWK program. It works as follows:

STRING="Hello1 Hello2 Hello3"
awk -v VAR="$STRING" 'BEGIN {print VAR}'


This is a stupid example of course, but the idea is that you are able to pass values from a main program to a piece of AWK code.



Now, I want to do the same thing with newLisp. I have a main program in Kornshell and I want to pass some strings to a piece of newLisp code.



This line gives the same result as the AWK example just mentioned:

newlisp -e "(silent (println "Hello1 Hello2 Hello3"))"


The question is, how do I pass the variable 'STRING' to the newlisp code? I thought of constructing the newLisp code as a string in advance, but it does not work:

NEWLISP_LINE='(println "${STRING}")(exit)'
newlisp -e $NEWLISP_LINE


The result is
Quote
missing parenthesis : "...(println                            "


Also other constructions do not work:

NEWLISP_LINE="(println $STRING)(exit)"
NEWLISP_LINE='(println $STRING)(exit)'


They all deliver the same error.



The workaround is to rewrite the main Kornshell program completely to newLisp, but then I have to convert over a 2000 lines of code. :-(



So, how can I embed newLisp code within a larger (shell) program, and pass values and variables to these codesnippets from the main program?



Thanks

Peter
#11
newLISP in the real world / (xml-parse) segfault
February 29, 2008, 12:29:34 PM
Quote
peter[~]$ newlisp

newLISP v.9.3.2 on Linux IPv4, execute 'newlisp -h' for more info.



> (set 'xml "<xml><DATABASE><This><FRUIT><NAME>apple</NAME><COLOR>red</COLOR><PRICE>0.80</PRICE></FRUIT></DATABASE>")

"<xml><DATABASE><This><FRUIT><NAME>apple</NAME><COLOR>red</COLOR><PRICE>0.80</PRICE></FRUIT></DATABASE>"

> (xml-parse xml (+ 1 2 4 8 16) A)

Segmentation error


So when using a 'A' (or some other letter or number) instead of a symname for a context there is a segfault.



This is the plain 32-bit newlisp, by the way :-)



Peter
#12
newLISP in the real world / Nth behaviour?
January 23, 2008, 12:31:11 PM

peter@AsteroidRider:~$ newlisp
newLISP v.9.2.17 on Linux, execute 'newlisp -h' for more info.

> (sys-info)
(362 268435456 358 1 0 140733193390080 9217 1)
> (nth 6 (sys-info))
140733193397249
> (nth 7 (sys-info))
140733193388033
> (nth 8 (sys-info))

list index out of bounds
> (nth 5 (sys-info))
140733193390080


Why is this happening? An (nth 6 (sys-info)) used to return the version number of newLisp (here 9217).



Peter
#13
newLISP Graphics & Sound / NEWLISPDIR questions
January 15, 2008, 08:58:09 AM
Hi,



If I set the variable NEWLISPDIR manually in a DOS prompt, newLisp does not seem to get the new value.


Quote
Microsoft Windows XP [Version 5.1.2600]

(C) Copyright 1985-2001 Microsoft Corp.



C:Documents and Settingspeter>cd



C:>cd newlisp



C:newlisp>newlisp

newLISP v.9.2.11 on Win32, execute 'newlisp -h' for more info.



> (env "NEWLISPDIR")

"C:\Program Files/newlisp"

> (exit)



C:newlisp>set NEWLISPDIR="C:\newlisp"



C:newlisp>set NEWLISPDIR

NEWLISPDIR="C:\newlisp"



C:newlisp>newlisp

newLISP v.9.2.11 on Win32, execute 'newlisp -h' for more info.



> (env "NEWLISPDIR")

"C:\Program Files/newlisp"

>




It seems newLisp always prints "C:Program Filesnewlisp". But in Windows I like to install newLisp in "C:newlisp".



Second question: will there be some description in the newLisp manual about this important environment variable...?



Regards

Peter
#14
Hi,



Here I am again with an annoying question :-)



First a nice quote.


Quote
peter[~]$ newlisp

newLISP v.9.2.11 on Linux, execute 'newlisp -h' for more info.



> (set 'example '("a" "b" "c" "d" "e"))

("a" "b" "c" "d" "e")

>

> (length example)

5

> (nth 4 example)

"e"

> (nth 5 example)

"e"

> (nth 6 example)

"e"

> (nth 0 example)

"a"

> (nth -1 example)

"e"

> (nth -2 example)

"d"


This is all according to documentation, so far so good. I am not using implicit indexing here, since I want to illustrate my question with a clear example.



My question relates to the logic of indexing. If the index grows, and gets larger than the the amount of elements, the last element is returned. No matter what number higher than the amount of elements, the last element is returned.



However, if the index gets smaller, even smaller than 0, not the first element is returned, but the indexing wraps around and all of a sudden returns the last element of the list again.



In my point of view it would be more consequent to return the first element of a list if the index gets smaller than 0. Or the other way around: if the index gets higher than the total amount of elements in a list, also wrap around to return the first element (better idea).



So in a fake session:
Quote
peter[~]$ newlisp

newLISP v.9.2.11 on Linux, execute 'newlisp -h' for more info.



> (set 'example '("a" "b" "c" "d" "e"))

("a" "b" "c" "d" "e")

>

> (length example)

5

> (nth 4 example)

"e"

> (nth 5 example)

"a"

> (nth 6 example)

"b"

> (nth 7 example)

"c"

> (nth 0 example)

"a"

> (nth -1 example)

"e"

> (nth -2 example)

"d"

> (nth -3 example)

"c"




What is the reason for the current logic of list indexing? To me it makes kind of an inconsistent impression :-) ...but probably I am missing a point...????



Cheers

Peter
#15
newLISP Graphics & Sound / Java path issue (Unix/Linux)
December 28, 2007, 03:56:09 AM
Hi,



After upgrading my Linux system(s) to a newer release, the GUIserver did not run anymore.



After some troubleshooting it appears that the file '/usr/share/newlisp/guiserver.lsp' looks for a Java binary in '/usr/bin'.



However, on Slackware-like systems (also Zenwalk) the java binary resides in '/usr/lib/java/bin'.



Starting a GUI program now returns "Could not connect to guiserver".



Porbably the hardcoded path for the Java binary should be changed to a more flexible mechanism?



What we suggest is using the environment variable "JAVA_HOME". This variable should point to the installation directory of Java on a Unix/Linux system. On my system it points to '/usr/lib/java'. The Java binary then can be found in the 'bin' subdirectory, e.g. $JAVA_HOME/bin.



This solution should work for all Unix/BSD/Linux systems.



Regards

Peter
#16
newLISP and the O.S. / Slashes
December 20, 2007, 02:08:34 AM
Hi,



In the release notes of 9.2.10 I see the following:


Quote

On Win32 function 'directory?' now will accept training slahes '' or '/'

before it would always fails on trailing slashes


If I test it:


Quote
c:Scripts>newlisp

newLISP v.9.2.10 on Win32, execute 'newlisp -h' for more info.



> (directory? "c:\temp")

true

> (directory? "c:\temp\")

true

> (directory? "c:\")

nil

> (directory? "c:")



string token too long : "c:")rn"

> (directory? "c:\")

nil



>


So the 'root' directory of the C-drive is still not accepting the slash backward...? Any reason for this?



Also the documentation for (directory?) has not been adjusted (yet).



Peter
#17
Anything else we might add? / (ends-with) regex issue
December 19, 2007, 11:31:17 AM
Hi,



The other day I was stumbling into this problem (and newdep: yes I've read the manual now :-) )


Quote
newLISP v.9.2.10 on Linux, execute 'newlisp -h' for more info.



> (set 'S "abc.def.ghi")

"abc.def.ghi"

> (ends-with S "ghi" 1)

true

> (ends-with S "def|ghi" 1)

nil

>


As is visible from above, I try to find out if a string "ends with" a 'def' or a 'ghi'. I would expect true as a result, but it seems not to be the case.



This however is working:


Quote
> (ends-with S "def$|ghi$" 1)

true


But isn't the dollarsign a little bit superfluous here? I mean, what is the meaning of 'ends-with'...?



Peter
#18
Anything else we might add? / (directory?) inconsistency
December 14, 2007, 05:52:24 AM
Hi,



In Linux, this code works:
Quote
newLISP v.9.2.0 on Linux, execute 'newlisp -h' for more info.



> (directory? "/tmp")

true

> (directory? "/tmp/")

true




However, in Win32 we see this:
Quote
newLISP v.9.2.0 on Win32, execute 'newlisp -h' for more info.



> (directory? "C:\Temp")

true

> (directory? "C:\Temp\")

nil




Regards

Peter
#19
Hi,



It seems that this code is not working:


Quote
> (delete-file "somedir/*.*")

nil


Why not? Do I first have to setup a list of files in that directory, and then walk through that list to delete them one-by-one...? :-(



Regards

Peter
#20
Hi,



It seems the examples in the manual (9.0.18) are gone? However, in several sections, like the UDP communications, there are still references to the 'client' and 'server' examples, and in the SEMAPHORE section there is still a reference to the 'prodcons' example.



Peter