Thanks! Regarding threading, I stepped away for a few and the thought crossed my mind as well. I came back tried the main thread do this:
(loop (setq Method "nope")) And I can see that Method gets overwritten in child threads. Neither bind nor job helps either. Is there any way around this? I supposed I could stick all my symbols in java thread local storage and always refer to symbols by (java ... ) instead of directly calling them. I may try that... Otherwise I'll have to make it single threaded which basically kills the idea of it because of slow pages. If not, it was a fun experiment nonetheless. On Sat, Jan 28, 2012 at 11:59 AM, Alexander Burger <[email protected]> wrote: > Hi Joe, > >> Another question: I started down an alternate path to use >> java.net.ServerSocket but it doesn't seem to like threads/thread pool >> calls. >> >> Here's a really simple example: >> >> : (setq Thread (java "java.lang.Thread" T (interface >> "java.lang.Runnable" 'run '(() (prinl "hi")))))) >> -> $Thread >> (java Thread "start") >> : -> NIL >> : Exception in thread "Thread-1" java.lang.NullPointerException > > HA! You found a bug in 'interface' :) > > > It seems that 'interface' could not handle correctly functions with > empty parameter lists, like the above '(() ..). This resulted in the > NullPointer exception. > > I fixed "ersatz/fun.src": > > 239a240,242 > > if (arg == null) > > return w.apply(null, false, null, 0); > > else { > 244a248 > > } > > (also uploaded a fixed version). > > > With that: > > abu:~/pico ersatz/pil + > : (setq Thread > (java "java.lang.Thread" T > (interface "java.lang.Runnable" 'run '(() (prinl "hi"))) ) ) > (java Thread "start") > -> $Thread > : -> NIL > : hi > > > BUT! While this simple example works, I'll have to warn stronly to use > Java threads in real code. The problem is the same as with the other > versions of PicoLisp: Threads cannot be handled cleanly, due to symbol > binding conflicts. You'll open a pandora box, because each thread will > overwrite the other thread's bindings. > > Unfortunately, Java doesn't come with a fork() system call ... > > Cheers, > - Alex > -- > UNSUBSCRIBE: mailto:[email protected]?subject=Unsubscribe -- UNSUBSCRIBE: mailto:[email protected]?subject=Unsubscribe
