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

#1
Anything else we might add? / newLISP + FCGI
March 06, 2006, 11:32:24 PM
I read a few older threads here and while newlisp + fcgi was mentioned as being used or toyed with, I never could find anything that hinted at it's success...



If someone here has successfully gotten newlisp to work with fastcgi (and lighttpd would be nice too) please let me know how you managed to do so.



Or is there any ideas how it might be accomplished?



Thanks guys.
#2
I am wondering what the easiest, or most efficient way is to search a string for all occurances of X and populating a list with each occurance. I've come up with a few solutions to this, but I am not sure that they are as fast or easy as they could be. I'd like to do a (find) with some regex on a string and throw each found occurance into a list.



Any ideas?



NOTE: In addition, I could use some mad regex fu. I need to scoure html source for all links and throw them into a list. Has anyone solved this problem already?
#3
newLISP in the real world / Contexts and Symbols
February 11, 2006, 04:48:39 PM
What would you suggest I mold into a habit?



Using a context prefix:

(context 'MYCONTEXT)
(define (myfunc , )
  (println MAIN:a)
)

(context 'MAIN)
(setq a 10)
(MYCONTEXT:myfunc)


or passing the value of a symbol when calling a function from another context:



(context 'MYCONTEXT)
(define (myfunc value , )
  (println myfunc)
)

(context 'MAIN)
(setq a 10)
(MYCONTEXT:myfunc a)


Is there anything I should keep in mind when using them?
#4
newLISP in the real world / (case) evaluation
February 09, 2006, 03:12:19 PM
Can anyone tell me why the following is true:



(setq a 1)
(setq b 2)
(setq c 3)
(setq d 1)

(case d
   (a (do-this))
   (b (do-that))
   (c (do-something))
   (true)
)

=> nil


I understand that the comparative values in my case are unevaluated. When switched out for an (eval) the case still doesn't work.



(setq a 1)
(setq b 2)
(setq c 3)
(setq d 1)

(case d
   ((eval a) (do-this))
   ((eval b) (do-that))
   ((eval c) (do-something))
   (true)
)

=> nil


What don't I understand?
#5
newLISP in the real world / Dealing with binary data...
January 31, 2006, 05:33:39 PM
I can do the following in perl:



$ perl -e 'print "xcan"'
Ê
$


And as you can see the xca result is the Ê character. If I wanted to duplicate this very thing in newlisp, how would I do it?
#6
I have an unsigned integer that is four bytes long that is sent to me via a network connection. When the server sends the integer, newlisp sees it as various characters ()&!@#*)}{":>?^`á–ó<Š¤,Ù¸í.!ƒ/,á–ó< so on and so forth.



What I need to do is take those four bytes and 'convert' them into an integer value.



Where do I start when doing something like this? I've looked at (format) and played with it a little, but was unable to get it to determine an unsigned int value.



I am at a loss :-(



If you're interested in what I'm doing, you can try the challenge found here: http://www.pulltheplug.org/wargames/vortex/level00.html">http://www.pulltheplug.org/wargames/vortex/level00.html



Thanks for the help guys.
#7
I'm confused as to why the following occurs:



netcat (nc):



# nc server 5842
%œŽ00ü›nßæ"ûO-^[[?1;2c


telnet:



# telnet server 5842
Connected to server.
Escape character is '^]'.
.m'Ww¢½MºÏŸjù©3


Now as you can see here, the content that is received is always different upon every connection.  I could use netcat to connect over and over, and I would never receive the same results. This is expected behavior of the server. What confuses me, however, is the fact that the following code only receives what seems like a small portion of the stuff sent from the server.



(context 'MAIN)

(setq host "server")
(setq port 5842)

(setq socket (net-connect host port))

(if socket
        (begin
                (println "Connected successfully!")
                (net-receive socket 'buffer 5128)
                (if buffer
                        (println "Recieved: " buffer)
                )
        )
)

(net-close socket)

(exit)


And when I run that code:



# ./code
Connected successfully!
Recieved: ¹«Õ/


I can run the program multiple times and still, I only appear to get a few results (as compared to that returned by a nc or telnet connection).



# ./code
Connected successfully!
Recieved: Žž»2



# ./code
Connected successfully!
Recieved: BͲ



# ./code
Connected successfully!
Recieved: {<


Can anyone tell me why this is the case? I should be seeing a little more than I am, so what if anything, am I doing incorrectly?
#8
Here's the code:



#!/usr/bin/newlisp

(context 'MAIN)

;; Check for a win32 platform

(if (> (& (last (sys-info)) 0xF) 4)
   (begin
      (println "Please run this application under unix.")
      (exit)
   )
)

;; Set constants

(constant   'signal 1
            'release 0
            'wait -1
)

(define (left-hand x)
   (println "left-hand")
   (set 'val 0)
   (while (< val x)
      (semaphore left-semaphore wait)
      (println (set 'val (share data)) "<--")
      (semaphore right-semaphore signal)
   )
   (exit)
)

(define (right-hand x)
   (println "right-hand")
   (for (val 1 x)
      (semaphore right-semaphore wait)
      (println "-->" (share data x))
      (semaphore left-semaphore signal)
   )
   (exit)
)

(define (start x)
   (println "Application Running...")

   ;; Allocate and fill shared memory
   (set 'data (share))
   (share data 0)

   ;; Create Semaphores for both right/left hands
   (set 'left-semaphore (semaphore))
   (set 'right-semaphore (semaphore))

   ;; Start threads
   (set 'left-process-id (fork (left-hand x)))
   (set 'right-process-id (fork (right-hand x)))

   ;; Move left hand
   (semaphore left-semaphore signal)

   ;; Wait for threads to finish
   (wait-pid left-process-id)
   (wait-pid right-process-id)

   ;; And finally, we release the semaphores
   (semaphore left-semaphore release)
   (semaphore right-semaphore release)
)

(start 1000)

(exit)


Now, I've tried to follow the manual yet, the out put of the program doesnt look right:



tmace:/src tmace$ ./semaphore.lsp
Application Running...
left-hand
0<--
right-hand
-->1000
1000<--
-->1000
^C
user reset - in function wait-pid
called from user defined function start
(c)ontinue, (d)ebug, e(x)it, (r)eset:
user reset - in function semaphore
called from user defined function right-hand
called from user defined function start
(c)ontinue, (d)ebug, e(x)it, (r)eset:x
tmace:/src tmace$ -->1000

tmace:/src tmace$


If anyone here could explain what is actually going on, i'd appreciate it.
#9
Taken from a debate in the #newlisp channel on freenode, here was this guy's complaints/arguments:



<someguy> well, newlisp's memory manager really sucks

<someguy> because it doesn't handle shared structure

<someguy> it copies objects when you pass parameters

<someguy> because its inefficient

<someguy> also it means you can't have first-class arrays or hash tables

<someguy> you have to name all arrays and hashes by symbols, and pass symbols, you can't just pass an anonymous hash

<someguy> it severely limits the language

<someguy> performance?

<someguy> sbcl is much faster

<someguy> except the design of newlisp is quite poor

<someguy> and i noticed the flawed memory management, and lack of first-class arrays and hashes

<someguy> more problems in newlisp than high-quality common lisps like sbcl

<someguy> in fact, i don't see anything newlisp is good for

<someguy> i've also looked at the implementation code, its a mess

<someguy> in that sbcl is better in every way

<someguy> it has first class arrays, hashes, real gc, a better object system

<someguy> newlisp is a strict subset of common lisp, except the really broken parts (copying all values when passing parameters, 'contexts')

<someguy> also there's no number tower

<someguy> so integer math overflows

<someguy> that's really bad

<someguy> you can have a file larger than 2gb, but newlisp cannot represent its size

<someguy> algorithms like md5 and sha1 hashing, and rsa crypto all use bignums



I could argue all day with this guy, but in the end, I'm really only interested in Lutz's commentary. So if you wouldn't mind...



Thanks.
#10
newLISP in the real world / Dynamic functions
June 17, 2005, 08:15:37 AM
(set 'a "myprogram -abc -use=something example.txt")

(set 'b (parse a))



b => ("myprogram" "-abc" "-use=something" "example.txt")



Now I need a way to execute this as a newlisp function. Something along the lines of:



(eval ((nth 0 b) (nth 1 b) (nth 2 b) (nth 3 b)))



I need newlips to try to turn all that into (myprogram -abc -use=something example.txt), or in other words, I need it to take my string and turn it into a newlisp function.



Any ideas?
#11
newLISP newS / NewLISP on IRC!
June 16, 2005, 08:56:52 AM
Just wanted to let everyone know that Lutz has ok'd a newlisp support channel for IRC users.



IRC Server: irc.freenode.net

IRC Channel: #newlisp
#12
Anything else we might add? / Broken server
April 14, 2005, 11:43:07 AM
I got a server that will accept one client but exits right after the client closes the connection. I want to keep the server listening and ready to accept so that other clients (or the same one) can communicate with the server more than once.



(define (server)
        (set 'addr "localhost")
        (set 'port 100)
        (set 'listen (net-listen port addr))
        (println "Waiting for connection on: " port)
        (set 'socket (net-accept listen))
        (println "Accepting... ")
        (if socket
                (while (net-receive socket 'received 1024)
                        (println "I got something: " (string received))
                        (net-send socket (string received)
                )
        )
)


Anyone got an idea why this would be?



-statik