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

#41
I want to stash some code in red-black trees.  I'd like it to automatically execute when I access it.



For instance,



(foo "bar" '(println "hi"))



When I do



(foo "bar")



I want the result to be



true



And also have the side effecting of printing "hi" to the console.



What is the best way to go about doing this?
#42
Has anyone else used the newlisp http mode to host several domains at once?  Is the appropriate method to modify the command-prompt?  Is an environment variable already set, or should I parse stdin to find out what the domain is?  How much parsing does newlisp do in http mode?  Just the first line of PUT/GET/etc?  And what variables does newlisp use to do its evaluating/processing afterward.



For instance, I want to hook in a handler to generate a directory listing.  Is there a callback I can set?  Or should I just "exit" once I'm done handling my URL, on the assumption that newlisp forks for every connection?  What if I want to futz with the headers a bit, but otherwise let newlisp do its thing of reading a file and blasting it out over the socket?  Should I do that in newlisp?  Do I lose much efficiency in read/write by doing that?



I host quite a few domains; I'm currently migrating them all over to the newlisp webserver.



I understand about setting the Status line, then having complete control over the output.  Guess I'll have to make utility functions to do things that newlisp does automatically under the hood.



Ted
#43
Is there any one of those all-you-can-eat web hosts like hostmonster that gives you unlimited bandwidth for $8/month, but also supports newLISP?



Ted
#44
Lutz has done a good job of making Debian packages available.



Now there is a Debian and Ubuntu repository available.  Once you set it up, you will get your newlisp upgrades automatically and the package management system will take care of getting the right deb file for your architecture.



The i386 and amd64 architectures are supported on Debian lenny (stable), Debian squeeze (testing), and Ubuntu karmic.



For complete info and instructions, go here:



http://dpkg.reactor-core.org/">http://dpkg.reactor-core.org/



Thank you Lutz for finding a bug in my packaging earlier on; it is all fixed and working.



I appreciate that there was an apt repository for newlisp earlier on; I hope this repository will be more comprehensive and bring newLISP to a broader spectrum of Debian distributions.  More specifically, I have eliminated the problem that made debian package management always consider newlisp packages to be coming from an "untrusted source".



Ted

Former member of Debian
#45
newLISP newS / Bug in GMP module?
December 14, 2009, 02:36:14 AM
For the last few releases, I've gotten segmentation faults on 64 bit Ubuntu and 64 bit OpenBSD.  Haven't tested on 32 bit, no hardware to test on.  Am using libgmp version 3.5.0



The bug is a segfault whenever I try to factor a non-prime number using GMP.



To duplicate the bug, do this:



(module "gmp.lsp")
(GMP:factor "4")


I narrowed the segfault down to this line of code in the push-factor function in the gmp module:



(set 'f (get-string (__gmpz_get_str rops 10 f)))
#46
The select function lets me pick various values from a list to form a new list.



Could we have the corollary as a built in?  deselect would return the whole list but WITHOUT the listed items.



(setq a '(1 2 3 4 5))

(select a 1 2 3) => (2 3 4)
(deselect a 1 2 3) => (1 5)
#47
What is the fastest/cleanest way to do this in newlisp?



((a b c) (1 2 3)) => ((a 1) (b 2) (c 3))


I'd like to convert some parallel lists to association lists. I know I can do it with a simple doloop.  I just have a nagging feeling that there has to be a simpler, more built-in way to do it.



Also, I find it annoying that newlisp symbols aren't required to be separated by brackets or spaces.  I'd like to do this:



(1+ x)
(1- x)


And I chose those forms because I understand that implicit indexing makes the following two forms impossible:



(-1 x)
(+1 x)


Ted
#48
Whither newLISP? / Request for a $this variable
October 23, 2009, 12:01:51 PM
Lutz, $0-$15 are useful.  I just learnt about $idx today.  And $it is also useful.  Can you please add $this to refer to the current context?



One idiom I use a lot is to make an object the way I want it, then use (new) to duplicate it.  Having a $this variable will make it easier to call methods between contexts which then respond asynchronously by invoking another method in the calling context.
#49
I tried doing two queries in a row and notice that the results of the old query were prepended to the results of the second query.  It was a simple typo.  Here is a patch generated by git:



modules/mysql.lsp |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/modules/mysql.lsp b/modules/mysql.lsp
index aca5c9a..c23fb6e 100644
--- a/modules/mysql.lsp
+++ b/modules/mysql.lsp
@@ -91,6 +91,7 @@
 
 (set 'files '(
        "/usr/local/lib/libmysqlclient.so.19.0" ; OpenBSD 4.4
+       "/usr/lib/libmysqlclient.so.15" ; Ubuntu Jaunty
        "/usr/lib/libmysqlclient.so" ; Linux, UNIX
        "/usr/local/mysql/lib/libmysqlclient.so" ; Linux, UNIX
        "/usr/local/mysql/lib/libmysqlclient.dylib" ; MacOS X
@@ -219,7 +220,7 @@
 ;; The whole result set from the query is returned at once as a list of row lists.
 
 (define (fetch-all , (all '()))
-  (dotimes (x (num-rows)) (push (fetch-row) alli -1)))
+  (dotimes (x (num-rows)) (push (fetch-row) all -1)))
 
 ;; @syntax (MySQL:databases)
 ;; @return A list of databases.


I commited this patch to a branch named mysql.  You can use it like this:



git clone http://reactor-core.org/newlisp/.git
cd newlisp
git merge mysql


At that point you can compile and go just as when using the regular source tarball.



Now you have the repository downloaded, you can use the following command to pull in any new changes and bring it up to date, all without losing any of the development history or any of your local changes:



git pull origin
#50
I took all the previous open source releases of newlisp and imported them into a git repository.



The repository is up to date, including version 10.1.4



To fetch the repository, run this command:



git clone http://reactor-core.org/newlisp/.git


This will download the repository (currently 13 megs) and create a "newlisp" directory with the source code all checked out and ready to go.



If this should be hosted by newlisp.org instead, I'd be happy to help in any way requested.



Having this repository gives you complete history.



If you want to see when a particular line of a particular file was changed, you use the git-blame command:



git blame nl-filesys.c


For each line in the file, you get the commit id that last changed that line.



This also lets you quickly and easily compare differences between versions, and prepare patches to submit to Lutz.  Lutz doesn't like receiving patches at the present time, but perhaps if he starts using a version control system like git, he will appreciate them. :-)



Did I mention git is a distributed version control system, easily letting Lutz merge in changes from other developers, should others take an interest and start developing features on side branches?
#51
I have updated the configure file to work with the --enable-debug and --enable-static options



Static compiling is very useful for running newLISP inside a chroot jail, such as the OpenBSD webserver runs in.  This makes it possible to use newLISP for handling CGI's without having to duplicate system libraries and linkers inside the jail.



Here are the sizes of the resulting binaries on my 64bit OpenBSD system:



dynamic,nodebug: 258k

dynamic,withdebug: 596k

static,nodebug: 761k

static,withdebug: 3.2M



The defaults for the static and debug options is OFF, but they are now there if you ever need them.  On AIX this might not work, I don't know what options xlc takes, same with other Unices with their own compilers, but as data comes in I'll modify the script to accomodate based on the OSTYPE.



Updated patch has the same name, in the same place.  Wish there was somewhere I could upload it.



Also as before, the patch is applied against a pristine 10.0.8 tree.
#52
This build system does not in any way alter the current build system, it is available if you want to use it.  For Mac, Linux, and BSD users I believe it already represents an improvement; it automatically detects if your system is 64 bits, and compiles accordingly.



It does not use autoconf, autotools, automake, or any other of those GNU tools,  But it takes some of the good ideas and conventions from them, as explained by Nelson Beebe of the maths department of the University of Utah.  This should make it even easier to package newLISP for the different Unix and POSIX variants.



To use it, simply download this patch and apply it: http://reactor-core.org/downloads/newlisp-configure.patch">http://reactor-core.org/downloads/newli ... gure.patch">http://reactor-core.org/downloads/newlisp-configure.patch



Then type ./configure.  To use this system, you can't omit this step.  Configure now takes the following options:



--enable-readline
--disable--readline
--enable-utf8
--disable-utf8
--enable-ipv6
--disable-ipv6


Also, you can pass in the CC, CFLAGS, LIBS, and OBJS variables from your shell environment and they will be preserved and respected.  Command line options will override them though, as is standard practice.



The script defaults to turning on all three knobs; UTF8, readline, and IPv6.  The patch also fixes a syntax error in the IPv6 code.



Configure now generates two files, config.h, and makefile_configure



On my OpenBSD system, the config.h looks like this:



/* This platform is using the LP64 memory model */
#define NEWLISP64

/* Operating System Type */
#define _BSD

/* UTF8 support was chosen */
#define SUPPORT_UTF8

/* READLINE support was chosen */
#define READLINE

/* IPv6 support was chosen */
#define IPV6

/* EOF */


Having the config.h file makes the Makefile smaller and easier to understand, because things aren't being defined on the commandline.



Here is what the resulting makefile_configure looks like:



CC = cc
CFLAGS = -Wall -Wno-uninitialized -fno-strict-aliasing -DNEWCONFIG -O2 -c
LIBS = -lm -lreadline -lncurses
OBJS = 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 nl-utf8.o

default: $(OBJS)
        $(CC) $(OBJS) $(LIBS) -o newlisp
        strip newlisp

.c.o:
        $(CC) $(CFLAGS) $<

$(OBJS): primes.h protos.h makefile_configure


You notice there is one #define being defined on the commandline there, -DNEWCONFIG.  This was necessary to make config.h only be #included when using this new config system, otherwise it would collide with the existing build system.



To compile newlisp, you type this command:



./configure
make -f makefile_configure
make install


I am posting it here so it can get some broader testing before I complete it and send it to Lutz.  It should already work out of the box for Linux, Mac, and BSD users.  For everyone else, it should be fairly simple to update it to support your platform, in which case I hope you'd show me your modifications to make it work.



Also, by having all the knobs turned on, hopefully we can get IPv6 more broadly tested.  And on those few platforms without readline, the --disable-readline options to configure will turn it off.



This system should free people from having to edit makefiles to tweak them for their system.



Any comments welcome.
#53
I notice that in the Solaris makefiles, both SOLARIS and SPARC are defined.  SPARC is only used in ns-filesys.c, and I see no reason why SOLARIS wouldn't do equally as well.  Is there something hardware specific going on?



Ted
#54
Here is a test that could be incorporated into the configure script of newLISP to automaticaly decide whether to use the -DNEWLISP64 define.



Maybe I should just make the patch.   But here is the code.



Would it be fair to say that we ONLY support the LP64 and the ILP32 memory models?



#include <stdio>

int
main(int argc, char** argv) {
short sc = sizeof(char) * 8;
short ss = sizeof(short) * 8;
short si = sizeof(int) * 8;
short sl = sizeof(long) * 8;
short sp = sizeof(void*) * 8;

if (si == 32 && sl == 64 && sp == 64) { printf("LP64n"); return 0; }
if (si == 64 && sl == 64 && sp == 64) { printf("ILP64n"); return 0; }
if (si == 32 && sl == 32 && sp == 64) { printf("LLP64n"); return 0; }
if (si == 32 && sl == 32 && sp == 32) { printf("ILP32n"); return 0; }
if (si == 16 && sl == 32 && sp == 32) { printf("LP32n"); return 0; }
}
#55
Whither newLISP? / begin vs. do
May 28, 2009, 10:45:50 PM
I was just reading the wikipedia article on REXX tonight, after reading their article on COBOL.  I was struck with how elegant REXX is.  Not as LISP, mind you, but it had a couple nice things.  I believe the (begin... construct came from the BASIC language.  Right?  In REXX, "do" serves the same role.  If it isn't a reserved word, (I believe it isn't) I will start doing (constant 'do begin) and starting using (do...) in my code instead of (begin...)



Lutz, thanks for incorporating those $prefix type changes!  In the next couple months I will try to implement an OpenBSD "port", or "package", of newlisp.  There used to be one, I don't know why it was dumped.



Ted
#56
Hi guys.  In my spare time (which is little) I'm developing a course to develop newbies into powerhouse computer programmers.  Of course, it is LISP (and newLISP) centric.



If anyone would care to look and make suggestions, I'd like to hear them.



The actual course outline isn't finished yet, but the set of core texts is mostly settled.



You can see it here:



http://reactor-core.org/programmer-syllabus.html">http://reactor-core.org/programmer-syllabus.html
#57
Can you change get-url and related functions so that instead of returning a string containing "ERR: ..." on an error, just throw an error that can be caught, similar to what is done with invalid list references?



As it is right now, I came across two different errors last night when running a site-scraper, but I don't feel comfortable with checking the output for a specific error string. 1) what if the file I'm fetching contains that error string?  2)  I don't know in advance what all the possible error strings are.  I came across two last night (connected failed, and server refused connection).  How many more are there? What if hostname lookup failed?
#58
In newlispdoc I've run across a few scenarios where I want to use the single quote and not have it be interpreted as a tt tag.  I understand there is an html entity I could use intead; could we add the ' escape though?
#59
I did this:



(setq x "hee heenhi hinho ho ho")
(find-all "hee.*hi" (| 2 4 8 512))
=> nil


Long and short, I tried almost every PCRE option and every combination, but nothing seemed to allow the . to match a newline, not even the option (4) that says it allows . to match newline.



Perhaps it is related to another thing I stumbled on, (trim "n     foo   ")
=> "n    foo"
 Is it supposed to work like that?



I am running OpenBSD,  Ubuntu, and Debian.  All are on 64bit AMD or Intel platforms with dual or better core.  All three show the problem.
#60
I am writing a Postgres module modeled on the MySQL module.



Postgres sometimes sends binary data as a result of queries.



newlisp strings can contain binary data, right?



Although I could probably work out something with (append), would it make sense to have a (get-bytes addr nbytes) function in the base distribution?



My brain is too fried right now to implement it.



Also, it might be more efficient to use the underlying memcpy() function of C in a builtin (get-bytes ...) rather than me implementing it.  Although as my mind works, I do see I could do it in a line or two of code.  Once I take a break.