ersatz - can not access a member

2012-01-28 Thread Joe Bogner
I'm trying to write a simple java web server using the simpleframework. I'm
close, but I process anything in the method handler:

(de handler (request response) (java response 'close))
(setq cont (interface "org.simpleframework.http.core.Container" 'handle
handler))
(setq con (java "org.simpleframework.transport.connect.SocketConnection" T
cont))
(setq addr (java "java.net.InetSocketAddress" T 8005))
(java con 'connect addr)

When I run this and then curl http://localhost:8005 I get the following
exception:

java.lang.IllegalAccessException: Class PicoLisp$Number can not access a
member
of class org.simpleframework.http.core.ResponseEntity with modifiers
"public"

I've tried every other method I can think of from this doc:
http://www.simpleframework.org/doc/javadoc/index.html

If I intentionally put a missing method in, it correctly reports it:
(de handler (request response) (java response 'close2))
: !? (java response 'close2)
java.lang.NoSuchMethodException: close2

If my handler is this, I get a response.
(de handler (request response) (prinl response))
: HTTP/1.1 200 OK

I need to be able access the request/response to process it. I am not sure
if I need to use javac because of the interface but then I'm not sure how
I'd add picolisp code to process the request/response.

Thanks for any help


Re: ersatz - can not access a member

2012-01-28 Thread Joe Bogner
This is the java example I'm trying to duplicate:
http://www.simpleframework.org/doc/tutorial/tutorial.php

import org.simpleframework.http.core.Container;
import org.simpleframework.transport.connect.Connection;
import org.simpleframework.transport.connect.SocketConnection;
import org.simpleframework.http.Response;
import org.simpleframework.http.Request;
import java.net.InetSocketAddress;
import java.net.SocketAddress;
import java.io.PrintStream;

public class HelloWorld implements Container {

   public void handle(Request request, Response response) {
      PrintStream body = response.getPrintStream();
      long time = System.currentTimeMillis();

      response.set("Content-Type", "text/plain");
      response.set("Server", "HelloWorld/1.0 (Simple 4.0)");
      response.setDate("Date", time);
      response.setDate("Last-Modified", time);

      body.println("Hello World");
      body.close();
   }

   public static void main(String[] list) throws Exception {
      Container container = new HelloWorld();
      Connection connection = new SocketConnection(container);
      SocketAddress address = new InetSocketAddress(8080);

      connection.connect(address);
   }
}



On Sat, Jan 28, 2012 at 6:33 AM, Joe Bogner  wrote:
>
> I'm trying to write a simple java web server using the simpleframework. I'm 
> close, but I process anything in the method handler:
>
> (de handler (request response) (java response 'close))
> (setq cont (interface "org.simpleframework.http.core.Container" 'handle 
> handler))
> (setq con (java "org.simpleframework.transport.connect.SocketConnection" T 
> cont))
> (setq addr (java "java.net.InetSocketAddress" T 8005))
> (java con 'connect addr)
>
> When I run this and then curl http://localhost:8005 I get the following 
> exception:
>
> java.lang.IllegalAccessException: Class PicoLisp$Number can not access a 
> member
> of class org.simpleframework.http.core.ResponseEntity with modifiers "public"
>
> I've tried every other method I can think of from this doc: 
> http://www.simpleframework.org/doc/javadoc/index.html
>
> If I intentionally put a missing method in, it correctly reports it:
> (de handler (request response) (java response 'close2))
> : !? (java response 'close2)
> java.lang.NoSuchMethodException: close2
>
> If my handler is this, I get a response.
> (de handler (request response) (prinl response))
> : HTTP/1.1 200 OK
>
> I need to be able access the request/response to process it. I am not sure if 
> I need to use javac because of the interface but then I'm not sure how I'd 
> add picolisp code to process the request/response.
>
> Thanks for any help
--
UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe


Re: ersatz - can not access a member

2012-01-28 Thread Joe Bogner
Hi Alex,

Thanks for the response! Here's the output from trace. It's neat to
see, but I don't know enough to interpret it:

java -DPID=42 -cp .;picolisp.jar;simple-4.1.21.jar PicoLisp lib.l go.l +
 interface : "org.simpleframework.http.core.Container" handle
((Request Response) (java Response 'close))
 interface = $$Proxy0
 java : "org.simpleframework.transport.connect.SocketConnection" T $$Proxy0
 java = $SocketConnection
 java : "java.net.InetSocketAddress" T 8005
 java = $InetSocketAddress
 java : $SocketConnection connect $InetSocketAddress
 java = $InetSocketAddress
:  java : $ResponseEntity close
!? (5 $4354460 $3195425)
java.lang.IllegalAccessException: Class PicoLisp$Number can not access a member
of class org.simpleframework.http.core.ResponseEntity with modifiers "public"
?


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
at PicoLisp$Number$1.invoke(Unknown Source)
at $Proxy0.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)

Any clues on this one either?


Thank you!
Joe


On Sat, Jan 28, 2012 at 7:18 AM, Alexander Burger  wrote:
> Hello Joe,
>
>> I'm trying to write a simple java web server using the simpleframework. I'm
>> close, but I process anything in the method handler:
>
> OK. I can't reproduce the problem, as I don't have access to that
> framework. But perhaps I can give some hints to help locate the problem.
>
>
>> (de handler (request response) (java response 'close))
>> (setq cont (interface "org.simpleframework.http.core.Container" 'handle
>> handler))
>> (setq con (java "org.simpleframework.transport.connect.SocketConnection" T
>> cont))
>> (setq addr (java "java.net.InetSocketAddress" T 8005))
>> (java con 'connect addr)
>
> One note first: In PicoLisp, it is advisable to use uppercase names for
> (local) variables, because otherwise there is a risc for name conflicts.
>
> For example, the expression
>
>   (setq con (java "org.simpleframework...
>
> changes the value of the symbol 'con', which happens to be a function
> (setting the CDR of a cell). Later calls to that function will crash.
> This risk also exists for function parameters, so I would write the
> above as:
>
>   (de handler (Request Response)
>      (java Response 'close) )
>
>   (setq Cont
>      (interface "org.simpleframework.http.core.Container" 'handle handler) )
>
>   (setq Con
>      (java "org.simpleframework.transport.connect.SocketConnection" T Cont) )
>
>   (setq Addr (java "java.net.InetSocketAddress" T 8005))
>
>   (java Con 'connect Addr)
>
>
> But this is probably not the problem here.
>
>
>> When I run this and then curl http://localhost:8005 I get the following
>> exception:
>>
>> java.lang.IllegalAccessException: Class PicoLisp$Number can not access a
>> member
>> of class org.simpleframework.http.core.ResponseEntity with modifiers
>> "public"
>
> It would be interesting to see _where_ things get wrong. Could you
> try to trace the execution? Please call
>
>   (trace 'java)
>   (trace 'interface)
>
> before starting execution. And possibly trace other functions too, e.g.
> (trace 'handler), or (traceAll) to trace all Lisp-level functions.
>
> There must be a situation where perhaps the argument type (number?)
> doesn't match.
>
> Cheers,
> - Alex
> --
> UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe
--
UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe


Re: ersatz - can not access a member

2012-01-28 Thread Joe Bogner
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  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:picolisp@software-lab.de?subject=Unsubscribe
--
UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe


json example w/ersatz

2012-01-29 Thread Joe Bogner
Are there any tips on how to port the json example to ersatz since it
does not support pipe? I experimented with parsing out the string into
a new string and calling str on it but didn't get very far yet. I'd
like something that can parse a string.

Thanks
Joe
-- 
UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe


Re: Web app example using ersatz

2012-01-31 Thread Joe Bogner
Hi Alex - Great! I see the drawback with losing the name. For now I've
just added some text to instruct "please rename to a zip".  With such
cryptic file names it adds to the security by obscurity (hah!).
Reminds me of the old trick in email to have file "foo.zip.rename" to
suggest people to rename.

Kidding aside, I think it's helpful to allow uploads and I'm not
worried about the security of it. Maybe if I were to pick a single
mimetype, I'd go with zip or tar.gz as that's the main reason someone
would upload if it's too much to paste in as a code example or to
include a complete working example with some supporting files (images,
example DB, etc).

On Tue, Jan 31, 2012 at 5:01 AM, Alexander Burger  wrote:
> Hi Joe,
>
>> > I uploaded the code but couldn't figure out how to link to it on the page.
>>
>> I'm afraid this is not possible. The wiki supports only  and
>
> Now I've added support for arbitrary files to the Wiki.
>
>
>> We could extend it for arbitrary mimetypes, but then I'm not sure which
>> tag to generate. A simple  might be dangerous in case someone uploads
>> a malign file, right? Any idea?
>
> Thinking about it, I think it is all right. The file can only be
> downloaded after all.
>
> What I did is extend the <{name} markup, so that if the file's mimetype
> is neither image nor video, it is simply put into a . The file
> will be presented for download then. A small drawback is that the file's
> name is lost in the process, because it is stored in a DB blob, and some
> cryptic name is given to the downloaded file. I'll think more about
> that.
>
>
> I see that you already solved the problem in your wiki article
> "http://picolisp.com/5000/!wiki?ErsatzWebApp"; by providing an external
> link.
>
> For a test, though, I added an entry with the new mechanism. Please
> modify it if you like.
>
> Cheers,
> - Alex
> --
> UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe
-- 
UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe


Re: Web app example using ersatz

2012-01-31 Thread Joe Bogner
Hi Henrik, Thanks for the feedback!

Yes, I plan on extending it further. I fixed a small bug with having
to decode the urlencoded post variables (e.g. 'hello%20world').

At first I was stumped because ht:Pack is implemented in ht.c so there
wasn't a java implementation

(ht:Pack (chop "hello%20world"))

Looks like this will do the trick though:

(de ht:Pack (X) (java (java 'java.net.URLDecoder 'decode (pack X) "UTF-8")))

The real test will be when/if I decide to write a real app with it.
I'm happy to help if anyone wants to use it too.


On Mon, Jan 30, 2012 at 11:12 PM, Henrik Sarvell  wrote:
> Cool stuff Joe!
>
> Are you planning to work more on this or?
>
>
>
> On Mon, Jan 30, 2012 at 11:50 PM, Alexander Burger  
> wrote:
>> Hi Jakob,
>>
>>> There is no silver bullet for this problem. Even images could be malicious.
>>
>> Yeah, that's right. But the wiki won't do anything with images or
>> videos, just push them to the browser. So I assume the wiki itself is
>> not in danger. Of course, there's no absolute security ;-)
>>
>>> Different wikis solve it by allowing certain users, or per page settings,
>>> ACLs and so on. It's a mess, just pick a kind of mess and go with it. :-)
>>
>> Hmm, too bad ;-)
>>
>> Cheers,
>> - Alex
>> --
>> UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe
> --
> UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe
-- 
UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe


Re: PicoLisp SSL Problem

2012-02-16 Thread Joe Bogner
More info on BEAST and a recent Microsoft security update that was pushed
out for it:

http://technet.microsoft.com/en-us/security/bulletin/ms12-006

http://www.securitynewsdaily.com/1077-beast-hack.html

My bet is that the update is what caused it to break.

On Thu, Feb 16, 2012 at 9:01 AM, Joe Bogner  wrote:

> You can see some interesting analysis on the certificate here:
> https://www.ssllabs.com/ssldb/analyze.html?d=https://app.7fach.de
>
> It mentions being vulnerable to BEAST and offers this link
> https://community.qualys.com/blogs/securitylabs/2011/10/17/mitigating-the-beast-attack-on-tls
>  .
> I haven't read through it.
>
> Have you tried using a signed certificate and/or adding the root cert to
> the trusted list? However, it looks like the BEAST issue is regardless of
> the cert. I suspect that's the cause.
>
> I can't connect with IE8 or Chrome on Windows so it might be that some
> windows update came along and updated my underlying SSL stack. I can't
> confirm though whether it worked previously.
>
> On Thu, Feb 16, 2012 at 8:46 AM, Alexander Burger wrote:
>
>> Hi Thorsten,
>>
>> > http://code.google.com/p/chromium/issues/detail?id=98101#c31
>> >
>> >  Comment 8 by a...@chromium.org, Oct 12, 2011
>> >
>> ,
>> > |Yes, requests will be in multiple records from now on. See
>>
>> I have no idea what "multiple records" mean in this context
>>
>> > |http://www.imperialviolet.org/2011/09/23/chromeandbeast.html Firefox
>>
>> So we are back to the BEAST issue (also mentioned by Randall in this
>> thread a few days ago).
>>
>> Clueless,
>> - Alex
>> --
>> UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe
>>
>
>


Re: PicoLisp SSL Problem

2012-02-16 Thread Joe Bogner
You can see some interesting analysis on the certificate here:
https://www.ssllabs.com/ssldb/analyze.html?d=https://app.7fach.de

It mentions being vulnerable to BEAST and offers this link
https://community.qualys.com/blogs/securitylabs/2011/10/17/mitigating-the-beast-attack-on-tls


Re: android success with full picolisp

2012-02-20 Thread Joe Bogner
Doug - Neat! I took a different approach and got picolisp working on my
android phone and kindle fire by using terminal-ide (
http://code.google.com/p/terminal-ide/ ) as the shell and cross compiling
picoLisp with gcc-arm-linux-gnueabi on my linux box. I can post the binary
if anyone is interested.

I didn't do anything with it because terminal-ide (and it's busybox
compile) couldn't resolve DNS (didn't include a /etc/resolv.conf) and I
lost root at the time with my kindle fire.
http://forum.xda-developers.com/showthread.php?p=22103721 . I was
originally going to play around with scripting out something that involved
the network.

I kicked around shelling out to a java app to resolve DNS but then moved
onto another project. Other than that it worked great. It was nice to have
VIM around as well. I may go back to it at some point but didn't really
have a practical use for it on android especially since I could just ssh
into my linux if I wanted to tinker with picoLisp.

Thanks for sharing

On Mon, Feb 20, 2012 at 9:46 PM, Doug Snead wrote:

> More android + picolisp fun, this time with the full picolisp.  Using the
> android SDK and NDK, I hacked a picolisp/src/makefile to work for android's
> arm processor like this:
>
> --- makefile ---
> [snip]
>
> CFLAGS := -c -O2  -pipe \
> -falign-functions=64 -fomit-frame-pointer -fno-strict-aliasing \
> -W -Wimplicit -Wreturn-type -Wunused -Wformat \
> -Wuninitialized -Wstrict-prototypes \
> -D_GNU_SOURCE  -D_FILE_OFFSET_BITS=64
> # ?? had: -m32
>
> NDK_ROOT = ~/android/android-ndk-r7
> NDK_BIN =
> $(NDK_ROOT)/toolchains/arm-linux-androideabi-4.4.3/prebuilt/linux-x86/bin
> SYS_ROOT = $(NDK_ROOT)/platforms/android-8/arch-arm/
> CC = $(NDK_BIN)/arm-linux-androideabi-gcc --sysroot=$(SYS_ROOT)
> LD = $(NDK_BIN)/arm-linux-androideabi-ld
> AR = $(NDK_BIN)/arm-linux-androideabi-ar
> RANLIB = $(NDK_BIN)/arm-linux-androideabi-ranlib
> STRIP = $(NDK_BIN)/arm-linux-androideabi-strip
>
> OS = Arm
> PICOLISP-FLAGS = -m32 -rdynamic
> LIB-FLAGS = -lc -lm -ldl
> DYNAMIC-LIB-FLAGS = -m32 -shared -export-dynamic
>
> [snip]
> -
>
> Then (to my surprise) picolisp and dynamic libraries were made,
>
> # file ../bin/picolisp  ../lib/ext  ../lib/ht ../lib/z3d
> ../bin/picolisp: ELF 32-bit LSB executable, ARM, version 1 (SYSV),
> dynamically linked (uses shared libs), stripped
> ../lib/ext:  ELF 32-bit LSB shared object, ARM, version 1 (SYSV),
> stripped
> ../lib/ht:   ELF 32-bit LSB shared object, ARM, version 1 (SYSV),
> stripped
> ../lib/z3d:  ELF 32-bit LSB shared object, ARM, version 1 (SYSV),
> stripped
>
> So far so good...
>
> Using this android approach generally,
>
>
> http://gimite.net/en/index.php?Run%20native%20executable%20in%20Android%20App
>
> I placed the picolisp executable in the assets dir and at run-time, copy
> it from assets to /data/data/ in the right place for that app.
>
> Since I'm using the emulator and I know where the executable was placed, I
> can run it using adb, for some command-line tests:
>
> # adb shell /data/data/com.mytest/picolisp '-de foo ("X") (println "X")'
> '-foo 123' -bye
> 123
>
> # adb shell /data/data/com.mytest/picolisp '-de foo ("X") (println (* "X"
> 2))'  '-foo 123' -bye
> 246
>
> # adb shell /data/data/com.mytest/picolisp '-de foo ("X") (println (* "X"
> 2))'  '-foo 12345' -bye
> 24690
>
> A bit cumbersome having to unpack the executable and other files from the
> app's .apk (zip archive) to run it ... but it can be done.  And no fiddling
> with bits ... no changes to the (full picolisp) source at all.
>
> Next step is to try to similarly unpack all the libraries and see if a
> picolisp database server application can be run. Then more testing.  And
> use that with android's browser, all within an android app.
>
> But I'm very confident that the full picolisp will run on the android from
> what I see so far!
>
> There are ways to call java from C also, so that opens up possibilities of
> using android java libraries from android picolisp too.
>
> Cheers,
>
> Doug
>
> --
> UNSUBSCRIBE: mailto:picolisp@software-lab.de?subjectUnsubscribe
>


Re: server - IP socket error: Address family not supported by protocol

2012-02-23 Thread Joe Bogner
Doug - you need to install ipv6 support on linux. Look for an ipv6 package
for your distro
On Feb 23, 2012 1:28 AM, "Doug Snead"  wrote:

> Might be even easier to reproduce ... just try the port function:
>
> # picoLisp-2.2.7.tgz ...
> ~/lisp/picoLisp
> $ ./p
> : (port 1234)
> -> 3
>
> That's ok, but the most recent version,
>
> # picoLisp-3.0.9.tgz
> # ./pil
> : (port 1234)
> !? (port 1234)
> IP socket error: Address family not supported by protocol
> ?
>
>
>
>
>
>
> --- On Wed, 2/22/12, Doug Snead  wrote:
>
> > From: Doug Snead 
> > Subject: server - IP socket error: Address family not supported by
> protocol
> > To: picolisp@software-lab.de
> > Date: Wednesday, February 22, 2012, 10:07 PM
> > Hi Alex,
> >
> > I'm tying to get the example in doc/app.html
> > (picoLisp-3.0.9.tgz on a pretty standard linux box) to
> > serve.  Here's my .l file:
> >
> > # cat test_html_app.l
> > 
> > (html 0 "Hello" "@lib.css" NIL
> >"Hello World!" )
> > 
> >
> > (renamed from project.l but otherwise identical)
> >
> > But when I try to start the server, like this:
> >
> > # ./pil @lib/http.l @lib/xhtml.l @lib/form.l -'server 8080
> > "test_html_app.l"' +
> >
> > Picolisp tells me:
> >
> > !? (port *Port)
> > IP socket error: Address family not supported by protocol
> > ?
> >
> > Same for a different port number:
> >
> > # ./pil @lib/http.l @lib/xhtml.l @lib/form.l -'server 54321
> > "test_html_app.l"' +
> > !? (port *Port)
> > IP socket error: Address family not supported by protocol
> > ?
> >
> > This is the linux platform I am using (Linux 2.6.30.5 #1 SMP
> > Tue Sep 1 15:48:26 GMT-8 2009 i686 GNU/Linux).
> >
> > I could easily be doing something wrong ... but I think the
> > above should work.
> >
> > Cheers,
> >
> > Doug
> >
> >
> >
> --
> UNSUBSCRIBE: mailto:picolisp@software-lab.de?subjectUnsubscribe
>


Re: Android Web Server

2012-02-23 Thread Joe Bogner
Hi Imran - Thanks for the feedback. I put it under Examples. I'm interested
in other's opinions - would you have considered it an article?

I agree with your points on making it easier to see changes on the wiki

On Thu, Feb 23, 2012 at 3:27 PM, Imran Rafique  wrote:

> Joe,
>
> More a comment on the wiki, rather than your Android article. I guess
> its a subjective choice as to where one files such things (articles vs
> examples vs ...). It would be great if the wiki had some kind of
> automatic changelog, where new additions & edits to existing pages are
> listed in LIFO order. Easier to find new stuff then :)
>
> --
> Regards,
>Imran Rafique
>
>
>
> On 23 February 2012 07:42, Joe Bogner  wrote:
> > Doug Snead's recent posts have encouraged me to write up my progress
> along
> > similar lines with getting PicoLisp to work on Android.
> >
> > http://picolisp.com/5000/!wiki?AndroidWebServer
> >
> > I have a functioning web server. My approach was to cross compile on unix
> > and then copy the binary to the device.
> >
> > If anyone has any input on the issue at the end I would appreciate it.
> >
> > I also uploaded the code in case I decide to remove it off my public
> > dropbox.
> >
> > Thanks and I look forward to any comments!
> >
> > Joe
> >
> --
> UNSUBSCRIBE: mailto:picolisp@software-lab.de?subjectUnsubscribe
>


Re: Reference Example typo

2012-02-23 Thread Joe Bogner
Thanks!

I arrived at a similar conclusion by looking at the C source. It also says
in the doc that new! can be used for multiple classes so that's probably
another reason why

2012/2/23 José Romero 

> On Thu, 23 Feb 2012 16:16:01 -0500
> Joe Bogner  wrote:
>
> > Sidenote: Can someone explain why the use of the parentheses around
> > the class name? It seems confusing to be '+Item in some contexts and
> > '(+Item) in others.
> >
> >
> It's the way typing works in the PicoLisp object system, "types" are
> lists of prototype objects (or "mixin classes", whatever way you wanna
> call them). When a message is sent to an object, be it with 'send 'try
> or calling a method symbol (val=meth), the interpreter looks into the
> val of the symbol for the method, if it's not there, it goes trough the
> symbols at the tail of the list (the "type"), in order.
>
> > Thanks!
> > Joe
> Cheers,
> José
> --
> UNSUBSCRIBE: mailto:picolisp@software-lab.de?subjectUnsubscribe
>


Re: Android Web Server

2012-02-24 Thread Joe Bogner
Hi Doug,

Thanks for the feedback! I've been able to browse to localhost and
http://127.0.0.1 against a running local picoLisp web app.

I then started to look into packaging it up in a java app. I created a
simple little WebView shell
(http://developer.android.com/resources/tutorials/views/hello-webview.html)
which hits my webapp on localhost.  I just now need to tie in the part
of launching the native picoLisp executable. I'll probably do that
using an approach from here:
http://gimite.net/en/index.php?Run%20native%20executable%20in%20Android%20App

I'll post when I make progress

On Fri, Feb 24, 2012 at 3:55 AM, Doug Snead  wrote:
> Hi Joe,
>
> Very nice!   I think it would be useful to be able to package complete 
> picolisp applications as android apps. Or, at least that might be a 
> possibility.  Something to explore. I'm still hung up on trying to get 
> android browser to talk to the picolisp app server like that.   I'm reading 
> there are some peculiarities with android localhost which is what I think I 
> am running into now.  Also I am thinking about best ways to have android java 
> interface with pilog too.
>
> Cheers,
>
> Doug
>
>
> --- On Thu, 2/23/12, Joe Bogner  wrote:
>
> From: Joe Bogner 
> Subject: Android Web Server
> To: picolisp@software-lab.de
> Date: Thursday, February 23, 2012, 7:42 AM
>
> Doug Snead's recent posts have encouraged me to write up my progress along 
> similar lines with getting PicoLisp to work on Android.
> http://picolisp.com/5000/!wiki?AndroidWebServer
>
> I have a functioning web server. My approach was to cross compile on unix and 
> then copy the binary to the device.
> If anyone has any input on the issue at the end I would appreciate it.
>
> I also uploaded the code in case I decide to remove it off my public dropbox.
> Thanks and I look forward to any comments!
> Joe
>
>
>
> --
> UNSUBSCRIBE: mailto:picolisp@software-lab.de?subjectUnsubscribe
--
UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe


Android Demo

2012-02-24 Thread Joe Bogner
I was able to successfully embed a picoLisp web app into a java
Android app. It's just a form that outputs what's in the textbox. I've
also been able to prove that database access calls work but I haven't
integrated it into this example.

I also recorded a terrible video of it :).
https://picasaweb.google.com/lh/photo/FLO3jIBS99dNPOeb9gC78s8zJy1Iv3Dkn7PZ5E-PSQc?feat=directlink.
I ran out of time to redo. I've added a sleep to help ensure that
picoLisp is running before the web page is rendered:


I've tried it on both my android (DroidX) phone and my kindle fire.

The core java code is quite simple. The toasts don't appear for some
reason while it's downloading the required files but it does appear
when it's starting.

@Override
public void onCreate(Bundle icicle) {
super.onCreate(icicle);
// ToDo add your GUI initialization code here
setContentView(R.layout.main);

Context context = getApplicationContext();

String localPath = "/data/data/org.me.androiddemo/";
String local = localPath + "arm-picoLisp.tar.gz";

if (!new File(localPath + "busybox").exists()) {
  Toast.makeText(context, "Downloading busybox", Toast.LENGTH_SHORT).show();
  download("http://dl.dropbox.com/u/20783971/busybox";, localPath +
"busybox");
  exec("/system/bin/chmod 744 " + localPath + "busybox");
}

if (!new File(local).exists()) {
  Toast.makeText(context, "Downloading picoLisp",
Toast.LENGTH_SHORT).show();
  download("http://dl.dropbox.com/u/20783971/arm-picoLisp.tar.gz";, local);
  exec(localPath + "busybox tar -zxvf " + local + " -C " + localPath);
}

exec(localPath + "busybox killall -9 picolisp");



Toast.makeText(context, "Starting App", Toast.LENGTH_SHORT).show();

execAsync(localPath + "arm-picoLisp/pil @lib/http.l @lib/xhtml.l "
+ localPath + "arm-picoLisp/s.l", localPath + "arm-picoLisp");

try {
Thread.sleep(1000);
}  catch (InterruptedException e) {
}
WebView mWebView;

mWebView = (WebView) findViewById(R.id.webview);
mWebView.getSettings().setJavaScriptEnabled(true);
mWebView.setWebViewClient(new WebViewClient() {
  @Override
  public boolean shouldOverrideUrlLoading(WebView view, String url) {

view.loadUrl(url);

return true;

  }
});
mWebView.loadUrl("http://127.0.0.1:8001/";);
}


demo_android_signed.apk
Description: application/vnd.android.package-archive


MainActivity.java
Description: Binary data


Re: Android Demo

2012-02-26 Thread Joe Bogner
Hi Doug - Thanks for the reply. Have you tried my APK to see if it's your
device or if it's the approach you took?

Please share if you create anything on android with picolisp. I would be
interested in hearing about use cases for it.

Thanks
Joe

On Sat, Feb 25, 2012 at 5:38 PM, Doug Snead wrote:

> Joe,
>
> Ha ... very interesting the way you download busybox to download picolisp!
>   I'm still wondering why I cannot connect to my picolisp server on android
> ... but it looks like you have that issue licked.
>
> Ok, so now this means we can package some picolisp client/server
> applications as android apps, using the android browser.  (I think.) I like
> that approach because it works with the android browser and app packaging
> scheme - and at the same time you're getting picolisp in all its glory and
> efficiency.
>
> Cheers,
>
> Doug
>
>
>
> --- On Fri, 2/24/12, Joe Bogner  wrote:
>
> > From: Joe Bogner 
> > Subject: Android Demo
> > To: picolisp@software-lab.de
> > Date: Friday, February 24, 2012, 8:30 AM
> > I was able to successfully embed a
> > picoLisp web app into a java
> > Android app. It's just a form that outputs what's in the
> > textbox. I've
> > also been able to prove that database access calls work but
> > I haven't
> > integrated it into this example.
> >
> > I also recorded a terrible video of it :).
> >
> https://picasaweb.google.com/lh/photo/FLO3jIBS99dNPOeb9gC78s8zJy1Iv3Dkn7PZ5E-PSQc?feat=directlink
> .
> > I ran out of time to redo. I've added a sleep to help ensure
> > that
> > picoLisp is running before the web page is rendered:
> >
> >
> > I've tried it on both my android (DroidX) phone and my
> > kindle fire.
> >
> > The core java code is quite simple. The toasts don't appear
> > for some
> > reason while it's downloading the required files but it does
> > appear
> > when it's starting.
> >
> > @Override
> > public void onCreate(Bundle icicle) {
> > super.onCreate(icicle);
> > // ToDo add your GUI initialization code here
> > setContentView(R.layout.main);
> >
> > Context context = getApplicationContext();
> >
> > String localPath =
> > "/data/data/org.me.androiddemo/";
> > String local = localPath +
> > "arm-picoLisp.tar.gz";
> >
> > if (!new File(localPath + "busybox").exists())
> > {
> >   Toast.makeText(context, "Downloading
> > busybox", Toast.LENGTH_SHORT).show();
> >   download("http://dl.dropbox.com/u/20783971/busybox";, localPath +
> > "busybox");
> >   exec("/system/bin/chmod 744 " +
> > localPath + "busybox");
> > }
> >
> > if (!new File(local).exists()) {
> >   Toast.makeText(context, "Downloading
> > picoLisp",
> > Toast.LENGTH_SHORT).show();
> >   download("http://dl.dropbox.com/u/20783971/arm-picoLisp.tar.gz";,
> > local);
> >   exec(localPath + "busybox tar -zxvf " +
> > local + " -C " + localPath);
> > }
> >
> > exec(localPath + "busybox killall -9
> > picolisp");
> >
> >
> >
> > Toast.makeText(context, "Starting App",
> > Toast.LENGTH_SHORT).show();
> >
> > execAsync(localPath + "arm-picoLisp/pil
> > @lib/http.l @lib/xhtml.l "
> > + localPath + "arm-picoLisp/s.l", localPath +
> > "arm-picoLisp");
> >
> > try {
> > Thread.sleep(1000);
> > }  catch (InterruptedException e) {
> > }
> > WebView mWebView;
> >
> > mWebView = (WebView)
> > findViewById(R.id.webview);
> >
> > mWebView.getSettings().setJavaScriptEnabled(true);
> > mWebView.setWebViewClient(new WebViewClient()
> > {
> >   @Override
> >   public boolean
> > shouldOverrideUrlLoading(WebView view, String url) {
> >
> > view.loadUrl(url);
> >
> > return true;
> >
> >   }
> > });
> > mWebView.loadUrl("http://127.0.0.1:8001/";);
> > }
> >
> --
> UNSUBSCRIBE: mailto:picolisp@software-lab.de?subjectUnsubscribe
>


Re: Google Summer of Code (GSoC) 2012

2012-02-28 Thread Joe Bogner
Hi Alex,

Android porting may be a good candidate. It depends on how it would be
scoped. Unfortunately I don't have much time to put towards leading it
or being a mentor. However, off the top of my head this is what I
think is needed:

1. Add Makefile changes and source code changes (e.g. making it so
ht:Pack can be called - however its needed) to the main source
repository

2. Create some utility that packages up a picoLisp web app into a java APK

3. Create an example app that demonstrates the full stack (db, web)
and power of picoLisp. Maybe also demonstrate a java bridge and
bindings (either by using call or something more native) so we can
interact with the device (e.g. capture QR code)

4. Create documentation

I'd be glad to be a contributor/reviewer though.

Thanks,
Joe



On Tue, Feb 28, 2012 at 5:26 AM, Alexander Burger  wrote:
> Hi Joe, Doug, and anyone interested!
>
> On Mon, Feb 27, 2012 at 01:40:16PM +0100, Thorsten wrote:
>> We prepared a GSoC 2012 page in the PicoLisp wiki
>> (http://picolisp.com/5000/!wiki?gsoc), where you can find more
>> information.
>> ...
>> For now (till 2012-03-09) the most important task is to collect ideas
>> and find out who would like to be a mentor for his (or other peoples)
>> project ideas. Then, if PicoLisp is accepted by Google, we need to
>> spread the word and make students apply for a project.
>>
>> Any thoughts or ideas how to make the PicoLisp application for the GSoC
>> 2012 a success are welcome.
>
> Wouldn't be the Android porting project a good candidate for the Summer
> of Code?
>
> Does anybody have contact to students who might be interested (and able)
> to do such a project? And would perhaps Joe and/or Doug be interested to
> support them as mentors?
>
> Cheers,
> - Alex
> --
> UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe
-- 
UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe


Re: Google Summer of Code (GSoC) 2012

2012-03-03 Thread Joe Bogner
Hi José -

I've been thoroughly impressed with everything I've seen from you and
even more so if you're a student. Wow!

Related to your proposal below, if I can replay back what I am
understanding, it sounds like there are three aspects to it:

1.) A more robust interface between a web server and a picolisp app.
Something that can work in a variety of situations (e.g.VPS or
dedicated hosting).  This should enable more adoption of picolisp as a
language for building web applicationss.

[Sidenote: I've used your SCGI.l with nginx with and it would benefit
others to document how that could work]

2.) A routing framework (does this follow the REST framework
discussions we've had on IRC?) to simplify web app development - again
it seems like you are close here based on what I've seen in scgi.l

3.) Provide some of the same functionality as XHTML without tying it
to the session IDs. In other words, enable the general purpose GUI
framework to be agnostic of the 'server' it's running in

I think these are all wonderful ideas. If I was sitting on the
committee evaluating proposals for the GSoC I would be evaluating
projects based on their ability to have a broad impact or solves an
unsolved problem. Since picoLisp is fairly niche, I like that what
you're suggesting could open it up to more developers. I am no expert
in this area though. I am not sure how this would stand out against
framework XYZ aiming for broader appeal.

I spent a minute looking for some more context on GSoC related to
languages. I found a retrospective on haskell:
http://www.gwern.net/Haskell%20Summer%20of%20Code

I guess for someone with no knowledge of picoLisp, as it relates to
your proposal, why is picoLisp a good choice for web development? What
would the successful completion of the proposal enable? I have some
perspective but would be interested in hearing what you think.

Thanks for sharing it!
Joe






2012/3/3 José Romero :
> On Sat, 03 Mar 2012 21:10:25 +0100
> Thorsten  wrote:
>
>> Alexander Burger  writes:
>>
>> Hi List,
>>
>> > On Mon, Feb 27, 2012 at 01:40:16PM +0100, Thorsten wrote:
>> >> We prepared a GSoC 2012 page in the PicoLisp wiki
>> >> (http://picolisp.com/5000/!wiki?gsoc), where you can find more
>> >> information.
>> >> ...
>> >> For now (till 2012-03-09) the most important task is to collect
>> >> ideas and find out who would like to be a mentor for his (or other
>> >> peoples) project ideas. Then, if PicoLisp is accepted by Google,
>> >> we need to spread the word and make students apply for a project.
>> >>
>> >> Any thoughts or ideas how to make the PicoLisp application for the
>> >> GSoC 2012 a success are welcome.
>>
>> I would suggest to add at least 2 or 3 more project ideas to the ideas
>> page (http://picolisp.com/5000/!wiki?ideasPage) to raise the odds of
>> PicoLisp being accepted as mentoring organisation.
>>
>> The best case would be if anybody is interested to participate as a
>> student and has a project idea (and a possible mentor in mind).
>> However, if you would like to see some new feature in PicoLisp and to
>> mentor the related project, it would be very helpfull too.
>>
>> A third (viable) option is to think about a project idea that is
>> beneficial for the PicoLisp community and doesn't require special
>> background (domain) knowledge from a (potential) mentor, but might be
>> interesting for students in general. That way, you can propose an idea
>> without being the student or mentor for that proposal.
>>
>> As an example, I would propose the project "Build a web-shop for
>> PicoLisp". Would that make sense? Any other ideas?
>>
>> If somebody has an idea but doesn't want to get involved with the
>> wiki, he can just post it here on the list, I put it on the wiki
>> then.
>>
>> Thanks
>
> If I can make it to participate as a student I'd like to make a more
> generic and portable web framework (in the sense of being able to deploy
> it in more kinds of servers than a dedicated/VPS with permission to run
> a server on a public port) Right now I have some work done in that
> direction with my "scgi.l" simple framework that is capable of running
> as a SCGI service, a CGI script and writing an HTTP backend it can also
> run as a standalone server (or actually, any protocol that has a
> CGI/HTTP-like interface can be adapted writing a backend) sharing most
> of the code (I have some code for that but i haven't published it yet
> because it's not complete/useful for anyone else than me at the
> moment).
>
> I have a formed idea for the "low level" design of the framework, as
> the internal protocol all backends "dump into" the app using a
> consistent interface (a set of global variables and functions).
>
> If you are allowed to run persistent processes in your server you
> would have at least these options for connecting the web application
> to the web (or a caching reverse proxy).
>
>  +---+    ++   +--+--++
>  |   | <->|   Web  |<->| SCGI <>         <

db new! performance

2012-05-29 Thread Joe Bogner
I'm evaluating the use of picolisp for analyzing large datasets. Is it
surprising that inserting a million rows into a simple db would take 5+
minutes on modern hardware? I killed it after that after about 500K were
inserted. I checked by ctrl+c and then inspecting N. It seems to
progressively get slower after about 100K records.

(pool "foo.db")
(class +Invoice +Entity)
(rel nr (+Key +Number))
(zero N)
(do 100 (new! '(+Invoice) 'nr (inc 'N)))

I have just testing out the concept. My input data will be a flat file of
invoice data (12 million rows+)

Thanks
Joe


Re: db new! performance

2012-05-30 Thread Joe Bogner
Thank you. That sped it up. It's taking 69 seconds to insert 1M records

(pool "foo.db")
(class +Invoice +Entity)
(rel id (+Key +Number))
(zero N)
(bench (do 100 (new (db: +Invoice) '(+Invoice) 'id (inc 'N)) ))
(commit)

I can work with that. Now I am testing out queries.

? (bench (iter (tree 'id '+Invoice) '((This) (inc 'Z (: id) )) )))
11.822 sec

? (bench (scan (tree 'id '+Invoice) '((Val Key) (inc 'Z Val )) )))
4.430 sec

It makes sense that scan would be fastest because I can use the index
directly. Is that likely the fastest query to sum up a number relation?

Thank you
Joe





On Wed, May 30, 2012 at 2:10 AM, Alexander Burger wrote:

> On Wed, May 30, 2012 at 12:28:50PM +0700, Henrik Sarvell wrote:
> > Use new and chunk it up:
> >
> >(dbSync)
> >(for A As
> >   (at (0 . 1000) (commit 'upd) (prune) (dbSync))
> >   (new (db: +Article) '(+Article) key1 value1 key2 value2 ... ))
> >(commit 'upd)
> >
> > With new! you are locking and writing every row so should only be used
> > in cases where you know you are only inserting one (or maybe very
> > few).
> >
> > Above we create them in memory and write 1000 of them at a time.
> >
> > If you have 12 million you should probably use an even higher number
> than 1000.
>
> Yes, I usually use 1. Larger values seem not to bring any further
> improvements, and use too much memory.
>
>
> You can slightly simplify and speed up the above, if you do not need to
> synchronize with other processes during that import (i.e. if other
> processes can wait until the import is done). Then you can omit the
> calls to 'commit' with 'upd' (signaling "done" to other processes) and
> the (dbSync) calls in the loop.
>
> And, in the final end, you could call (prune T) to reset to normal
> behavior, though not doing this will not have any bad effect.
>
> With that, we would have
>
>   (dbSync)
>   (for ...
>   (new (db: +Article) '(+Article) 'key1  'key2  ... )
>   (at (0 . 1) (commit) (prune)) )
>   (commit 'upd)
>   (prune T)
>
>
> Practically, I would also omit the 'prune' calls, and only insert them
> if I find that the import process uses too much money (monitor with
> 'top' or 'ps'). This speeds up small imports (which include 12 million
> objects).
>
> This would simplify the import to
>
>   (dbSync)
>   (for ...
>   (new (db: +Article) '(+Article) 'key1  'key2  ... )
>   (at (0 . 1) (commit)) )
>   (commit 'upd)
>
> Cheers,
> - Alex
> --
> UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe
>


Re: db new! performance

2012-05-30 Thread Joe Bogner
Hi Alex,

Thanks for the reply. Just for reference, using seq is actually
considerably slower. It ran in 39 seconds vs. 4 seconds. I think it's
because it has to look up every object from disk to get the value of 'id
instead of using the index which is likely in memory. The index appears to
be stored as a simple list of external symbols and the index value.  I'm
just guessing through.

Thanks,
Joe

On Wed, May 30, 2012 at 9:36 AM, Alexander Burger wrote:

> Hi Joe,
>
> > Thank you. That sped it up. It's taking 69 seconds to insert 1M records
> >
> > (pool "foo.db")
> > (class +Invoice +Entity)
> > (rel id (+Key +Number))
> > (zero N)
> > (bench (do 100 (new (db: +Invoice) '(+Invoice) 'id (inc 'N)) ))
> > (commit)
>
> You can further speed it up if you distribute objects and indices across
> separate files. For the above example:
>
>   (class +Invoice +Entity)
>   (rel id (+Key +Number))
>
>(dbs
>  (3 )# First file, 512 byte blocks
>  (2 +Invoice)# Second file, 256 byte blocks
>  (4 (+Invoice id)) ) # Third file, 1024 byte blocks
>
> This puts the '+Invoice' objects into the second file (with a block size
> of 256), and the 'id' index into the third (with a block size of 1024).
>
> The first file (with a block size of 512) is not specified to hold any
> entities here, so it contains only the administrative data (root and
> base objects).
>
>
> Then you must pass a directory (instead of a file name) and the database
> size specifications to 'pool':
>
>   (pool "foo.db/" *Dbs)
>
> If you have really large indexes (more than, say, 10 or 100 million
> entries), the you might experiment with an even larger block size (e.g.
> 6, giving 4096 byte blocks). In my experience performance goes down
> again if you use too large block sizes.
>
>
>
> > I can work with that. Now I am testing out queries.
> >
> > ? (bench (iter (tree 'id '+Invoice) '((This) (inc 'Z (: id) )) )))
> > 11.822 sec
> >
> > ? (bench (scan (tree 'id '+Invoice) '((Val Key) (inc 'Z Val )) )))
> > 4.430 sec
> >
> > It makes sense that scan would be fastest because I can use the index
> > directly. Is that likely the fastest query to sum up a number relation?
>
> Yes, it is surely faster than a Pilog query (though less powerful).
>
> The absolutely fastest, though, would be to use 'seq', i.e. avoid
> completely to use an index. This can be used occasionally, when
> (as in the above case) a file consists mainly of objects of a
> single type:
>
>   (bench
>  (for (This (seq (db: +Invoice)) This (seq This))
>  (inc 'Z (: id)) ) )
>
> If the file also might contain other objects, use this as the last line:
>
> (and (isa '+Invoice This) (inc 'Z (: id))
>
> Cheers,
> - Alex
> --
> UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe
>


Re: efficiently building a large list

2012-05-31 Thread Joe Bogner
Nice! (gc) was the trick.

I noticed lags still when doing a (gc 300) so I bumped it up to (gc 800)
 and it loaded 4M records in 34 seconds

I switched my code to use a (class +Invoice) and do everything in memory.

Calculating a SUM is very quick..

! (bench (let Amt 0 (mapc '((This) (inc 'Amt (: Amount))) List)))
1.152 sec

This is about the same amount of time as SQL server

I also benchmarked against R and Julia. Julia choked at around 2GB of ram
and then just spun and spun. R loaded the file in about the same amount of
time and was able to do a SUM very quickly. It choked when I was doing an
aggregate by customer number.

Sidebar: Is there a way to disable the interactive session from printing
the return of a statement? For example, if I do a (setq ABC L) where L is a
million items, I'd prefer the option of not having all million items print
on my console. I've worked around this by wrapping it in a prog and
returning NIL. Is there an easier way?

The next thing I'm working on is aggregating sums by customer. So far, (by)
and (group) have been too slow. I was pleasantly surprised to see accu run
well

! (bench (mapc '((X) (accu 'Sum X 1)) CustomerNumbers))
13.137 sec

I was expecting that I could use idx as an alternative, but I can't seem to
get it to come back in a reasonable time

As a simple test to get a list of unique customers

! (bench (mapc '((X) (idx 'UniqueCustomers X T)) CustomerNumbers))
163.309 sec

Am I doing something wrong with idx? I'm wondering if accu runs better
because I remember reading that picoLisp internally uses hashes for symbols
and properties and I think accu is using a property of the symbol to store
the values.

Thanks again

Joe





On Thu, May 31, 2012 at 12:16 PM, Alexander Burger wrote:

> > using, e.g. (gc 250) instead, to pre-allocate memory. This avoids that
> > the garbage collector runs again and again.
>
> BTW, 'proc' is very useful here to check the process size:
>
> $ pil +
> : (proc 'pil)
>  PID  PPID  STARTED  SIZE %CPU WCHAN  CMD
> 25575  1831 18:14:55  1512  0.3 -  /usr/bin/picolisp
> /usr/lib/picolisp/lib.l
> -> T
>
> : (gc 250)
> -> 250
>
> : (proc 'pil)
>  PID  PPID  STARTED  SIZE %CPU WCHAN  CMD
> 25575  1831 18:14:55 258512 2.8 -  /usr/bin/picolisp
> /usr/lib/picolisp/lib.l
> -> T
> :
>
> Cheers,
> - Alex
> --
> UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe
>


Re: efficiently building a large list

2012-05-31 Thread Joe Bogner
Thanks Tomas, I've started using nil now.

 This is what I came up with to aggregate the data. It actually runs
reasonably well. I'm sharing because I always enjoy reading other people's
picoLisp code so I figure others may as well.

My source file has 4 million rows

: (bench (pivot L 'CustNum))
35.226 sec

# outputs 31,000 rows.

My approach is to load it in as follows:

(class +Invoice)
(rel CustNum (+String))
(rel ProdNum (+String))
(rel Amount (+Number))
(rel Quantity (+Number))

(de Load ()
  (zero N)
  (setq L (make (
  (in "invoices.txt"
(until (eof)
  (setq Line (line) )
  (setq D (mapcar pack (split Line "^I")))
  (link (new
'(+Invoice)
'CustNum (car (nth D 1))
'ProdNum (car (nth D 2))
'Amount (format (car (nth D 3)))
'Quantity (format (car (nth D 4))) )) ) ) ) ) ) T )


I can probably clean this up.  I tinkered around with various approaches
and this was the best I could come up with in a few hours. At first I was
using something like the group from lib.l but found it to be too slow. I
think it was due to the fact that I optimize for a sorted list instead of
scanning for a match in the made list

(de sortedGroup (List Fld)
  (make
(let (Last NIL LastSym NIL)
 (for This List
  (let Key (get This Fld)
(if (<> Last Key)
(prog
(if LastSym (link LastSym))
(off LastSym)
(push 'LastSym Key)) )
 (push 'LastSym This)
 (setq Last Key) ) )
 (link LastSym)) ) )

And here's the piece that ties it all together:

(de pivot (L Fld)
  (let (SL (by '((X) (get X Fld)) sort L) SG (sortedGroup SL Fld))
(out "pivot.txt"
  (for X SG
(let (Amt 0)
  (mapc '((This) (inc 'Amt (: Amount))) (cdr (reverse X)))
  (setq Key (get (car X) Fld))
  (prinl Key "^I" Amt) ) ) ) ) )


(Load)

: (bench (pivot L 'CustNum))
35.226 sec

: (bench (pivot L 'ProdNum))
40.945 sec

It seems the best performance was by sorting, then splitting and then
summing the individual parts. It also makes for a nice report.

Sidenote: At first I thought I was getting better performance by using a
modified version of quicksort off rosetta code, but then I switched it to
the built-in sort and saw considerably better speed.

Thanks for the help everyone

On Thu, May 31, 2012 at 3:37 PM, Tomas Hlavaty  wrote:

> Hi Joe,
>
> > Sidebar: Is there a way to disable the interactive session from
> > printing the return of a statement? For example, if I do a (setq ABC
> > L) where L is a million items, I'd prefer the option of not having all
> > million items print on my console. I've worked around this by wrapping
> > it in a prog and returning NIL. Is there an easier way?
>
> you could also use http://software-lab.de/doc/refN.html#nil or
> http://software-lab.de/doc/refT.html#t
>
> Cheers,
>
> Tomas
> --
> UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe
>


Re: efficiently building a large list

2012-06-02 Thread Joe Bogner
Hi Henrik -

Thanks for sharing. I used your approach and it ran quickly after I built
the index using balance.

(bench (setq  SL (by '((X) (get X 'CustNum)) sort L))) T)
(bench (setq SLC (mapcar '((This) (: CustNum)) SL)) T)
(off A) (bench (balance 'A SLC T))

I'm stumped one piece. If I run the below code multiple times then my total
increases

: (Sum)
4.466 sec
-> 495029119
: (Sum)
4.497 sec
-> 990058238
: (Sum)
4.507 sec
-> 1485087357

(de Sum ()
  (zero Amount)
  (bench
(for This SL
  (let (Key (: CustNum) Amt (: Amount) Idx (idx 'A Key))
(setq Amt (if Amt Amt 0))
(inc 'Amount Amt) #check figure to make sure it sums up

# the val of the cell is by default a customer number, set it to be
0 if it's non-numeric
(ifn (num? (val (car Idx))) (set (car Idx) 0))

(set (car Idx) (+ (val (car Idx)) Amt)) ) ) )
  (sum '((X) (car X)) (idx 'A)) )


I don't know exactly how to phrase the question. I'm storing the total in
the val of the cell (I think). I would have thought it was in the val of
the cell stored in the index. However, if I

(off A) (bench (balance 'A SLA T))

, it still duplicates.

If I run this first, it clears it out: (for X (idx 'A) (set (car (idx 'A
X)) 0))

Where is the value being stored such that I need to set each value of the
cell to 0 regardless of rebuilding  the index?


Here's a simple example that I used to understand the concept:

: (setq Z "abc")
-> "abc"
: (val Z)
-> "abc"
: (set Z 0)
-> 0
: (val Z)
-> 0
: (set Z (+ (val Z) 1))
-> 1
: (val Z)
-> 1
: Z
-> "abc"

Like your example, I think I'm storing the number in the val of the symbol
(cell).

I apologize for the long winded question

Thanks
Joe




On Fri, Jun 1, 2012 at 1:38 AM, Henrik Sarvell  wrote:

> I noticed you were talking about idx.
>
> The below code is from vizreader and was part of a system that counted
> and stored all the non-common words in every article:
>
> # We extract all words from the article without special characters and
> count them
> (dm words> (L)
>   (let Words NIL
>  (for W L
> (and
>(setq W (lowc (pack W)))
>(not (common?> This W))
>(if (idx 'Words W T)
>   (inc (car @))
>   (set W 1
>  (idx 'Words)))
>
> It is using idx and summing up the occurrences of each word and turned
> out to be the fastest way of solving that problem anyway, maybe it's
> helpful to you.
>
>
>
>
> On Fri, Jun 1, 2012 at 10:33 AM, Joe Bogner  wrote:
> > Thanks Tomas, I've started using nil now.
> >
> >  This is what I came up with to aggregate the data. It actually runs
> > reasonably well. I'm sharing because I always enjoy reading other
> people's
> > picoLisp code so I figure others may as well.
> >
> > My source file has 4 million rows
> >
> > : (bench (pivot L 'CustNum))
> > 35.226 sec
> >
> > # outputs 31,000 rows.
> >
> > My approach is to load it in as follows:
> >
> > (class +Invoice)
> > (rel CustNum (+String))
> > (rel ProdNum (+String))
> > (rel Amount (+Number))
> > (rel Quantity (+Number))
> >
> > (de Load ()
> >   (zero N)
> >   (setq L (make (
> >   (in "invoices.txt"
> > (until (eof)
> >   (setq Line (line) )
> >   (setq D (mapcar pack (split Line "^I")))
> >   (link (new
> > '(+Invoice)
> > 'CustNum (car (nth D 1))
> > 'ProdNum (car (nth D 2))
> > 'Amount (format (car (nth D 3)))
> > 'Quantity (format (car (nth D 4))) )) ) ) ) ) ) T )
> >
> >
> > I can probably clean this up.  I tinkered around with various approaches
> and
> > this was the best I could come up with in a few hours. At first I was
> using
> > something like the group from lib.l but found it to be too slow. I think
> it
> > was due to the fact that I optimize for a sorted list instead of scanning
> > for a match in the made list
> >
> > (de sortedGroup (List Fld)
> >   (make
> > (let (Last NIL LastSym NIL)
> >  (for This List
> >   (let Key (get This Fld)
> > (if (<> Last Key)
> > (prog
> > (if LastSym (link LastSym))
> > (off LastSym)
> > (push 'LastSym Key)) )
> >  (push 'LastSym This)
> >  (setq Last Key) ) )
> >  (link LastSym)) ) )
> >
> > And here's the piece that ties it all together:
&

Re: efficiently building a large list

2012-06-02 Thread Joe Bogner
To be more clear, this is the call pattern that I'm referring to:

: (for X (idx 'A) (set (car (idx 'A X)) 0)) (Sum)
4.492 sec
-> 495029119
: (for X (idx 'A) (set (car (idx 'A X)) 0)) (Sum)
4.451 sec
-> 495029119
: (for X (idx 'A) (set (car (idx 'A X)) 0)) (Sum)
4.519 sec
-> 495029119
:
As you can see, clearing it before calling Sum gives the correct results.

On Sat, Jun 2, 2012 at 6:08 PM, Joe Bogner  wrote:

> Hi Henrik -
>
> Thanks for sharing. I used your approach and it ran quickly after I built
> the index using balance.
>
> (bench (setq  SL (by '((X) (get X 'CustNum)) sort L))) T)
> (bench (setq SLC (mapcar '((This) (: CustNum)) SL)) T)
> (off A) (bench (balance 'A SLC T))
>
> I'm stumped one piece. If I run the below code multiple times then my
> total increases
>
> : (Sum)
> 4.466 sec
> -> 495029119
> : (Sum)
> 4.497 sec
> -> 990058238
> : (Sum)
> 4.507 sec
> -> 1485087357
>
> (de Sum ()
>   (zero Amount)
>   (bench
> (for This SL
>   (let (Key (: CustNum) Amt (: Amount) Idx (idx 'A Key))
> (setq Amt (if Amt Amt 0))
> (inc 'Amount Amt) #check figure to make sure it sums up
>
> # the val of the cell is by default a customer number, set it to
> be 0 if it's non-numeric
> (ifn (num? (val (car Idx))) (set (car Idx) 0))
>
> (set (car Idx) (+ (val (car Idx)) Amt)) ) ) )
>   (sum '((X) (car X)) (idx 'A)) )
>
>
> I don't know exactly how to phrase the question. I'm storing the total in
> the val of the cell (I think). I would have thought it was in the val of
> the cell stored in the index. However, if I
>
> (off A) (bench (balance 'A SLA T))
>
> , it still duplicates.
>
> If I run this first, it clears it out: (for X (idx 'A) (set (car (idx 'A
> X)) 0))
>
> Where is the value being stored such that I need to set each value of the
> cell to 0 regardless of rebuilding  the index?
>
>
> Here's a simple example that I used to understand the concept:
>
> : (setq Z "abc")
> -> "abc"
> : (val Z)
> -> "abc"
> : (set Z 0)
> -> 0
> : (val Z)
> -> 0
> : (set Z (+ (val Z) 1))
> -> 1
> : (val Z)
> -> 1
> : Z
> -> "abc"
>
> Like your example, I think I'm storing the number in the val of the symbol
> (cell).
>
> I apologize for the long winded question
>
> Thanks
> Joe
>
>
>
>
> On Fri, Jun 1, 2012 at 1:38 AM, Henrik Sarvell  wrote:
>
>> I noticed you were talking about idx.
>>
>> The below code is from vizreader and was part of a system that counted
>> and stored all the non-common words in every article:
>>
>> # We extract all words from the article without special characters and
>> count them
>> (dm words> (L)
>>   (let Words NIL
>>  (for W L
>> (and
>>(setq W (lowc (pack W)))
>>(not (common?> This W))
>>(if (idx 'Words W T)
>>   (inc (car @))
>>   (set W 1
>>  (idx 'Words)))
>>
>> It is using idx and summing up the occurrences of each word and turned
>> out to be the fastest way of solving that problem anyway, maybe it's
>> helpful to you.
>>
>>
>>
>>
>> On Fri, Jun 1, 2012 at 10:33 AM, Joe Bogner  wrote:
>> > Thanks Tomas, I've started using nil now.
>> >
>> >  This is what I came up with to aggregate the data. It actually runs
>> > reasonably well. I'm sharing because I always enjoy reading other
>> people's
>> > picoLisp code so I figure others may as well.
>> >
>> > My source file has 4 million rows
>> >
>> > : (bench (pivot L 'CustNum))
>> > 35.226 sec
>> >
>> > # outputs 31,000 rows.
>> >
>> > My approach is to load it in as follows:
>> >
>> > (class +Invoice)
>> > (rel CustNum (+String))
>> > (rel ProdNum (+String))
>> > (rel Amount (+Number))
>> > (rel Quantity (+Number))
>> >
>> > (de Load ()
>> >   (zero N)
>> >   (setq L (make (
>> >   (in "invoices.txt"
>> > (until (eof)
>> >   (setq Line (line) )
>> >   (setq D (mapcar pack (split Line "^I")))
>> >   (link (new
>> > '(+Invoice)
>> > 'CustNum (car (nth D 1))
>> > 'ProdNum (car (nth D 2))
>> > 'Amount (forma

Re: efficiently building a large list

2012-06-03 Thread Joe Bogner
Thank you. Very helpful.

I was confused where the value was actually being stored. I was thinking
that in my example it was being stored in the cell in the index. Then, I
couldn't figure out how it retained it's value after I cleared out the
index.

Turns out that it actually stored it back on the original symbol that held
the customer number string.

I'm fairly clear now on it. Definitely an interesting deep dive


On Sun, Jun 3, 2012 at 4:23 AM, Alexander Burger wrote:

> On Sat, Jun 02, 2012 at 06:10:05PM -0400, Joe Bogner wrote:
> > To be more clear, this is the call pattern that I'm referring to:
> >
> > : (for X (idx 'A) (set (car (idx 'A X)) 0)) (Sum)
> > ...
> > As you can see, clearing it before calling Sum gives the correct results.
>
> OK, so this makes sense (also the assumption in my last mail about the
> idx values). You clear the values of the payload items.
>
>
> Note that 'X' in the above loop already contains the payload items
> (symbols or cells). So looking them up again is not necessary. You can
> write
>
>   (for X (idx 'A) (set X 0))
>
>
> A second note: (idx 'A) collects all items in the _whole_ index tree
> into a list. This makes sense only for small trees, of course, and is
> not used often in production code.
>
> Cheers,
> - Alex
> --
> UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe
>


Re: pilog solver

2012-07-26 Thread Joe Bogner
Thank you. My researched suggested that it was possible with other prolog
implementations so I wasn't sure if I was missing something simple in pilog.

I also wasn't sure if with a simple problem space I could combine something
like permute with a known range of possibilities. In the example below, I
could generate a list of the whole numbers from 1-100 for the acreage and
then have some helper functions to test for ranges. I wouldn't need to
solve for a real number.

It sounds like there are better ways to do it. I was hoping to come up with
something as nicely declarative/expressive as pilog that didn't have a
bunch of conditionals. I could probably use some dsl though. I have no
experience with pilog and was interested in an application of it.

Thanks again




On Thu, Jul 26, 2012 at 11:31 AM, Alexander Burger wrote:

> On Thu, Jul 26, 2012 at 04:02:07PM +0200, Henrik Sarvell wrote:
> > I can't say for sure if prolog is a good fit or not. The problems seems a
> > little bit too arithmetic maybe but do not trust my word on it.
>
> I also don't think that Prolog or Pilog are well suited for that.
>
> Linear programming is an optimization technique, often employing the
> simplex algorithm where you solve a number of linear equations by
> "pivot"ing their terms. I think this can be easier solved in plain Lisp
> than in Pilog.
>
> Cheers,
> - Alex
> --
> UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe
>


Re: pilog solver

2012-07-26 Thread Joe Bogner
My interest also piqued when I saw the amb example in rosettacode. It seems
like that could be combined with something to backtrack if a permutation
goes out of bounds.

http://www.randomhacks.net/articles/2005/10/11/amb-operator

On Thu, Jul 26, 2012 at 12:21 PM, Joe Bogner  wrote:

> Thank you. My researched suggested that it was possible with other prolog
> implementations so I wasn't sure if I was missing something simple in pilog.
>
> I also wasn't sure if with a simple problem space I could combine
> something like permute with a known range of possibilities. In the example
> below, I could generate a list of the whole numbers from 1-100 for the
> acreage and then have some helper functions to test for ranges. I wouldn't
> need to solve for a real number.
>
> It sounds like there are better ways to do it. I was hoping to come up
> with something as nicely declarative/expressive as pilog that didn't have a
> bunch of conditionals. I could probably use some dsl though. I have no
> experience with pilog and was interested in an application of it.
>
> Thanks again
>
>
>
>
> On Thu, Jul 26, 2012 at 11:31 AM, Alexander Burger 
> wrote:
>
>> On Thu, Jul 26, 2012 at 04:02:07PM +0200, Henrik Sarvell wrote:
>> > I can't say for sure if prolog is a good fit or not. The problems seems
>> a
>> > little bit too arithmetic maybe but do not trust my word on it.
>>
>> I also don't think that Prolog or Pilog are well suited for that.
>>
>> Linear programming is an optimization technique, often employing the
>> simplex algorithm where you solve a number of linear equations by
>> "pivot"ing their terms. I think this can be easier solved in plain Lisp
>> than in Pilog.
>>
>> Cheers,
>> - Alex
>> --
>> UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe
>>
>
>


Re: pilog solver

2012-07-28 Thread Joe Bogner
I pushed forward and implemented a solution using Alex's amb rosettacode
solution. It's probably not optimal but it runs really quick 0.08 seconds
for 100 acres. It grows to 5 seconds for 1000 acres.

Please forgive any style issues

"Example: A farmer has 100 acres on which to plan oats or corn. Each acre
of oats requires $18 capital and 2 hours of labor. Each acre of corn
requires $36 capital and 6 hours of labor. Labor costs are $8 per hour. The
farmer has $2100 available for capital and $2400 available for labor. If
the revenue is $55 from each acre of oats and $125 from each acre of corn,
what planting combination will produce the greatest total profit? What is
the maximun profit?"

(be amb (@E @Lst)
   (lst @E @Lst) )

(setq Oats (new NIL '+Choice 'capital 18 'labor 2 'revenue 55))
(setq Corn (new NIL '+Choice 'capital 36 'labor 6 'revenue 125))
(setq LaborCost 8)
(setq CapitalAvailable 2100)
(setq LaborAvailable 2400)

(de laborCost (OatAcre CornAcre)
(+
(* LaborCost (* OatAcre (get Oats 'labor)))
(* LaborCost (* CornAcre (get Corn 'labor))) ) )

(de capitalCost (OatAcre CornAcre)
(+
(* OatAcre (get Oats 'capital))
(* CornAcre (get Corn 'capital))) )

(de totalRevenue (OatAcre CornAcre)
(+
(* OatAcre (get Oats 'revenue))
(* CornAcre (get Corn 'revenue))) )

(be isValid (@OatsAcre @CornAcre)
(@Labor laborCost (-> @OatsAcre) (-> @CornAcre))
(@Capital capitalCost (-> @OatsAcre) (-> @CornAcre))
(@Revenue totalRevenue (-> @OatsAcre) (-> @CornAcre))

(@Valid and
(<= (-> @Capital) CapitalAvailable)
(<= (-> @Labor) LaborAvailable) )
(@ push 'Solutions (list (-> @Revenue) (-> @OatsAcre) (-> @CornAcre)))
(or
  ((equal @Valid T))
  ((amb @ NIL)) ) )

(be problem ((@Choice1 @Choice2))
(@Acres range 1 100)
(amb @Choice1 @Acres)
(amb @Choice2 @Acres)
(isValid @Choice1 @Choice2) )

(off Solutions)
(bench (solve '((problem @X))) T)
(printsp "Maximal solution: " (maxi val Solutions)

: .083 sec
: Maximal solution: (6890 48 34)

Which is really close to the real number solution given in the problem

"The values in B5 and B6 should have become 50 and 33.3, and that the
maximum profit is $6916.6 and your spreadsheet will look like the
following. Thus x=50 and y=33.3 are the number of acres that the farmer
should devote to oats and corn, respectively. "

Fun!


On Thu, Jul 26, 2012 at 12:39 PM, Alexander Burger wrote:

> Hi Joe,
>
> > Thank you. My researched suggested that it was possible with other prolog
> > implementations so I wasn't sure if I was missing something simple in
> pilog.
>
> Should be no problem to translate it, if you have a solution in Prolog.
> But, as we said, it is probably not really useful.
>
>
> > I also wasn't sure if with a simple problem space I could combine
> something
> > like permute with a known range of possibilities.
>
> Yeah, this might work in this special case. But for general linear
> programming problems, other algorithms are much better.
>
> Cheers,
> - Alex
> --
> UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe
>


Re: Cygwin bad file descriptor error.

2012-08-12 Thread Joe Bogner
Hi Michiel,

It appears to be an issue with fork under cygwin. I've duplicated your same
problem. I've ran into similar issues with fork under windows/cygwin and
found it to be unstable.  You can google to find other instances:
http://cygwin.com/ml/cygwin/2012-06/msg00331.html, I came across this
several months ago as well to see if there's a way to eliminate the fork:
http://social.msdn.microsoft.com/Forums/en-US/windowsgeneraldevelopmentissues/thread/afdf1b68-1f3e-47f5-94cf-51e397afe073,
but found it to be a dead end. In the end, I've used cygwin for light, non
web work and then used a virtual image otherwise. I've also tinkered with
ersatz and web -  http://picolisp.com/5000/!wiki?ErsatzWebApp for the same
reasons.

Specifically windows error 6 seems to be an issue with an invalid handle. I
suspect fork() is having an issue sharing the handle in the new process.

I suggest avoiding fork() altogether. As a proof of concept, you can
redefine server() to not use fork. This may introduce other errors. I've
only done limited testing with it.

This example works for me and prints out the # of hits that have been
stored in the db.

testwindows.l

(load "@lib/http.l" )

(de server (P H)
   (setq
  *Port P
  *Port1 P
  *Home (cons H (chop H))
  P (port *Port) )
   (gc)
   (loop
  (setq *Sock (listen P))
  (http *Sock)
  (close *Sock) ) )

(de mytest ()
   (prinl "hello")
   (put! (get *DB) 'hits (inc (get *DB 'hits)))
   (prinl (get *DB 'hits))
   (prinl (val *DB)) )

(de go ()
   (pool "testdb1" )
   (or (get *DB 'hits) (put! (get *DB) 'hits 0))
   (prinl (val *DB) ) #does not give an error
   (server 8080 "!mytest") )

Hope that helps in some way.

Thanks
Joe


On Fri, Aug 10, 2012 at 11:58 PM, Michiel van Oosten  wrote:

> Hi,
>
> I ran into the same problem as Yechiel described in an earlier email to this 
> mailing list (quoted at the bottom).
>
> I did as Alexander suggested in his email to Yechiel,  and got the following 
> results:
>
> ---
>
> Running in cygwin on Windows7 64 bit with the following in testwindows.l
>
> (load "@lib/http.l" )
>
> (de mytest ()
>   (prinl "hello")
>   (val *DB) #gives the error
>  )
>
> (de go ()
>(pool "testdb1" )
>(val *DB) #does not give an error
>(server 8080 "!mytest") )
>
> results go to standard out, written to the file straceout:
>
> $ pil testwindows.l -go &
> [1] 6868
>
> $ strace -p 6868 1>straceout
> DB read: Bad file descriptor
> ? *DB
> -> {1}
> ? (val *DB)
> DB read: Bad file descriptor
>
>
> [Control-c]
>
>

> Hi Michiel,
>
>
> thanks for the strace info.
>
> However, the output from cygwin's strace looks completely different from
> the one under Linux, and unfortunately it doesn't include any
> information which helps to locate the program's execution, like strings
> read or printed (only addresses like in "write(2, 0x200106CC, 29))".
> This makes it almost impossible to follow what the program is actually
> doing.
>
>
> > Seems to run into windows error 6 a number of times. Doesn't mean
>
> Yes, but I'm not sure if this is really an error condition. It seems to
> happen always after some obscure 'seterrno_from_nt_status' call, so
> perhaps it is just some normal administrative processing?
>
> > anything to me, but maybe to you or somebody else?
>
> Sorry, no. And I also cannot try as I have nether Windows nor Cygwin.
>
> Cheers,
> - Alex
>
> ---
>
> Hopefully somebody has some ideas or solutions, it would be nice to be able 
> to use a fully working picolisp with a minimal cygwin as a kind of portable, 
> easily deployable full database/web server//gui bundle on windows.
>
> Regards,
>
> Michiel
>
>
> ---
>
> Quoted from earlier email to mailinglist:
>
> Hi Yechiel,
>
> > but I got this error:
> >
> > "DB read: Bad file descriptor" and localhost 8080 is waiting
>
>


Re: Android Demo

2012-10-10 Thread Joe Bogner
Hi Thorsten,

Thanks for asking. I haven't done any work on the topic since I last
posted about it. I haven't built any real apps using PicoLisp on
Android. On the other hand, I haven't built any real apps for Android
using any technology, so it's more a matter of not having a need vs it
being the wrong choice.

For those who are curious, here is the last wiki article about it:
http://picolisp.com/5000/!wiki?AndroidWebServer

I'd be interested in hearing if anyone has a need or has created a
PicoLisp app on Android

Joe

On Tue, Oct 9, 2012 at 1:06 PM, Thorsten Jolitz  wrote:
> Doug Snead 
> writes:
>
> Hi Joe and Doug,
>
> I read up your conversations about PicoLisp on Android in the mailing
> list and your articles in the Wiki about the topic:
>
>> Ok, so now this means we can package some picolisp client/server
>> applications as android apps, using the android browser. (I think.) I
>> like that approach because it works with the android browser and app
>> packaging scheme - and at the same time you're getting picolisp in all
>> its glory and efficiency.
>
> I don't have an Android device to try out your code examples, but I
> would be interested in the 'status quo' of this topic - is full PicoLisp
> running on Android, have there been any real Apps implemented in
> PicoLisp by somebody?
>
> If so - are there any cons of using PicoLisp instead of Java to be
> considered?
>
> --
> cheers,
> Thorsten
>
> --
> UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe
-- 
UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe


Re: pil64emu testing features

2012-11-02 Thread Joe Bogner
Hi Alex,

pil64emu sounds very interesting. In case it helps, here is some output
from running pil64emu

joebo@joebo:~/tmp/picolisp$ ./pil +
: *CPU
-> "emu"
: (load "misc/fibo.l")
/usr/bin/ld: skipping incompatible
/usr/lib/gcc/i486-linux-gnu/4.4.5/libgcc.a when searching for -lgcc
/usr/bin/ld: skipping incompatible
/usr/lib/gcc/i486-linux-gnu/4.4.5/libgcc.a when searching for -lgcc
/usr/bin/ld: cannot find -lgcc
collect2: ld returned 1 exit status
-> NIL
:

Here is my uname output:

Linux 2.6.32-5-686-bigmem #1 SMP Wed Jan 12 04:40:25 UTC 2011 i686 GNU/Linux

I'm running Debian 6.0

I tried some very basic picolisp operations and they worked fine.

I haven't done any native work since I had been running 32bit and so I
don't know if there's something broken on my install or if it's an issue
with pil64emu. In any case, I wanted to share my findings.

Thank you !

Joe




On Fri, Nov 2, 2012 at 3:47 PM, Jon Kleiser  wrote:

> Hi Alex,
>
> > On Fri, Nov 02, 2012 at 05:38:40PM +0100, Alexander Burger wrote:
> >> For some reason, fcntl() doesn't work. It workes on pil32, I believe.
> >
> > Perhaps found the reason. I've changed the calling pattern of fcntl().
> > Please try once more.
> >
> > Cheers,
> > - Alex
>
> At least something has changed during the make:
>
> MacBook-Air:picoLispEmu jkleiser$ (cd src64; make)
> emu.base.c: In function ‘run’:
> emu.base.c:42115: warning: format not a string literal and no format
> arguments
> emu.base.c:42170: warning: format not a string literal and no format
> arguments
> MacBook-Air:picoLispEmu jkleiser$ ./pil +
> [/Users/jkleiser/.pil/history:1] File lock: Invalid argument
> ?
> : (== 64 64)
> -> T
> : *CPU
> -> "emu"
> : (load "misc/fibo.l")
> [misc/fibo.l:40] !? (here "/**/")
> here -- Undefined
> ?
> : (bye)
> MacBook-Air:picoLispEmu jkleiser$ ./bin/picolisp
> : (load "misc/fibo.l")
> [lib/native.l:31] !? (** 2 32)
> ** -- Undefined
> ?
> : (bye)
> MacBook-Air:picoLispEmu jkleiser$ ./bin/picolisp misc/fibo.l
> [misc/fibo.l:38] !? (load "@lib/native.l")
> "@lib/native.l" -- Open error: No such file or directory
> ?
> : (bye)
>
> /Jon
>
> --
> UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe
>


Re: pil64emu testing features

2012-11-04 Thread Joe Bogner
Hi Alex, Thank you for the reply.

I had the same issue on another machine. I was able to get this working by
changing the gcc args to -m32 in lib/native.l instead of -m64

  (apply call L 'gcc "-o" (tmp Nm)
   "-fPIC" "-m32" "-shared" "-export-dynamic"
   "-O" "-falign-functions" "-fomit-frame-pointer"
   "-W" "-Wimplicit" "-Wreturn-type" "-Wunused" "-Wformat"
   "-Wuninitialized" "-Wstrict-prototypes"
   "-pipe" "-D_GNU_SOURCE" (tmp Nm ".c") ) ) )


I was then able to call cFibo successfully

joe@joe-linux:~/tmp/picolisp$ ./pil +
: *CPU
-> "emu"
: (load "misc/fibo.l")
-> NIL
: (cFibo 3)
-> 2
: cFibo
-> ((N) (native "/home/joe/.pil/tmp/7311/fibo" "Fibo" 'I N))
:


I don't know enough about this to offer an opinion on whether -m64 is
appropriate on a 32bit machine. It sounds like it's possible to cross
compile to 64 bit with supporting libraries but I don't think it'd be
possible to execute it.

Joe


On Sat, Nov 3, 2012 at 3:04 AM, Alexander Burger wrote:

> Hi Joe
>
> > joebo@joebo:~/tmp/picolisp$ ./pil +
> > : *CPU
> > -> "emu"
> > : (load "misc/fibo.l")
> > /usr/bin/ld: skipping incompatible
> > /usr/lib/gcc/i486-linux-gnu/4.4.5/libgcc.a when searching for -lgcc
> > /usr/bin/ld: skipping incompatible
> > /usr/lib/gcc/i486-linux-gnu/4.4.5/libgcc.a when searching for -lgcc
> > /usr/bin/ld: cannot find -lgcc
> > collect2: ld returned 1 exit status
>
> Strange. A problem of incompatible library installations?
>
>
> > Linux 2.6.32-5-686-bigmem #1 SMP Wed Jan 12 04:40:25 UTC 2011 i686
> GNU/Linux
>
> Nearly the same as I have:
>
> Linux lab 2.6.32-5-686 #1 SMP Sun Sep 23 09:49:36 UTC 2012 i686 GNU/Linux
>
>
> > I'm running Debian 6.0
>
> I have squeeze with some sprinkles of wheezy and sid.
>
>
> > I tried some very basic picolisp operations and they worked fine.
>
> So the problem seems mainly with the loading of dynamic libs.
>
>
> > I haven't done any native work since I had been running 32bit and so I
> > don't know if there's something broken on my install or if it's an issue
> > with pil64emu. In any case, I wanted to share my findings.
>
> Sure. Many thanks!
>
> Cheers,
> - Alex
> --
> UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe
>


Re: A few quick emu/pil timings

2012-11-06 Thread Joe Bogner
I ran a similar test the other day. Here are my timings with (fibo 33) and
 (cFibo 33)

I'm including cFibo (since I can now run it on emu64) and ersatz.

emu64: 21.632 sec
emu64/cFibo: 0.111 sec
pil32: 4.477 sec
ersatz: 12.797 sec




On Tue, Nov 6, 2012 at 11:04 AM, Alexander Burger wrote:

> Hi Jon,
>
> > I installed the latest "ongoing" (v3.1.0.12) on my iMac, and
> > compared the timing results of (bench (fibo 33)). Not too useful, I
> > was just curious. ;-)
>
> Yeah, interesting :)
>
>
> > pil32: 0.804 sec
> > emu64: 10.032 sec
> >
> > My EmuLisp in Safari: 5.82 sec
> > My EmuLisp in Chrome: 8.102 sec
> > My EmuLisp in Chromium: 8.261 sec
> >
> > The fibo used in all cases was this:
> > (de fibo (N) (if (>= 2 N) 1 (+ (fibo (dec N)) (fibo (- N 2)
> >
> > And the returned value was 3524578. ;-)
>
> If I try this on an x86-64 machine having all of them installed (pil32,
> pil64 and emu64), I get:
>
>pil32:   0.89 sec
>pil64:   0.42 sec
>emu64:   12.3 sec
>
> All quite similar (with the same result, 3524578).
>
>
> I did also tests with the chess program, getting similar relations. You
> can let play it against itself, with e.g.:
>
>$ time ./pil games/chess.l -main -'do 12 (msg (go))' -bye
>
>
> A database stress, however, running 40 concurrent processes hammering
> data into the database, showed a drop in speed for emu of only a factor
> of three. Here the bottleneck is in file I/O, locking etc.
>
> Cheers,
> - Alex
> --
> UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe
>


Re: Rosetta Code analysis

2012-11-07 Thread Joe Bogner
Sorry - here is the link: http://picolisp.com/5000/!wiki?RosettaCodeAnalysis


On Wed, Nov 7, 2012 at 12:13 PM, Joe Bogner  wrote:

> Hi All,
>
> I added a wiki article that includes some basic analysis of the Rosetta
> Code solutions. At several points I've tried to memorize the usage of all
> the PicoLisp functions. I'm getting closer to retaining it, however I may
> use this list as a way to prioritize my learning.
>
> I considered hyperlinking to the relevant reference for the function page
> but didn't have the time to include that - specifically due to things like
> the Globals. The alpha ones are pretty straightforward to map.  I may
> update the article in the future with the links.
>
> I'm sharing in case others find it useful / interesting
>
> Joe
>


picostache - mustache implementenation

2012-11-14 Thread Joe Bogner
I've created a mustache (a template system) implementation in PicoLisp.
I've been seeking an alternative way to build HTML that allows for more
separation of logic and the view.

You can find it here: https://bitbucket.org/joebo/picostache/

I'm very interested in feedback on the implementation and the usefulness of
it.

In my initial benchmarks it seems "very fast" but it's hard to really
compare yet. In http benchmarking it seemed to have a negligible difference
on requests per second (maybe a 5-10% decline) over just (prinl "hello
world"). Not very scientific. It can render a million loops in < 5 seconds
(again, not scientific) and depends on the complexity of the template.

Hope others find it useful. It was fun to write.

Joe


Re: picostache - mustache implementenation

2012-11-15 Thread Joe Bogner
Alex, thanks for the feedback!

This is my first time running lintAll - great suggestion!

It looks like it's suggesting that I have a bunch of unbound variables.
Probably because I don't have my globals prefixed with * which is against
the naming convention.

Is that a correct high level interpretation? I tested it by replacing Model
with *Model and those warnings went away.

(lintAll)

output:

(((revise> . +Date) (def datStr expDat))
((print> . +Date) (def datStr))
(section (def Func) (bnd X Subview Model Func))
(testRender (def Section NonSection Name) (bnd Names Model Tree))
(addCell (bnd Cur RootPtr CurType))
(update (def set!>))
(select (def goal))
(testParse (def Section Name) (bnd Names Model Expected Template Html))
(_update (def put!> mis>))
(context (def Func) (bnd Model Func))
(parse (bnd Cur RootPtr Root)))

I think I understand the warnings on the test* functions too. Definitely a
good idea to run before publishing a library for others. thanks!




On Thu, Nov 15, 2012 at 1:31 PM, Alexander Burger wrote:

> Hi Joe,
>
> > I've created a mustache (a template system) implementation in PicoLisp.
> > You can find it here: https://bitbucket.org/joebo/picostache/
>
> Nice! :)
>
>
> > I'm very interested in feedback on the implementation and the usefulness
> of
> > it.
>
> Concerning the implementation, there are a few glitches. I'd recommend
> to call
>
>: (lintAll)
>
> in debug mode, and then fix the diagnoses one by one ;-)
>
> ♪♫
> - Alex
> --
> UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe
>


pilog - using range

2012-11-21 Thread Joe Bogner
I'm having trouble figuring out how to use range in a simple pilog example.

I can use member:

(be add1-or-double (@X @Num)
  (member @X (1 2 3 4))
  (@Ans + 1 (-> @X))
  (@Ans2 * 2 (-> @X))
  (or ((equal @Num @Ans)) ((equal @Num @Ans2

(? (add1-or-double @X 4))
@X=2 @X=3:



If I try this:

(be add1-or-double (@X @Num)
  # (member @X (1 2 3 4))
  (@X range 1 100)
  (@Ans + 1 (-> @X))
  (@Ans2 * 2 (-> @X))
  (or ((equal @Num @Ans)) ((equal @Num @Ans2

(? (add1-or-double @X 100))
 (1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52
53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77
78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100) --
Number expected

I've tried using (car (-> @X)) and that didn't work either...

I suspect I am approaching this wrong. I will gladly accept feedback that
points to a different direction to take

Thanks!
Joe


Re: pilog - using range

2012-11-22 Thread Joe Bogner
Alex,

Thank you as always. Very helpful

By the way, I am reading "Programming in Prolog" by Clocksin/Mellish per
the recommendation on the reference page. I have spent a fair amount of
time reading various prolog tutorials and this book is really clicking for
me.  Thanks again for the recommendation.

For the list, I have found these lectures to be really good too:
http://vimeo.com/user8713508/videos . It filled in alot of the "why" that
was left uncovered in many of the tutorials. The book is doing a great job
as well.

Joe


On Nov 22, 2012 2:56 AM, "Alexander Burger"  wrote:

> Hi Joe,
>
> > (be add1-or-double (@X @Num)
> >   (member @X (1 2 3 4))
> >   (@Ans + 1 (-> @X))
> >   (@Ans2 * 2 (-> @X))
> >   (or ((equal @Num @Ans)) ((equal @Num @Ans2
> >
> > (? (add1-or-double @X 4))
> > @X=2 @X=3:
>
> OK
>
>
> > If I try this:
> >
> > (be add1-or-double (@X @Num)
> >   # (member @X (1 2 3 4))
> >   (@X range 1 100)
>
> 'range/3' is a predicate, not a generator. You can use it only for
> range checks like:
>
>: (? (range (1 . 5) 3))
>-> T
>: (? (range (1 . 5) 7))
>-> NIL
>
> Its main purpose is for database queries, to be used as a filter for
> numeric or date values.
>
>
> Instead, you might consider using 'for/2'
>
>(be add1-or-double (@X @Num)
>  (for @X 4)
>  (@Ans + 1 (-> @X))
>  (@Ans2 * 2 (-> @X))
>  (or ((equal @Num @Ans)) ((equal @Num @Ans2))) )
>
>
> To generate an unlimited supply of numbers, you could write
>
>(be number (@N)
>   (@C box 0)
>   (repeat)
>   (@N inc (-> @C)) )
>
>(be add1-or-double (@X @Num)
>  (number @X)
>  (@Ans + 1 (-> @X))
>  (@Ans2 * 2 (-> @X))
>  (or ((equal @Num @Ans)) ((equal @Num @Ans2))) )
>
> Note, however, that this won't terminate.
>
> ♪♫
> - Alex
> --
> UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe
>


Re: New Article about 'for'

2012-11-24 Thread Joe Bogner
Hi Thorsten,

Great article! Thank you for sharing. I spent a bit of time trying to
figure out how to use 'for' when I started. The article would have been
very helpful then.

Joe
 On Nov 24, 2012 1:39 AM, "Thorsten Jolitz"  wrote:

>
> Hi List,
>
> I published an article about the (somehow a bit complicated) for
> function in the PicoLisp Wiki, its quite pedestrian, but at least it
> helped its author to better understand the different forms of 'for'.
>
> You can find it here:
> http://picolisp.com/5000/!wiki?deeperLookAtFor
>
> --
> cheers,
> Thorsten
>
>
> --
> UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe
>


Re: PicoLisp and Redis

2012-11-25 Thread Joe Bogner
Henrik,

Thank you for sharing. I have also thought about using redis for session
state.

Just curious on the coding style, why did you choose to use a class? I have
noticed some of your other code uses classes too. In general I think of
using classes to encapsulate state or to group related functions.

I tend to use picolisp in more of a functional form possibly because its a
breath of fresh air after 10 years of oop in c#.  I sometimes wonder when
its a good fit to mix in oop in picolisp.

Thanks
Joe
On Nov 25, 2012 2:20 PM, "Henrik Sarvell"  wrote:

> Hi everyone, at work I use Redis ( http://redis.io/ ) for various things
> such as session data, to avoid as much disk scratching as possible (I've
> configured it to only live in memory).
>
> I thought it would be interesting to see how much work it would take to
> implement a Redis client in PL, as it happens not much.
>
> The most interesting part of the documentation for the purpose:
> http://redis.io/topics/protocol
> http://redis.io/topics/data-types
>
> The below is by no means a complete client that can handle all scenarios
> but I thought I might just put it "out there". In case someone else gets
> the same idea they won't have to start from scratch.
>
> (class +Redis)
>
> (dm e> (Cmd . @)
>(let? Sock (connect "localhost" 6379)
>   (prog1
>  (out Sock
> (prinl "*" (+ 1 (length (rest))) "^M")
> (for Arg (append (list Cmd) (rest))
>(prinl "$" (size Arg) "^M")
>(prinl (pack Arg "^M")) )
> (flush)
> (in Sock
>(let? Res (char)
>   (cond
>  ((= Res "+") (line T))  #status
>  ((= Res ":") (any (line T)))#integer
>  ((= Res "$")#bulk
>   (let Length (peek)
>  (if (= Length "-")
> NIL
> (line)
> (line T) ) ) )
>  ((= Res "*")#multi bulk
>   (let Length (any (line T))
>  (if (member Length '("0" "-"))
> NIL
> (make
>(do Length
> (line)
> (link (line T)) ) ) ) ) )
>  (T NIL) ) ) ) )
>  (close Sock) ) ) )
>
> (de redis (Cmd . @)
>(apply 'e> (rest) '+Redis (uppc Cmd)))
>
> (println (redis 'set "key" "value"))
> (println (redis 'get "monkey"))
> (println (redis 'get "key"))
> (println (redis 'lpush "monkeys" "orangutang"))
> (println (redis 'lpush "monkeys" "gorilla"))
> (println (redis 'lpush "monkeys" "schimpanzee"))
> (println (redis 'lrange "monkeys" 0 2))
>
>
> Output:
> "OK"
> NIL
> "value"
> 1
> 2
> 3
> ("schimpanzee" "gorilla" "orangutang")
>
>


Re: making in a loop - or an sequentially building a nested list

2012-11-26 Thread Joe Bogner
Here's a naive implementation:

(de list-make ("Lst")
  (queue "Lst" "("))

(de list-link ("Lst" Node)
  (queue "Lst" Node)
  (queue "Lst" " "))

(de list-close ("Lst")
  (queue "Lst" ")"))


(de list-close-all ("Lst")
  (let (Open (length (sect (val "Lst") (list "(" )))
Close (length (sect (val "Lst") (list ")" 
  (for X (- Open Close)
(queue "Lst" ")")))
(car (str (pack (val "Lst")

(setq L NIL)
(list-make 'L)
(list-make 'L)
(list-link 'L 'parent)
(list-make 'L)
(list-link 'L 'child)
(list-link 'L 'child)
(list-close-all 'L)

-> ((parent (child child)))

I don't know how I feel about it...


On Mon, Nov 26, 2012 at 1:11 PM, Joe Bogner  wrote:

> I'm sure I'm making this harder than it is. I spent several hours
> tinkering around trying to find a way to sequentially build a nested list.
>
> make and link have spoiled me.
>
> Instead of this:
>
> : (make (link (make (link 'parent (make (link 'child 'child))
> -> ((parent (child child)))
>
> or
>
> : (list (list 'parent (list 'child 'child
> -> ((parent (child child)))
>
> I would like to do
>
> (setq L NIL)
> (list-make 'L)
> (list-make 'L)
> (list-link 'L 'parent)
> (list-make 'L)
> (list-link 'L 'child)
> (list-link 'L 'child)
>
> Or something along those lines. The reason for the question is that I find
> myself building things in for loops and it seems like I would need to use
> some form of recursion to build it with make or list.
>
> I've had some success with push and queue but was wondering if there's a
> more elegant way.
>
>


Re: New Emacs-style command-line editor

2012-11-29 Thread Joe Bogner
Thanks Thorsten!

I will give it a shot. This gives me a reason to try emacs again for
picolisp. I installed everything the other day and then switched back to vi
and vi mode in the repl after getting frustrated with not knowing how to
cycle through my command history in inferior-picolisp. I am so used to
 k j

After some googling tonight I found how to cycle using


   - M-p (comint-previous-input)
   Select the previous command in the input history.

   - M-n (comint-next-input)
   Select the next command in the input history.


It might be nice to add this and any other tricks to your emacs style page.

By the way, if no one has tried it yet, ConqueTerm makes a nice alternative
to inferior-lisp when using vim. I typically run it in a split. I've found
the paren matching to be somewhat slow when it copies in the text so
sometimes I'll just skip ConqueTerm altogether and map a key to run pil on
the file I'm working on.




On Thu, Nov 29, 2012 at 5:27 PM, Thorsten Jolitz wrote:

>
> Hi List,
>
> I just posted a reference article on the wiki
> (http://picolisp.com/5000/!wiki?emacsstyleled) that explains how to
> activate and use the new Emacs-style command-line editor developed by me
> (with some help from Alex).
>
> You can try it out with the new testing version 3.1.0.15 available on
> the download page. Feedback is welcome. The goal is that Emacs users
> feel right at home at the PicoLisp command-line - that its possible to
> switch between the REPL and Emacs almost without being aware of changing
> the application (like switching between Emacs and Conkeror).
>
> There is still some functionality to add, but it works already quite
> good, I use it all the time now. I would be highly appreciated if Emacs
> users could test it and report bugs.
>
> --
> cheers,
> Thorsten
>
>
> --
> UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe
>


Re: New Emacs-style command-line editor

2012-11-29 Thread Joe Bogner
Thorsten - Thanks for the reply. I tried it and it works great - just as
expected. It works very well on my phone too which had some trouble with
the terminal program switching in and out of vi mode due to the poor
handling of Esc. I will definitely be using this


On Thu, Nov 29, 2012 at 10:15 PM, Thorsten Jolitz wrote:

> Joe Bogner  writes:
>
> Hi Joe,
>
> > I will give it a shot. This gives me a reason to try emacs again for
> > picolisp. I installed everything the other day and then switched back
> > to vi and vi mode in the repl after getting frustrated with not
> > knowing how to cycle through my command history in inferior-picolisp.
> > I am so used to  k j
>
> there is something superior to inferior-picolisp out there: Tomas
> Hlavaty's slime/swank mode for PicoLisp. He recently posted the link to
> his git-repo on the mailing list. Thats a top point on my agenda to make
> that mode work for me and replace inferior-picolisp.
>
>
I will have to look into that further. Thanks for the suggestion


> However, I found it very frustrating to be totally lost on the PicoLisp
> command-line (since I don't know nothing about vi). And I do think that
> the PicoLisp philosophy (live in the command-line, open an editor on
> demand) does have its merits sometimes. Therefore I wrote the
> Emacs-style editor. Its still alpha, but now I can use the PicoLisp line
> editor in a 'natural way' (for an Emacs user), just like I use the Bash
> command-line in Emacs mode "without thinking".
>
>
I have spent the last year learning emacs and what I've found is (my
personal experience, not a flame war) that emacs can be more efficient and
natural when creating new content - either code or text. Vim is more
efficient for me when changing large amounts of code or refactoring. That
may come with time in emacs.


> > After some googling tonight I found how to cycle using
> >
> > * M-p (comint-previous-input)
> >   Select the previous command in the input history.
> >
> >
> > * M-n (comint-next-input)
> >   Select the next command in the input history.
> >
> >
> > It might be nice to add this and any other tricks to your emacs style
> > page.
>
>
> Thats already implemented, but I used C-p and C-n instead of M-p and M-n
> since there is only only line in the REPL and and C-p and C-n can't
> server as line-up and line-down in a buffer. However, I could change
> that anytime.
>
>
Works like a charm


> > On Thu, Nov 29, 2012 at 5:27 PM, Thorsten Jolitz
> >  wrote:
> >
> >
> > Hi List,
> >
> > I just posted a reference article on the wiki
> > (http://picolisp.com/5000/!wiki?emacsstyleled) that explains how
> > to
> > activate and use the new Emacs-style command-line editor developed
> > by me
> > (with some help from Alex).
> >
> > You can try it out with the new testing version 3.1.0.15 available
> > on
> > the download page. Feedback is welcome. The goal is that Emacs
> > users
> > feel right at home at the PicoLisp command-line - that its
> > possible to
> > switch between the REPL and Emacs almost without being aware of
> > changing
> > the application (like switching between Emacs and Conkeror).
> >
> > There is still some functionality to add, but it works already
> > quite
> > good, I use it all the time now. I would be highly appreciated if
> > Emacs
> > users could test it and report bugs.
> >
> > --
> > cheers,
> > Thorsten
> >
> >
> > --
> > UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe
> >
> >
> >
>
> --
> cheers,
> Thorsten
>
> --
> UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe
>


Re: New Emacs-style command-line editor

2012-11-30 Thread Joe Bogner
Hi Alex,


Are the "arrow keys" usable on the phone? Both the vi- and the
> emacs-style command line in PicoLisp now also support arrow keys
> for navigating the history.
>

Yes, they work great. One less keypress. Great!

Thorsten, Alex -

Would it be possible to add hooks to the emacs line editor? I came up with
a rough patch to demonstrate what I mean. I wanted to minimize the number
of changes to eled but had some problems due to needing to reference the
transient symbols. Also, I'm still pretty basic when it comes to my
understanding on the best way to do things.

In any case:

Change #1 - lib/eled.l add a hook to the front of the insMode case list

(de insMode ("C")
   (if (= "C" "^I")
...
  (case "C"
 ~(car (list *EmacsKeyHook))
 ("^?"



Change #2 - lib/eled.l add a method to wrap the transients and invoke a
block

(de EmacsHook Prg
  (let (_Line "Line" _chgLine chgLine)
(eval (car Prg ))) )


>From these two changes, I can inject my own functions such as this one to
automatically close parens

Let's say I have an init.l

(de closeParens (Line)
  (let (Open (length (sect Line (list "(" )))
Close (length (sect Line (list ")" 
(make
  (for X Line (link X))
  (for X (- Open Close) (link ")")

(setq *EmacsKeyHook '(("^y" (EmacsHook (let L (closeParens _Line) (_chgLine
L (length L)))


I can then run:

/pil init.l -em +

: '(a (b (c 

and have it automatically close my open parens

I'm sure there's other ways to do this but wanted to share the concept

Thanks again for the new feature

Joe


org mode parser

2012-12-14 Thread Joe Bogner
Hello all,

I've written a tiny org-mode parser and hooked it up with my mustache
implementation to create a simple web page that dumps out the org
structure. I'm not sure where I'm going to go next but figured I'd share it
since I enjoy reading other's code as well.

I'm amazed at what can be done in 42 lines of picolisp :-) (looking at
org.l)

https://bitbucket.org/joebo/pico-org/src

I have it running with a random org mode file I found at
http://csilo.com/org/

By the way - I like the new ref page look & feel (
http://software-lab.de/doc/ref.html). The sort alphabetically is also handy.

Joe


Re: org mode parser

2012-12-15 Thread Joe Bogner
Alex - thank you as always for the code suggestions!

Thorsten - I just added PROPERTIES parsing and preliminary tag parsing and
now we're at 90 lines. I think it will take a bit more to get to 5000 ;)




On Sat, Dec 15, 2012 at 9:01 AM, Thorsten Jolitz wrote:

> Alexander Burger  writes:
>
> Hi Joe,
>
> >> https://bitbucket.org/joebo/pico-org/src
> >
> > Thanks for sharing! Thorsten will be delighted too ;-)
>
> Indead, delighted and surprised, I just talked about an Org-mode parser
> with Alex yesterday and recently had a look at the official Org-mode
> parser in Emacs Lisp (org-element.el) that is almost 5000 lines of code
> in contrast to your 50 lines ;)
>
> I think the combination of Org-mode and PicoLisp is quite interesting.
>
> --
> cheers,
> Thorsten
>
> --
> UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe
>


picolisp org-mode blog

2013-01-05 Thread Joe Bogner
Hello all -

Over the holiday I made some progress on the org-mode parser and rolled it
into a blog engine.

It's still very much a work in progress yet wanted to share it with the
group for some early feedback. The cosmetics of the blog are last on my
list.

https://bitbucket.org/joebo/picoblogorg

It still has a fair amount of debug code and cleanup left so it's not
really ready yet for primetime.

I figure it may be a useful example for someone wanting to build a picolisp
web app using an alternative to the gui framework. A real app would likely
also use the picolisp DB which I haven't needed to do in this app.

I switched over my site to use it and am going to continue to post some
updates as I go: http://csilo.com

Cheers,
Joe


Re: SEXP?

2013-07-01 Thread Joe Bogner
Hi Thorsten,

I've used fun? to determine if an argument had the proper form of something
that was executable or if it was data. It may not work in all cases, but it
was sufficient for my use case.  As Alex mentioned, it won't let you know
whether it's actually executable or not. I think of it as having the
potential to be executable.

Joe


On Mon, Jul 1, 2013 at 4:50 AM, Thorsten Jolitz  wrote:

> dexen deVries 
> writes:
>
> > On Monday 01 of July 2013 07:39:49 you wrote:
> >> Hi Thorsten,
> >>
> >> > I wonder if there is a way in PicoLisp to check if some function
> >> > argument is a SEXP, i.e. if something like a function 'sexp? exists
> that
> >> > returns T if the argument is a SEXP.
> >
> >
> > how about (pair 'any) ? basically the opposite of (atom 'any)
>
> thats probably what I was looking for, thanks, besides the fact that
> Alex is of course right about the difficulties with doing these kind of
> tests in a dynamic environment.
>
> --
> cheers,
> Thorsten
>
> --
> UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe
>


Re: Bitmessage Mailing List for PicoLisp

2013-08-29 Thread Joe Bogner
Hi Alex -

Do we also need the chan name?  I tried PicoLisp

I tried joining and the Bitmessage client says "Although the Bitmessage
address you entered was valid, it doesn't match the chan name."

Thanks
Joe


On Thu, Aug 29, 2013 at 9:24 AM, Alexander Burger wrote:

> Hi all,
>
> in case some of you like to experiment with Bitmessage, I have now
> created a "PicoLisp" mailing list!
>
> Bitmessage is a P2P communications protocol used to send encrypted
> messages to another person or to many subscribers. For details, see
>
>https://bitmessage.org
>
> If you installed the Bitmessage client, you can join the PicoLisp
> mailing list by subscribing to the address:
>
>BM-2D9k6jt6wxipHH7ABwbDB43zBWj67Bw3U7
>
> Let's see if and how it works out :)
>
> ♪♫ Alex
> --
> UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe
>


Re: Bitmessage Mailing List for PicoLisp

2013-08-29 Thread Joe Bogner
Got it! Thanks. I'm trying it out for the first time


On Thu, Aug 29, 2013 at 10:02 AM, Alexander Burger wrote:

> Hi Joe,
>
> > Do we also need the chan name?  I tried PicoLisp
>
> I didn't create a "chan" (Decentralized Mailing List), as this involves
> possible spam issues. Just a plain mailing list as described in
>
>https://bitmessage.org/wiki/Mailing_List
>
> As I understand it, you can simply send messages to the given address.
>
>
> > I tried joining and the Bitmessage client says "Although the Bitmessage
> > address you entered was valid, it doesn't match the chan name."
>
> I think you can simply add the address to the "Subscriptions" tab in the
> client. Then you should receive all posted messages as broadcasts.
>
> ♪♫
> --
> UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe
>


Re: Ext library and file name indexer

2013-08-31 Thread Joe Bogner
Hi Henrik

Thanks for sharing. I have a few picolisp repos on bitbucket too.

https://bitbucket.org/joebo

Includes my orgmode parser, mustache template implementation, and blog. All
have been running flawlessly for 8 continuous months.

I have read Alex's comments on the stability of picolisp over the years. It
is neat to experience it myself - especially since I am no expert at the
language.

Joe
 Anything newer than Subversion is pretty much equal in my book, that
includes both darcs, hg and git. They're all so simple that it doesn't make
sense spending time "shopping" in that area once you've settled for one of
them, at least not for my use case.

I use hg at work so I use bitbucket, it's as simple as that. Would not
dream of learning yet another vcs when hg just works for me.


On Sat, Aug 31, 2013 at 7:52 PM, Tamas Herman  wrote:

> henrik,
>
> there is http://hub.darcs.net/ with no limitations whatsoever on anything.
> darcs is a lot more logical version control system.
> it's a lot easier to remember it's options.
> it's interactive by default.
> avoids tons of merge conflicts automatically.
> it doesn't try to invent branching/forking, since
> every clone of a repo IS A branch or fork naturally.
> it's is very easy to install, since it's just 1 static exe on any platform.
>
> for such small sources what picolisp has,
> it's an overkill to use anything else...
> it's really the kind of tool which doesn't get in the way, unlike git.
> you can see tons of pull requests are talking about git,
> instead of the patch itself. people are struggling with it
> for years and years now...
>
> i admire how much simplicity could you showcase with picolisp;
> it's makes me feel bad if you let such dirt as git or hg touch its source
> ;)
>
> --
>   tom
> --
> UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe
>


Re: Great canvas article and demo

2013-09-15 Thread Joe Bogner
Tomas,

That is interesting!

I was playing around with your demo and ran a little bookmarklet that would
refresh the stepped version automatically.

I first included jquery through a bookmarklet. Then, I pasted this into my
javascript console window:

var refresh = function(location) {
$.get(location, function(x) {
var $html = $(x);
var url = $html.find('a:contains(step)').attr("href");
console.log(url);
var svg = $html.find('svg');
$('svg').replaceWith(svg.get(0));
setTimeout(function() { refresh(url) }, 500)
})
}
refresh($('a:contains(step)').attr("href"));

I think this appears more seamless (like the iframe approach) instead of
doing a full page refresh.

It looks like Alex's approach is about 15x lighter on the wire. I ran
fiddler and it looks like it transmits upwards of 639 bytes for a full
chart whereas the svg is around 9500 bytes. Still, it's an neat
alternative!



On Sun, Sep 15, 2013 at 12:51 PM, Tomas Hlavaty  wrote:

> Hi Alex,
>
> as a proof of concept, I have implemented your zapper demo using svg and
> without any javascript, see http://logand.com:2234/
>
> Tomas Hlavaty  writes:
> > Another way of achieving the same result without any need for
> > javascript would be using SVG.  It works very well across browsers
> > nowadays.  Canvas could be an iframe with a refresh rate if required
> > and SVG could be inlined in the HTML, generated in a similar way as
> > the usual PicoLisp generated HTML.  As an added bonus, SVG could
> > contain links which could trigger picolisp actions without the need
> > for calculating positions on server side (because the browser would do
> > this work for us), should the users wish to inspect a point in the
> > demo graph.
>
> 1) It uses svg instead of canvas, meaning that:
>
>   - There is no javascript required for drawing stuff.  The same
> approach to generating html can be used to generate svg.
>
>   - It's easy to define parts of the picture to be clickable, so if you
> click on a point in the graph, the text clicked will be updated with
> the y axis value, as an example.  Also it displays a buuble if you
> leave cursor above a point.
>
>   - svg used to be slow, broken and non-portable across browsers a few
> years ago but these days, it's rather good for many use-cases.
> There are still some things broken on some browsers, but it's
> getting steadily better.
>
>   - Graphics transformation can be easily specified in svg, so there is
> no need to do "complicated" coordinate calculations. e.g.
>
> 
>
> changes the orientation and origin of the coordinate system, and
> also moves the centres of lines a bit so that 1px lines are sharp
> (which is what you discussed with Jon I guess, and which your
> example doesn't do for the horizontal axis I think).
>
> 2) The example doesn't use any javascript meaning that the maximum
>refresh speed is 1s.  This is good enough for many use-cases.  If
>not, a bit of javascript can be added in a similar way like the
>current picolisp refresh is implemented.  As you mentioned, something
>like the +Auto class.
>
>If the automatic refresh is not desirable for the whole page, the
>whole svg graph could be put into an iframe which would refresh, but
>the surounding html would stay.  But it's not critical for this demo.
>
> 3) Bug: If you click too fast or at the same time as refresh happens,
>the browser and session can get out of sync and it will stop reacting
>to click, unfortunately.  I have to figure out why.  If that happens,
>simply open the link again, or just discard the "s" query parameter.
>
> Generally I find svg much better than using canvas, which is too low
> level.  In picolisp, one could write similar functions like for html, or
> use the '' function to generate arbitrary svg.
>
> Enjoy:-)
>
> Tomas
> --
> UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe
>


Re: Some initial questions

2013-09-25 Thread Joe Bogner
I remember finding this reference very helpful as well:
http://pleac.sourceforge.net/pleac_picolisp/index.html

These quick guides have been cropping up lately on my news feeds -
http://learnxinyminutes.com/ . Is anyone interested in doing one for
PicoLisp? It's been on my maybe-someday list for awhile.

Here is common lisp and elisp versions:

http://learnxinyminutes.com/docs/common-lisp/

http://learnxinyminutes.com/docs/elisp/




On Wed, Sep 25, 2013 at 8:45 AM, Thorsten Jolitz  wrote:

> "O.Hamann"  writes:
>
> Hi,
>
> > There is not much help found by searching google (stackoverflow and
> similar)
> > for best practices or 'oneliner'
>
> But there is
>
> ,---
> | http://de.scribd.com/doc/103733857/PicoLisp-by-Example
> `---
>
> easily searchable online with 'C-f', i.e. in total some 700 or so
> PicoLisp solutions for a wide range of Computer Science problems, all
> written by the master (Alex ;) himself.
>
> I don't think many non-mainstream languages offer such a huge pool of
> examples written on expert level and easily searchable online or in a
> local pdf.
>
> And of course there is
>
> ,--
> | http://de.scribd.com/doc/103732688/PicoLisp-Works
> `--
>
> too, another easy to search ressource with almost all documents written
> about PicoLisp until 2012.
>
> Have fun ...
>
> --
> cheers,
> Thorsten
>
> --
> UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe
>


Re: Some initial questions

2013-09-26 Thread Joe Bogner
Hi Luis,

I've built a proof of concept PicoLisp apk and ran it on a Droid X and my
kindle fire. I wrote about it here:
http://www.mail-archive.com/picolisp@software-lab.de/msg03114.html

I was able to build the entire apk using terminal ide on my android (no
android SDK).

I'm happy to answer any questions about it. I didn't take it any farther
than this.  I don't know if it would pass Play Store policy or not.

Joe






On Thu, Sep 26, 2013 at 7:15 PM, Luis P. Mendes  wrote:

> Thank you all for your messages!
>
> Henrik:
> It's good to know that database speed is compared to major RDBMs.
> PicoLisp having an integrated database is a big plus for the language.
>
> Alex:
> Thank you for providing the community such a powerful language that
> for sure has many many hours of hard work.
> As you say, the ones that come to PicoLisp are the ones who do the
> effort to find a programming language.
> As everything else in life, either people are satisfied with
> propaganda that others try to push, or people choose to find their own
> ways. I'm glad I'm between people who have the latter attitude.
>
> Enough of philosophy, I'll just ask you something more, since my
> searches in google were not conclusive.
> I've seen this:
> http://picolisp.com/5000/!wiki?AndroidWebServer
> and
> http://www.mail-archive.com/picolisp@software-lab.de/msg03081.html [-]
> Will .apk android applications be supported by PicoLisp in the future?
>
> Olaf:
> Nice to hear that you're also starting with PicoLisp.
> As recommended in the PicoLisp Reference, I'll start reading the book
> "Lisp" by Winston/Horn.
>
> Thorsten and Joe:
> Thank you for the links!
>
>
> Now it's time to start learning!
>
>
> Luis
> --
> UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe
>


PicoLisp parsing example

2013-10-07 Thread Joe Bogner
Hello,

In the interest of sharing PicoLisp related content, I recently wrote up a
solution[1] to a problem[2] posted in a J forum.

https://gist.github.com/joebo/6813083

I also ended up creating a J solution too[3]

The PicoLisp solution was a joy to write and actually turned out to be a
bit longer than I anticipated. I wanted a nice balance between clarity and
being concise.

Cheers,
Joe

[1] http://jsoftware.com/pipermail/chat/2013-October/005372.html
[2] http://jsoftware.com/pipermail/chat/2013-October/005363.html
[3] http://jsoftware.com/pipermail/chat/2013-October/005383.html


Re: Pre-compiled picolisp for CentOS, Cygwin, OSX

2013-11-01 Thread Joe Bogner
Thanks Keith. The cygwin one is helpful. The last time I compiled it
is a few years ago and haven't reconfigured cygwin on this machine to
build

On Fri, Nov 1, 2013 at 10:20 AM, Keith Kim  wrote:
> Hello,
>
> I've uploaded pre-compiled picolisp for CentOS6 (32 and 64bit), OSX and
> Cygwin:
>
> http://blog.keithkim.com/2013/11/pre-compiled-picolisp-for-centos-and.html
>
> Well, it's very easy and no trouble compiling them for anyone, but just for
> convenience.
>
> BR,
>
> Keith Kim
>
>
> --
> UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe
-- 
UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe


Re: Creation stamp

2014-02-10 Thread Joe Bogner
Henrik - Thank you for posting the code. I enjoyed tinkering around with
it. The inserts took a long time --- I stopped after about 30m and then
added some timing info. I think it was taking about 20 seconds per day and
that time will grow if I recall correctly. I am guessing it would take 2-3
hours to insert the 31M rows (on SSD and a xen environment) and a fair
amount of disk space. I think I was up to about 2 gig with 50 days.

I may look further into experimenting with different block sizes:
https://www.mail-archive.com/picolisp@software-lab.de/msg03304.html

If you end up speeding up please share. I know it's just a mock example so
may not be worth the time. It's nice to have small reproducible examples.

It's neat to hear that the queries are sub second.

Thanks
Joe




On Sun, Feb 9, 2014 at 6:24 AM, Henrik Sarvell  wrote:

> "Yes, a bit perhaps."
>
> I tested, it is of no consequence (at least for my applications), given
> one transaction per second for a full year, fetching a random +Ref +String
> day takes a fraction of a second on my PC equipped with SSD, here is the
> code:
>
> Note that it's only the collect at the end that takes a fraction of a
> section, the insertions do NOT.
>
> (class +Transaction +Entity)
> (rel amount (+Number))
> (rel createdAt (+Ref +String))
>
> (dbs
>(4 +Transaction)
>(4 (+Transaction createdAt)) )
>
> (pool "/opt/picolisp/projects/test/db/db" *Dbs)
>
> (setq Sday (date 2013 01 01))
> (setq Eday (+ Sday 364))
> (setq F (db: +Transaction))
>
> (for (D Sday (>= Eday D) (inc D))
>(for (S 1 (>= 86400 S) (inc S))
>   (let Stamp (stamp D S)
>  (println Stamp)
>  (new F '(+Transaction) 'amount 100 'createdAt Stamp) ) )
>(commit)
>(prune) )
>
> (commit)
> (prune T)
>
> (println (collect 'createdAt '+Transaction "2013-10-05 00:00:00"
> "2013-10-05 23:59:59"))
>
> (bye)
>
>
>
>
> On Sat, Feb 8, 2014 at 5:44 PM, Alexander Burger wrote:
>
>> Hi Henrik,
>>
>> On Fri, Feb 07, 2014 at 08:29:07PM +0700, Henrik Sarvell wrote:
>> > Given a very large amount of external objects, representing for instance
>> > transactions, what would be the quickest way of handling the creation
>> stamp
>> > be with regards to future lookups by way of start stamp and end stamp?
>> >
>> > It seems to me that using two relations might be optimal, one +Ref +Date
>> > and an extra +Ref +Time. Then a lookup could first use the +Date
>> relation
>> > to filter out all transactions that weren't created during the specified
>> > days followed by (optionally) a filter by +Time.
>>
>> You could use two separate relations, but then I would definitely
>> combine them with '+Aux'
>>
>>(rel d (+Aux +Ref +Date) (t)) # Date
>>(rel t (+Time))   # Time
>>
>> In this way a single B-Tree access is sufficient to find any time range.
>> For example, to find all entities between today noon and tomorrow noon:
>>
>>(collect 'd '+Mup
>>   (list (date) (time 12 0 0))
>>   (list (inc (date)) (time 11 59 59)) )
>>
>>
>> Another possibility is using not two separate relations, but a single
>> bag relation
>>
>>(rel ts (+Ref +Bag) ((+Date)) ((+Time)))  # Timestamp
>>
>> This saves a little space in the objects, but results in the same index
>> entry format.
>>
>>
>> But anyway, in both cases a single index tree is used. In the first case
>> you also have the option to define the time as
>>
>>(rel t (+Ref +Time))  # Time
>>
>> with an additional separate index, so that you can search also for
>> certain time ranges only (no matter what the date is).
>>
>>
>> > Or am I over-thinking it, is a simple +Ref +Number with a UNIX
>> timestamp an
>> > easier approach that is just as fast?
>>
>> I think this would not make any difference in speed (regarding index
>> access), but would have some disadvantages, like having to convert this
>> format to/from PicoLisp date and time values, and being limited in range
>> (the Unix timestamp cannot represent dates before 1970).
>>
>>
>> > A +Ref +String storing the result of a call to stamp would be ideal as
>> the
>> > information is human readable without conversions. However, I suspect
>> that
>> > a start-end lookup on it would be much slower than the above, or?
>>
>> Yes, a bit perhaps. Parsing and printing human readable date and time
>> values is simple in PicoLisp (e.g. with 'date', 'stamp', 'datStr' and
>> related functions, see http://software-lab.de/doc/refD.html#date).
>>
>> ♪♫ Alex
>> --
>> UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe
>>
>
>


Re: Creation stamp

2014-02-10 Thread Joe Bogner
Hey Alex -

On Mon, Feb 10, 2014 at 9:31 AM, Alexander Burger wrote:

> Also, you can save quite some time if you pre-allocate memory, to avoid
> an increase with each garbage collection. I would call (gc 800) in the
> beginning, to allocate 800 MB, and (gc 0) in the end.
>


Thanks for the reminder about gc I remember you mentioning it over a year
ago: https://www.mail-archive.com/picolisp@software-lab.de/msg03308.html. I
added the gc and completed 30 days of import in two minutes. I also
switched to my i7 (under cygwin too) vs my xen virtual host. It ended up
using 2.7 gig of disk so I had to stop it.  Again, I'm reminded and
impressed with the speed.

Thanks
Joe


Re: Would a logging framework make sense for PicoLisp

2014-02-25 Thread Joe Bogner
I like the idea of something simple and possibly built-in. However, would
it be possible to implement as a function that wraps definitions with a
redef and adds the logging?

http://software-lab.de/doc/refR.html#redef


On Tue, Feb 25, 2014 at 9:20 AM, Henrik Sarvell  wrote:

> Sometimes it's also nice to be able to get everything in a file, not
> just printed, would be nice if it could have that option.
>
> On Tue, Feb 25, 2014 at 6:50 PM, Thorsten Jolitz 
> wrote:
> >
> > Hi List,
> >
> > sometimes I start putting a lot of (maybe too many) 'msg calls in my
> > code for debugging purposes, what then triggers memories of logging
> > frameworks for Java I once read about.
> >
> > Would it make sense to add such a logging framework to the language as a
> > kind of third debugging tool (besides trace and debug)? I was thinking
> > about something along the line of
> >
> >  - a new global variable *Log
> >  - two new functions 'log and 'unlog
> >  - an equivalent to ! as debugging breakpoint (e.g. § or whatever as
> >logging point)
> >
> > *Log would then be NIL or one of several logging levels
> > (e.g. 1,2,3). (log func) would then put § before all expressions of a
> > function, (unlog func) remove them. Depending on the logging level, §
> > would do nothing or, e.g., print the expression and the results of
> > what (e) and (d) do during debugging, and maybe all variables with
> > their actual values in that expression.
> >
> > What do you think?
> >
> > --
> > cheers,
> > Thorsten
> >
> > --
> > UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe
> --
> UNSUBSCRIBE: mailto:picolisp@software-lab.de?subjectUnsubscribe
>


Re: Using OpenStreetMap Geo-Data with PicoLisp

2014-05-06 Thread Joe Bogner
Hi Alex, I look forward to reading the article. To load the videos only
when needed, you could take a screenshot of video and use that as the image
on the page. You could have a javascript click event that replaces the
image HTML with the  tag.  That's the first idea that came to mind.
I don't know if javascript is an option


On Tue, May 6, 2014 at 2:17 PM, Alexander Burger wrote:

> Hi all,
>
> after a lot of procrastination, I crunched out today an article about
> PicoLisp canvas programming, and the handling of geographic data from
> the OpenStreetMap project:
>
>http://picolisp.com/wiki/?osmGeoData
>
> I incorporated some short video sequences for better illustration.
>
> Perhaps this was not a good idea, as the picolisp.com server doesn't
> have a good upstream connection. There are in total four videos embedded
> in the document, and it seems that whenever the page is opened or
> refreshed, all those videos get reloaded.
>
> Any ideas? Is there some other way, i.e. having the videos loaded only
> when really needed?
>
> Anyway, I hope the article is useful :)
> ♪♫ Alex
> --
> UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe
>


Re: Regarding the implementations of PicoLisp

2014-05-09 Thread Joe Bogner
Hi Rick, Christophe,

I was thinking the same thing. miniPicolisp might be a simpler first step
to port


On Fri, May 9, 2014 at 7:51 AM, Rick Lyman  wrote:

> Christophe,
>
> How about porting the c version using:
> https://github.com/kripken/emscripten?
>
> -rl
>
>
> On Thu, May 8, 2014 at 5:08 PM, Christophe Gragnic <
> christophegrag...@gmail.com> wrote:
>
>> Hi,
>>
>> I'm currently embedding a «pedagogical pseudo-code like language» in
>> PicoLisp.
>> As using plain browsers is a nice thing to have in front of students,
>> I tried with
>> EmuLisp (PicoLisp in JS, by Jon Kleiser, that I won't thank enough, with
>> Alex),
>> which proved to be a good solution for me.
>>
>> So I had some thoughts, ideas and questions.
>>
>> 1) EmuLisp lacks some functions. The first idea I had was to write them
>> in the
>> available functions (like 'glue' with 'pack'). It worked for some, but
>> some others
>> needed to be implemented in JS. Now my question: how far could be pushed
>> the
>> idea to write a maximal subset of Picolisp in a minimal subset of
>> Picolisp? Like in
>> the original paper of McCarthy or «the Jewel» in SICP? I'm not talking
>> about
>> performance here, just functions availability.
>>
>> 2) Since PicoLisp64 is written in a «generic assembly» embedded in
>> PicoLisp,
>> I was wondering (only wondering, since the concepts are a bit vague for
>> me) if
>> instead of building the .s files we could build some 
>> http://asmjs.org/file(s).
>>
>> 3) Regarding EmuLisp again, and for your information, I've created
>> (and am using seriously!) a JS pil, that I named `piljs` which runs on
>> node
>
>
>


Re: Regarding the implementations of PicoLisp

2014-05-09 Thread Joe Bogner
It works in chrome too and IE10 too

Check out: http://pypyjs.org/demo/




On Fri, May 9, 2014 at 10:21 AM, Rick Lyman  wrote:

> Joe, Christophe,
>
> A downside to asm.js is that it is Firefox only...
>
>
> http://www.infoworld.com/t/javascript/apple-has-its-own-javascript-accelerator-in-the-works-242042
>
> -rl
>
> p.s.: anyone considering c directly via Chrome/NaCL?
>
>
> On Fri, May 9, 2014 at 8:19 AM, Joe Bogner  wrote:
>
>> Hi Rick, Christophe,
>>
>> I was thinking the same thing. miniPicolisp might be a simpler first step
>> to port
>>
>>
>> On Fri, May 9, 2014 at 7:51 AM, Rick Lyman 
>> 
>> > wrote:
>>
>>> Christophe,
>>>
>>> How about porting the c version using:
>>> https://github.com/kripken/emscripten?
>>>
>>> -rl
>>>
>>>
>>> On Thu, May 8, 2014 at 5:08 PM, Christophe Gragnic <
>>> christophegrag...@gmail.com> wrote:
>>>
>>>> Hi,
>>>>
>>>> I'm currently embedding a «pedagogical pseudo-code like language» in
>>>> PicoLisp.
>>>> As using plain browsers is a nice thing to have in front of students,
>>>> I tried with
>>>> EmuLisp (PicoLisp in JS, by Jon Kleiser, that I won't thank enough,
>>>> with Alex),
>>>> which proved to be a good solution for me.
>>>>
>>>> So I had some thoughts, ideas and questions.
>>>>
>>>> 1) EmuLisp lacks some functions. The first idea I had was to write them
>>>> in the
>>>> available functions (like 'glue' with 'pack'). It worked for some, but
>>>> some others
>>>> needed to be implemented in JS. Now my question: how far could be
>>>> pushed the
>>>> idea to write a maximal subset of Picolisp in a minimal subset of
>>>> Picolisp? Like in
>>>> the original paper of McCarthy or «the Jewel» in SICP? I'm not talking
>>>> about
>>>> performance here, just functions availability.
>>>>
>>>> 2) Since PicoLisp64 is written in a «generic assembly» embedded in
>>>> PicoLisp,
>>>> I was wondering (only wondering, since the concepts are a bit vague for
>>>> me) if
>>>> instead of building the .s files we could build some 
>>>> http://asmjs.org/file(s).
>>>>
>>>> 3) Regarding EmuLisp again, and for your information, I've created
>>>> (and am using seriously!) a JS pil, that I named `piljs` which runs on
>>>> node
>>>
>>>
>>>
>>
>


Re: Regarding the implementations of PicoLisp

2014-05-09 Thread Joe Bogner
I bet it's the same problem as this:
https://www.mail-archive.com/picolisp@software-lab.de/msg04411.html

emscripten uses clang, right?


On Fri, May 9, 2014 at 1:59 PM, Rick Lyman  wrote:

> just a note:
>
> Downloaded miniPicoLisp.
> Building under Linux/gcc ok
>
> Downloaded Emscripten (for Windows)
> Using c files (from Linux re: above) I tried: "emcc -O2 flow.c -o flow.bc"
>
> below are a few of the errors generated:
>
> flow.c:41:62: warning: '&&' within '||' [-Wlogical-op-parentheses]
>if (isNum(x = EVAL(x)) || isNil(x) || x == T || isCell(x) &&
> isNum(car(x)))
> ~~
> ~~^~~~
> flow.c:41:62: note: place parentheses around the '&&' expression to
> silence this
>
>   warning
>if (isNum(x = EVAL(x)) || isNil(x) || x == T || isCell(x) &&
> isNum(car(x)))
>
>  ~~^~~~
> flow.c:60:37: error: fields must have a constant size: 'variable length
> array in
>
>   structure' extension will never be supported
>  struct {any sym; any val;} bnd[length(x)];
> ^
> flow.c:77:18: warning: using the result of an assignment as a condition
> without
>   parentheses [-Wparentheses]
>   } while (p = p->link);
>~~^
>
> ...
>
>
>
>
> On Fri, May 9, 2014 at 11:20 AM, Rick Lyman  wrote:
>
>> re: http://pypyjs.org/demo/
>>
>> Success:
>> Chrome: 34
>> Internet Explorer: 11
>>
>> Failure:
>> Safari: 5
>>
>>
>> On Fri, May 9, 2014 at 10:50 AM, Joe Bogner  wrote:
>>
>>> It works in chrome too and IE10 too
>>>
>>> Check out: http://pypyjs.org/demo/
>>>
>>>
>>>
>>>
>>> On Fri, May 9, 2014 at 10:21 AM, Rick Lyman wrote:
>>>
>>>> Joe, Christophe,
>>>>
>>>> A downside to asm.js is that it is Firefox only...
>>>>
>>>>
>>>> http://www.infoworld.com/t/javascript/apple-has-its-own-javascript-accelerator-in-the-works-242042
>>>>
>>>> -rl
>>>>
>>>> p.s.: anyone considering c directly via Chrome/NaCL?
>>>>
>>>>
>>>> On Fri, May 9, 2014 at 8:19 AM, Joe Bogner  wrote:
>>>>
>>>>> Hi Rick, Christophe,
>>>>>
>>>>> I was thinking the same thing. miniPicolisp might be a simpler first
>>>>> step to port
>>>>>
>>>>>
>>>>> On Fri, May 9, 2014 at 7:51 AM, Rick Lyman 
>>>>> 
>>>>> > wrote:
>>>>>
>>>>>> Christophe,
>>>>>>
>>>>>> How about porting the c version using:
>>>>>> https://github.com/kripken/emscripten?
>>>>>>
>>>>>> -rl
>>>>>>
>>>>>>
>>>>>> On Thu, May 8, 2014 at 5:08 PM, Christophe Gragnic <
>>>>>> christophegrag...@gmail.com> wrote:
>>>>>>
>>>>>>> Hi,
>>>>>>>
>>>>>>> I'm currently embedding a «pedagogical pseudo-code like language» in
>>>>>>> PicoLisp.
>>>>>>> As using plain browsers is a nice thing to have in front of students,
>>>>>>> I tried with
>>>>>>> EmuLisp (PicoLisp in JS, by Jon Kleiser, that I won't thank enough,
>>>>>>> with Alex),
>>>>>>> which proved to be a good solution for me.
>>>>>>>
>>>>>>> So I had some thoughts, ideas and questions.
>>>>>>>
>>>>>>> 1) EmuLisp lacks some functions. The first idea I had was to write
>>>>>>> them in the
>>>>>>> available functions (like 'glue' with 'pack'). It worked for some,
>>>>>>> but
>>>>>>> some others
>>>>>>> needed to be implemented in JS. Now my question: how far could be
>>>>>>> pushed the
>>>>>>> idea to write a maximal subset of Picolisp in a minimal subset of
>>>>>>> Picolisp? Like in
>>>>>>> the original paper of McCarthy or «the Jewel» in SICP? I'm not
>>>>>>> talking about
>>>>>>> performance here, just functions availability.
>>>>>>>
>>>>>>> 2) Since PicoLisp64 is written in a «generic assembly» embedded in
>>>>>>> PicoLisp,
>>>>>>> I was wondering (only wondering, since the concepts are a bit vague
>>>>>>> for me) if
>>>>>>> instead of building the .s files we could build some
>>>>>>> http://asmjs.org/ file(s).
>>>>>>>
>>>>>>> 3) Regarding EmuLisp again, and for your information, I've created
>>>>>>> (and am using seriously!) a JS pil, that I named `piljs` which runs
>>>>>>> on node
>>>>>>
>>>>>>
>>>>>>
>>>>>
>>>>
>>>
>>
>


Re: Regarding the implementations of PicoLisp

2014-05-12 Thread Joe Bogner
On Mon, May 12, 2014 at 5:40 AM, Christophe Gragnic <
christophegrag...@gmail.com> wrote:

> I'm interested by a clang compatible version, just to see what
> emscripten will make of it.
> For the sake of the experience I'm gonna try anyway.
>

chri,

I'm also interested in a emscripten compiled minPicoLisp. I've been itching
to try out emscripten and I think having miniPicoLisp available on all
platforms without building could help PicoLisp adoption.

I was able to compile miniPicoLisp on windows under clang. I basically just
replaced all instances of variable array initialization, such as:

struct {any sym; any val;} bnd[length(x = car(expr))+3];

with

//TODO
struct {any sym; any val;} bnd[100];


It builds and runs. I don't see any obvious consequences yet. I would have
assumed something like this would fail:

(setq Z (make (for N 120 (link N

I don't have emscripten geared up on this machine to try to compiling with
it. I figure it's not that far off though as a proof of concept.

Alex, is there a reasonably safe upper bounds that can be used instead of
it being determined dynamically?

(http://clang.llvm.org/compatibility.html#vla)
1. replace the variable length array with a fixed-size array if you can
determine a reasonable upper bound at compile time; sometimes this is as
simple as changing int size = ...; to const int size = ...; (if the
initializer is a compile-time constant);


I can envision a neat tool that lets us share snippets and even run code
directly from rosettacode.

GNU APL.js supports pasting code to it's emscripten compiled version of
apl:
http://baruchel.hd.free.fr/apps/apl/#code=5%205%20%E2%8D%B4%20%E2%8D%B310%0A


Re: Regarding the implementations of PicoLisp

2014-05-12 Thread Joe Bogner
Hi Alex,

Thanks for the reply and the details.

On Mon, May 12, 2014 at 9:56 AM, Alexander Burger wrote:

> Alex, is there a reasonably safe upper bounds that can be used instead of
> > it being determined dynamically?
>
> Hmm, what is "safe"? In any case you use the generality of the language,
> the "Unlimited" design objective of PicoLisp. You can never be sure that
> you don't exceed one of these fixed sizes.
>

The Unlimited design of PicoLisp is incredibly powerful. To clarify, I was
seeking some guidance on a reasonable upper limit on variable length arrays
that doesn't significantly handicap the language for demoing in an
emscripten environment. The proper solution is likely to use malloc/free
but that would introduce additional effort/complexity that might be
unnecessary for a proof of concept. I sometimes prefer hacking a small
change just to see if it's possible before letting myself go down a rabbit
hole.

It sounds like the reasonable upper limit might depend on the function. I
think I may have changed approximately 8 places that use the sym/val
structure.  I'll take a closer look. I was hopeful that there might have
been a quick answer that will work the vast majority of use cases with
little or no impact on run time and memory.


Re: Regarding the implementations of PicoLisp

2014-05-12 Thread Joe Bogner
I added my changes to this repo:

https://github.com/joebo/miniPicoLisp

This commit has everything needed to build on clang on windows:

https://github.com/joebo/miniPicoLisp/commit/e34b052bc9c8bd8fa813833294a5830a69ffb56e


I'm using:

C:\Users\jbogner\Downloads\miniPicoLisp\src>clang -v
clang version 3.4 (198054)
Target: i686-pc-mingw32
Thread model: posix
Selected GCC installation:

And my make came from http://sourceforge.net/projects/win-bash/

I am happy to answer any questions/help further




On Mon, May 12, 2014 at 11:50 AM, Christophe Gragnic <
christophegrag...@gmail.com> wrote:

> On Mon, May 12, 2014 at 2:16 PM, Joe Bogner  wrote:
> >
> > I was able to compile miniPicoLisp on windows under clang. I basically
> just
> > replaced all instances of variable array initialization, such as:
> >
> > struct {any sym; any val;} bnd[length(x = car(expr))+3];
> >
> > with
> >
> > //TODO
> > struct {any sym; any val;} bnd[100];
> >
> > It builds and runs.
>
> I didn't have this luck.
> I just set up a repository on github (Alex being OK) and reported my issue
> here:
> https://github.com/Grahack/minipicolisp/issues/1
> Could you show me your source files?
> Could you try with my source files?
> Or tell me the differences?
> Would it be easy for you to be granted commit access?
>
> On Mon, May 12, 2014 at 4:31 PM, Joe Bogner  wrote:
> > […]
> > The proper solution is likely to use malloc/free but
> > that would introduce additional effort/complexity that might be
> unnecessary
> > for a proof of concept. I sometimes prefer hacking a small change just to
> > see if it's possible before letting myself go down a rabbit hole.
>
> The same for me. My goal being beyond the proof of concept, but not
> very far though.
>
>
> chri
>
> --
>
> http://profgra.org/lycee/ (site pro)
> http://delicious.com/profgraorg (liens, favoris)
> https://twitter.com/profgraorg
> --
> UNSUBSCRIBE: mailto:picolisp@software-lab.de?subjectUnsubscribe
>


Re: Regarding the implementations of PicoLisp

2014-05-12 Thread Joe Bogner
On Mon, May 12, 2014 at 11:50 AM, Christophe Gragnic <
christophegrag...@gmail.com> wrote:


> I just set up a repository on github (Alex being OK) and reported my issue
> here:
> https://github.com/Grahack/minipicolisp/issues/1


I think the main difference is your Makefile

https://github.com/Grahack/minipicolisp/commit/15a72e16b097336c3a1d3b4092f3656509183308

Instead of:

clang $*.c

I'm doing this:

$(CC) -w -c $*.c

The -w suppresses warnings

and then linking with:

c:/Progra~2/LLVM/bin/clang.exe -o picolisp $(picoFiles:.c=.o)


Re: Implementation Education

2014-08-07 Thread Joe Bogner
Hi Alabhya,

I would also suggest starting with miniPicoLisp.-
http://software-lab.de/miniPicoLisp.tgz

Check out the docs: http://picolisp.com/wiki/?Documentation

Specifically, the reference: http://software-lab.de/doc/ref.html#vm

You may need to read it over several times. I've probably read it 10+ times
and learn something new after each reading.






On Thu, Aug 7, 2014 at 5:59 AM, Henrik Sarvell  wrote:

> Perhaps not simpler but my thinking is that it's probably easier to find
> resources on C plus getting to know C better might have higher utility than
> assembly.
>
>
> On Thu, Aug 7, 2014 at 4:44 PM, Alabhya Singh  wrote:
>
>> Thanks Henrik.
>>
>> May be because pil32 and C are simpler than pil64 and assembly
>> respectively.
>>
>>  --
>> * From: * Henrik Sarvell ;
>> * To: * ;
>> * Subject: * Re: Implementation Education
>> * Sent: * Thu, Aug 7, 2014 9:31:10 AM
>>
>>   Hi Alabhya, if I were you I would learn enough C to understand the
>> pil32 source and then go through it.
>>
>>
>> On Thu, Aug 7, 2014 at 4:00 PM, Alabhya Singh  wrote:
>>
>>> To be able to use a language with utmost confidence one should be able
>>> to understand its implementation so much so as to be able to implement it
>>> and maintain it.
>>>
>>> This I am saying from my experience in maintaining my Porteus Linux
>>> system.
>>> PicoLisp matches Porteus in many ways, minimalist, easy to maintain,
>>> speed etc.
>>>
>>> PicoLisp philosophy of minimal orthogonal design makes it ideal for this
>>> down to bare metal approach.
>>>
>>> However I am just a novice lisp programmer who would love to invest
>>> significant effort into learning through using picoLisp.
>>>
>>> I shall be grateful if Alexander and/or other senior experienced people
>>> be kind enough to outline various components of implementing picoLisp.
>>>
>>> Such as: knowledge level of lisp, assembly and C (reference books, links
>>> etc).
>>>
>>> Kindly indicate steps to start learning how to implement and maintain
>>> picoLisp.
>>>
>>>
>>>
>>
>


Re: try picolisp

2014-08-28 Thread Joe Bogner
Hi Mike,

I would also be interested in minipicolisp running under Emscripten.
In the meantime, have you seen Jon Kleiser's EmuLisp:
http://folk.uio.no/jkleiser/pico/emuLisp/console.html ?



On Thu, Aug 28, 2014 at 1:41 PM, Mike Pechkin  wrote:
> hi,
>
> Is it hard to implement minimalist version of minipicolisp in browser ?
> Like http://tryclj.com/ ?
>
> Mike
>
-- 
UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe


Re: Announce: PicoLisp in Hardware (PilMCU)

2014-09-19 Thread Joe Bogner
Hi Alex - congratulations... It's really inspiring to see picoLisp keep
improving and branching out. It really has staying power

This might be off base, but is it within the realm of possibility to
run PilMCU on a raspberry pi now or in the future? That's an accessible
piece of hardware that many people already have (myself included). These
people may also be willing to fund the work

My pi has been sitting powered off largely since I bought it. This could
reinvigorate it.

On Fri, Sep 19, 2014 at 9:05 AM, Alexander Burger 
wrote:

> Hi Alabhya,
>
> > Congratulations to both of you on this important feat!
>
> Thanks!
>
> > Funds should flow in when "picoLisp OS" is seen running with all
> > virtues, on existing hardware.
>
> Hmm, but this is a bit against the point, isn't it? This *is* a hardware
> project. On existing hardware you may be served better with a standard
> OS.
>
> ♪♫ Alex
> --
> UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe
>


Re: PicoLisp roots

2014-09-22 Thread Joe Bogner
Hi Jerome,

You might be interested in https://github.com/michelp/0pl as it's somewhat
similar to what you are trying to accomplish. It's PicoLisp bindings for
ZeroMQ

It may give you some ideas on how to tackle the amqp port




On Sun, Sep 21, 2014 at 12:32 PM, jerome moliere 
wrote:

> Hi all,
> I do not intend to spam your mailing list , sorry if this question sounds
> stupid for many of you but I had a look to the PicoLisp language.I am not a
> Lisp expert but I can write Clojure code & Emacs Lisp I'd like to know
> how far/close PicoLisp is from Common Lisp or other Lisp dialects.
> In fact I've seen that github hosts a Common Lisp AMQP client library and
> I'd like to estimate how much work I would need to port this library to
> PicoLisp.
> The project is hosted here : https://github.com/lisp/de.setf.amqp
>
> Thanks for precious help
> Kind regards
>
> --
> JMOLIERE - Mentor/J
>


Re: A PicoLisp native library tutorial

2015-03-03 Thread Joe Bogner
Nicely done. Thanks for sharing

On Tue, Mar 3, 2015 at 12:16 PM, Henrik Sarvell  wrote:

> Nice!
>
> On Tue, Mar 3, 2015 at 5:36 PM, Alexander Williams
>  wrote:
> > Hi list,
> >
> > Some of you might know me from IRC @aw-Unscramble.
> >
> > I've written my first PicoLisp library, a native C binding for Nanomsg
> > (picolisp-nanomsg) - as an experiment for myself to learn this language.
> >
> > In doing so, I ran into a few difficulties (mostly noob stuff) but
> Regenaxer
> > has been very helpful and patient.
> >
> > I also wrote a tutorial explaining the code, to help other newbies
> > understand some useful features of PicoLisp:
> >
> >   https://github.com/aw/picolisp-nanomsg/blob/master/EXPLAIN.md
> >
> > And of course, the library: https://github.com/aw/picolisp-nanomsg
> >
> >
> > Thanks!
> >
> --
> UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe
>


Re: Static file server with Ersatz

2015-03-16 Thread Joe Bogner
Christophe, I wrote up an article a few years ago about creating a web app
with ersatz and picoLisp:

http://picolisp.com/wiki/?ersatzwebapp

One of the subtle points of the article is that you need to modify the
ersatz sources to remove the Static initialization of variables, otherwise
it won't be thread safe.



On Mon, Mar 16, 2015 at 3:51 AM, Christophe Gragnic <
christophegrag...@gmail.com> wrote:

> Hi list,
> I'm investigating a way to be able to fire up a static file server
> like in Python:
>
> python -m http.server 8000
>
> but with Ersatz. Has it been done ? If not, would it involve:
> 1) the use of the -server function in http.l
> 2) grab the path of the requested file
> 3) read the file and send it to the client
> 4) write a little file explorer when requesting a directory
> ?
>
> BTW, wouldn't it be more correct to say
> «Then the -server function is called»
> than
> «Then the server function is called»
> near the end of this section:
> http://software-lab.de/doc/app.html#server
>
>
> Thanks.
>
> --
>
> http://profgra.org/lycee/ (site pro)
> http://delicious.com/profgraorg (liens, favoris)
> https://twitter.com/profgraorg
> http://microalg.info
> --
> UNSUBSCRIBE: mailto:picolisp@software-lab.de?subjectUnsubscribe
>


Re: PilMCU is dead - Long live PilOS!

2015-06-19 Thread Joe Bogner
Alex, this is incredibly cool. It runs fine on win64 under qemu. This will
be fun to play with. Are you considering adding networking support in the
future? I imagine that would be quite difficult.

On Fri, Jun 19, 2015 at 4:16 PM, Alexander Burger 
wrote:

> Hi all,
>
> I'm happy to announce PilOS - The PicoLisp Operating System!
>
> It is a modification of the infamous PilMCU, which unfortunately doesn't
> seem to get off the ground. So in order not to have wasted all that
> effort, I decided to let it run on standard PC hardware, basically
> directly off the BIOS.
>
> In the future, we might think of utilizing it in embedded systems.
>
> I release it free to the public. It is currently just a toy project,
> which gave me lots of fun during the last two weeks.
>
> You can read more about it, watch a demo video, and download all at
>
>http://picolisp.com/wiki/?PilOS
>
> ♪♫ Alex
> --
> UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe
>


Re: PilMCU is dead - Long live PilOS!

2015-06-19 Thread Joe Bogner
I was so excited I didn't read close enough

"Also missing is - of course - networking (left as an exercise for the
reader ;)."


On Fri, Jun 19, 2015 at 4:47 PM, Joe Bogner  wrote:
> Alex, this is incredibly cool. It runs fine on win64 under qemu. This will
> be fun to play with. Are you considering adding networking support in the
> future? I imagine that would be quite difficult.
>
> On Fri, Jun 19, 2015 at 4:16 PM, Alexander Burger 
> wrote:
>>
>> Hi all,
>>
>> I'm happy to announce PilOS - The PicoLisp Operating System!
>>
>> It is a modification of the infamous PilMCU, which unfortunately doesn't
>> seem to get off the ground. So in order not to have wasted all that
>> effort, I decided to let it run on standard PC hardware, basically
>> directly off the BIOS.
>>
>> In the future, we might think of utilizing it in embedded systems.
>>
>> I release it free to the public. It is currently just a toy project,
>> which gave me lots of fun during the last two weeks.
>>
>> You can read more about it, watch a demo video, and download all at
>>
>>http://picolisp.com/wiki/?PilOS
>>
>> ♪♫ Alex
>> --
>> UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe
>
>
--
UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe


Re: PilOS Boot Issues

2015-06-29 Thread Joe Bogner
Hi Alex,

The new version boots fine on qemu under windows 7 x64. Under
virtualbox on the same platform, get stuck with a black screen that
says Loading PilOS with nothing else displayed

This is how I converted the image

"c:\Program Files\qemu\qemu-img.exe" convert -O vmdk x86-64.img  x86-64.vmdk

The symptoms are the same when I use vboxmanage to convert:

c:\Program Files\Oracle\VirtualBox\VBoxManage.exe convertfromraw
x86-64.img x86-64_vbox.vmdk --format VMDK
Converting from raw image file="x86-64.img" to file="x86-64_vbox.vmdk"..
Creating dynamic image with size 684032 bytes (1MB)...

It still freezes on the black screen Loading PilOS


On Mon, Jun 29, 2015 at 9:55 AM, Alexander Burger  wrote:
> Hi all,
>
> it seems that there are still problems with booting PilOS.
>
> While it works for me (on Qemu and on my Acer notebook), it hear that on
> other emulators or hardware people just see a black screen. So I would
> be glad to find out the reason(s).
>
>
> One reason might be that the image is not recognized as a hard disk:
>
>
> http://reboot.pro/topic/7512-fool-the-bios-booting-any-usb-stick-as-a-hard-disk
>
> So I followed the suggestions there, and changed the partition table to
> two dummy-partitions instead of one. Also, I set one System ID to
> "Linux" ("83", instead of the arbitrary "22" before), and the other to
> "Linux swap" (ID "82"). I don't know if this helps though.
>
>
> Also, I added a few diagnostic messages, to see how far it gets.
>
> So anybody daring to try it is welcome! As before, PilOS can be
> downloaded from
>
>http://software-lab.de/pilos.tgz
>
> and put on an USB-Stick, e.g. on /dev/sdb
>
>$ sudo dd if=x86-64.img of=/dev/sdb
>
> Then try to boot (only on x86-64 (Amd64) hardware, of course).
>
> ♪♫ Alex
> --
> UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe
--
UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe


Re: PilOS

2015-07-21 Thread Joe Bogner
Hi Rob,

I'm using qemu-2.0.9.1 on win64 with pilos and it works fine

I downloaded it from here:

http://qemu.weilnetz.de/w64/qemu-w64-setup-20140715.exe

Later versions, including qemu-w64-setup-20150503.exe did not run for me

Hope that helps


On Mon, Jul 20, 2015 at 6:10 AM, Robert Herman  wrote:
> I tried several, and when I finally tried version 2.2.90 for windows 64 bit,
> It went past that error and went to a 'READ ERROR 09'
> Is that a 09h Attempt to DMA over 64kb boundary using the same Wiki
> reference you supplied in a previous posting?
> How can I fix it or keep moving on? Where do I look in the source to
> troubleshoot this myself? Exciting fun anyhow, so no complaints here!
>
>
> Rob
>
> On Mon, Jul 20, 2015 at 1:32 PM, Alexander Burger 
> wrote:
>>
>> Hi Robert,
>>
>> > First, I would like to donate some money anyway, seeing how much fun I
>> > have
>> > had with PicoLisp and PilOS.
>>
>> Thanks, that's very nice! But don't worry, that's not what I'm looking
>> for. I need some stable, long-term project(s) ;)
>>
>>
>> > Second, I get a 'Guest has not initialized the display (yet).' when
>> > trying
>> > to run PilOS in qemu on my i5 Windows 8.1 64bit machine. Any steps I am
>> > missing? I am a qemu newbie, and PilOS newbie.
>>
>> I did a short search on the web, and it seems this error appears in qemu
>> in other situations too. Not only on Windows, but also on other guest
>> operating systems.
>>
>> I have no idea what might be the reason. PilOS simply uses the standard
>> VIDEO memory (VGA) on hardware address 0xB8000.
>>
>> Can you try another version of qemu?
>>
>> ♪♫ Alex
>> --
>> UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe
>
>
--
UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe


Re: PilOS

2015-07-23 Thread Joe Bogner
Good to hear! Happy to help.

On Thu, Jul 23, 2015 at 11:21 AM, Robert Herman  wrote:
> Joe,
>
> Thanks! That did it. I was trying different versions of Qemu sequentially,
> and hopping around, and could not get one past that 09 error. I have no
> regrets of jumping down the rabbit hole though, since I have learned heaps
> about DMA and qemu, and I have even started to look into Alex's code. Now,
> back to PilOS!!!
>
> Rob
>
> On Tue, Jul 21, 2015 at 7:18 PM, Joe Bogner  wrote:
>>
>> Hi Rob,
>>
>> I'm using qemu-2.0.9.1 on win64 with pilos and it works fine
>>
>> I downloaded it from here:
>>
>> http://qemu.weilnetz.de/w64/qemu-w64-setup-20140715.exe
>>
>> Later versions, including qemu-w64-setup-20150503.exe did not run for me
>>
>> Hope that helps
>>
>>
>> On Mon, Jul 20, 2015 at 6:10 AM, Robert Herman 
>> wrote:
>> > I tried several, and when I finally tried version 2.2.90 for windows 64
>> > bit,
>> > It went past that error and went to a 'READ ERROR 09'
>> > Is that a 09h Attempt to DMA over 64kb boundary using the same Wiki
>> > reference you supplied in a previous posting?
>> > How can I fix it or keep moving on? Where do I look in the source to
>> > troubleshoot this myself? Exciting fun anyhow, so no complaints here!
>> >
>> >
>> > Rob
>> >
>> > On Mon, Jul 20, 2015 at 1:32 PM, Alexander Burger 
>> > wrote:
>> >>
>> >> Hi Robert,
>> >>
>> >> > First, I would like to donate some money anyway, seeing how much fun
>> >> > I
>> >> > have
>> >> > had with PicoLisp and PilOS.
>> >>
>> >> Thanks, that's very nice! But don't worry, that's not what I'm looking
>> >> for. I need some stable, long-term project(s) ;)
>> >>
>> >>
>> >> > Second, I get a 'Guest has not initialized the display (yet).' when
>> >> > trying
>> >> > to run PilOS in qemu on my i5 Windows 8.1 64bit machine. Any steps I
>> >> > am
>> >> > missing? I am a qemu newbie, and PilOS newbie.
>> >>
>> >> I did a short search on the web, and it seems this error appears in
>> >> qemu
>> >> in other situations too. Not only on Windows, but also on other guest
>> >> operating systems.
>> >>
>> >> I have no idea what might be the reason. PilOS simply uses the standard
>> >> VIDEO memory (VGA) on hardware address 0xB8000.
>> >>
>> >> Can you try another version of qemu?
>> >>
>> >> ♪♫ Alex
>> >> --
>> >> UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe
>> >
>> >
>> --
>> UNSUBSCRIBE: mailto:picolisp@software-lab.de?subjectUnsubscribe
>
>
--
UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe


Re: Single File Function Reference

2015-10-13 Thread Joe Bogner
This may be relevant:

https://github.com/tj64/picolisp-by-example

https://github.com/tj64/picolisp-works/blob/master/editor.pdf?raw=true
https://github.com/tj64/picolisp-by-example/blob/master/book.pdf?raw=true

PicoLisp By Example has a function reference

Also documented here: http://picolisp.com/wiki/?Documentation

On Tue, Oct 13, 2015 at 9:35 AM, František Fuka  wrote:
> Is there Picolisp function reference available to download as a single file,
> to put in in my EBook reader? I can only see it online, split to individual
> files according to the first letter of the function name.
>
> --
> -- Frantisek Fuka
> (yes, that IS my real name)
>
> -- My Personal homepage: www.fuxoft.cz
> -- My Google+ profile: google.com/+fuxoft
> -- My Telegram chat: telegram.fuxoft.cz
>
>
--
UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe


Re: Websockets now considered stable

2016-01-14 Thread Joe Bogner
Hi Henrik,

Thanks for sharing. I get the following when running the ws-demo:

 ./pil pl-web/ws-demo/main.l -go
..
!? (wsServer)
wsServer -- Undefined

I can't find the definition of wsServer anywhere. Is it missing from the
repo?

Thanks,
Joe

On Mon, Jan 4, 2016 at 4:27 PM, Henrik Sarvell  wrote:

> Update:
>
> The socketserver is now completely reliant on Redis, using Redis' pub
> / sub functionality: http://redis.io/topics/pubsub
>
> The reason for this is that I was using the websocket server to handle
> all websockets functionality for the site I'm being paid to work on
> and it started running into problems as the site grew, the first issue
> was an easy fix after Alex pointed me to it, increasing the amount of
> file descriptors in src64/sys/x86-64.linux.defs.l, my line #115 now
> looks like this: (equ FD_SET 1024)  # 1024 bit
>
> After re-compiling I could easily handle more than 500 clients and all
> was well for a while.
>
> Unfortunately the site is growing so fast that just some month(s)
> later the parent / root process started intermittently running at 100%
> CPU utilization and the service stopped working for perhaps 10-20
> minutes before resolving on its own. At this point peak usage involved
> 2000 clients being connected at the same time.
>
> Alex suspects that the issue has got to do with how the internal logic
> handles new processes being created when there are already a lot of
> them present. In a normal HTTP server scenario this probably never
> happens, imagine that every request takes on average 1 second to
> perform before the socket closes, you would then need about 2000
> requests per second in order to trigger the CPU problem, you'll run
> into many other issues long before that happens in a non-trivial
> scenario (trust me I've tested).
>
> In the end we switched over to a node.js based solution that also
> relies on Redis' pub / sub functionality (that's where I got the idea
> from to make the PL based solution also use it).
>
> I have tried to replicate the real world situation load wise and
> number of clients wise but not been able to trigger the CPU issue
> (this also seems to imply that Alex's suspicion is not completely on
> target), it's impossible for me to replicate the real world situation
> since I can't commandeer hundreds of machines all over the world to
> connect to my test server. What I did manage to trigger though was
> fairly high CPU usage in the child processes though, a situation that
> also involved loss of service. After the switch to using pub / sub I
> haven't been able to trigger it, so that's a win at least.
>
> Now for the real improvement, actually making HTTP requests to publish
> something becomes redundant when publishing from server to client
> since it's just a matter of issuing a publish call directly to Redis
> instead. That lowers the amount of process creation by more than 90%
> in my use case.
>
> Even though I can't be 100% sure as it currently stands I believe that
> if I had implemented the websocket server using Redis' pub / sub to
> begin with the CPU issue would probably never have happened and there
> would've been no need to switch over to node.js.
>
> That being said, this type of service / application is better suited
> for threads since the cost in RAM etc is lower.
>
> Final note, my decision to use one socket per feature was poor, it
> allowed me a simpler architecture but had I opted for one socket with
> "routing" logic implemented in the browser instead I could have
> lowered the amount of simultaneous sockets up to 8 times. Peak usage
> would then have been 2000 / 8 = 250 processes. Not only that, it turns
> out that IE (yes, even version 11 / edge) only allows 6 simultaneous
> sockets (including in iframes) per page. We've therefore been forced
> to turn off for instance the tournament functionality for IE users.
>
>
>
> On Fri, Jun 26, 2015 at 9:30 PM, Henrik Sarvell 
> wrote:
> > Hi all, after over a month without any of the prior issues I now
> > consider the websockets part of pl-web stable:
> > https://bitbucket.org/hsarvell/pl-web Gone are the days of 100% CPU
> > usage and zombie processes.
> >
> > With Alex's help the main web server is now more stable (he made me
> > throw away a few throws in favour of a few byes). The throws were
> > causing the zombies.
> >
> > I was also including dbg.l (it was causing hung processes at 100%
> > CPU), it's basically been deprecated or something, I'll leave it up to
> > him to elaborate. It's just something I've been including by habit
> > since years ago when at some point I needed to include it to do some
> > kind of debugging.
> >
> > Anyway atm the WS router is regularly routing up to 40 messages per
> > second to upwards 300-500 clients which means that roughly 20,000
> > messages are being pushed out per second during peak hours.
> >
> > The PL processes show up with 0 CPU and 0 RAM usage when I run top,
> > sometimes 1% CPU :) They hardly register even i aggregate,

Re: flinuxpicolisp

2016-07-05 Thread Joe Bogner
On Mon, Jul 4, 2016 at 2:17 PM, Thorsten  wrote:

> Hi List,
> I just discovered a nice article by Joe Bogner about FLINUX as an
> alternative was to run PicoLisp under Windows (http://picolisp.com/wiki/?
> flinuxpicolisp).
>
>
Hi Thorsten, glad you found it.


> I tried it out, and succeded to a certain point but not further.
>
> When installing necessary tools like wget, make etc. I often hit the
> "could not change the root directory (No such file or directory)" error,
> but it appeared after the last installation step, and after an C-c
> installation appeared successful.
>
>
I had the same experience. I think it was a side effect of how bash runs
within it and didn't affect the pil32 execution as far as I remember.


> But when trying to compile the 64bit version, Java is missing, and when I
> try to install it, I get the above error in the middle of the installation
> process that thus cannot finish.
>
>
Unfortunately, I don't think you'll be able to compile or run the 64bit
version. I was unable to compile a x64 version of flinux and it seems like
it is not implemented. For example,
https://github.com/wishstudio/flinux/tree/7874a4ff9ba2fec4ad1c67b857c563288d5aa93e/src/dbt,
does not have an x64 version and the assembly for x86_trampoline does not
compile under visual c++ x64.

This is the main motivation for working on the native x64 version of
PicoLisp using midipix as the linux syscall interop layer.  Thanks for the
mention Rick!

The x64 version is still in a draft status, most of the changes are here:
https://github.com/joebo/picoLisp-win-x86-64/blob/master/src64/arch/win-x86-64.l,
to support the different ABI calling convention. It relies on midipix which
is still in alpha and hasn't yet been released which is why I haven't
actively promoted it. There's a few workarounds still in the code too, for
example dlopen isn't yet implemented in midipix so ht ext: code needs to be
compiled into the picolisp binary,
https://github.com/joebo/picoLisp-win-x86-64/blob/master/src64/Makefile#L129

The current x64 windows binary release can be found under Releases in the
github repo linked above,
https://github.com/joebo/picoLisp-win-x86-64/releases

There is some info about this
> (https://github.com/wishstudio/flinux/issues/63), but I could not really
> find a solution. Did somebody on the list succeed with the Flinux install
> of the 64bit version on Windows?
>
> Any hints would be welcome.
> Cheers
> Thorsten
>
> --
> UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe
>


Re: flinuxpicolisp

2016-07-05 Thread Joe Bogner
Oleksandr, thank you for the report. Please confirm, what does *CPU report
under the src64 version on the Win10/Windows Subsystem? If it is emu then
it is running the emulated version of the 64-bit version, which is good but
not optimal for performance

I have a 32-bit windows 10 machine and the Windows Subsystem for Linux was
not available on 32-bit as of a few months ago, which is one of the reasons
I started working on the win-x86-64 port.

If the native, assembly, version of PicoLisp 64 runs under Win10/x64 then
that would be great. I will still continue to work on my port as I would
like to support those without access to win10 (myself included).




On Tue, Jul 5, 2016 at 2:14 AM, Oleksandr Nikitin 
wrote:

> Hi Rick, Thursten
>
> just FYI, both 32 and 64-bit PicoLisp compiles and runs pretty much
> transparently on the new "Windows Subsystem for Linux".
>
> Haven't tried using database yet, though.
>
> On Tue, Jul 5, 2016 at 5:26 AM, Rick Hanson  wrote:
>
>> On Mon, Jul 4, 2016 at 2:17 PM, Thorsten wrote:
>> > Hi List,
>>
>> Hi, Thorsten !
>>
>> > I just discovered a nice article by Joe Bogner about FLINUX as an
>> > alternative was to run PicoLisp under Windows
>> > (http://picolisp.com/wiki/?  flinuxpicolisp).
>> >
>> > I tried it out, and succeded to a certain point but not further.
>> >
>> > When installing necessary tools like wget, make etc. I often hit the
>> > "could not change the root directory (No such file or directory)"
>> > error, but it appeared after the last installation step, and after
>> > an C-c installation appeared successful.
>> >
>> > But when trying to compile the 64bit version, Java is missing, and
>> > when I try to install it, I get the above error in the middle of the
>> > installation process that thus cannot finish.
>> >
>> > There is some info about this
>> > (https://github.com/wishstudio/flinux/issues/63), but I could not
>> > really find a solution. Did somebody on the list succeed with the
>> > Flinux install of the 64bit version on Windows?
>>
>> I'm not aware.  It looks as if his article
>>
>> http://picolisp.com/wiki/?flinuxpicolisp
>>
>> was only meant for 32-bit pil builds.
>>
>> On the other hand and on the topic of Windows 64-bit pil builds, Joe
>> is currently working on and very close to a solution based on midipix.
>>
>> http://www.midipix.org/#sec-midipix
>>
>> He has been working closely with the midipix author for many weeks now
>> (back and forth on IRC) to iron out particular problems with getting
>> pil ported there.
>>
>> There is not much in the way of documentation yet, but Joe has
>> cataloged some pil patches related to the midipix build here:
>>
>> https://github.com/joebo/picoLisp-win-x86-64
>>
>> (and there might be more he has not pushed yet; not entirely sure.)
>>
>> At any rate, when we see Joe (joebo) on #picolisp let's remind
>> ourselves to ask him to update us about it here on the ML.
>>
>> > Any hints would be welcome.
>> > Cheers
>> > Thorsten
>>
>> Best, --Rick
>> --
>> UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe
>>
>
>
>
> --
> With best wishes, Oleksandr Nikitin
>
> skype: wizzard0
>


Windows x64 PicoLisp preview

2016-08-17 Thread Joe Bogner
I've been working on a port of PicoLisp 64 to Windows. The port is ready
for an early preview for anyone who wants to try it out

The goal of the initiative is to allow PicoLisp development on Windows.
This may improve efficiency and usage of resources as virtual boxes or
remote shells aren't necessary for those of us on Windows workstations. We
can run PicoLisp 64 natively. Cygwin or flinux[4] is still an option for
32-bit PicoLisp (src vs src64). PicoLisp 64 has more features and is
faster. It may also bring new users to PicoLisp.

The binaries are available at
https://github.com/joebo/picoLisp-win-x86-64/releases/tag/0.02

Please read the notes on the release page for invocation instructions.

There are a few known items that aren't working:

- file locking (fnctl not implemented in midipix yet)
- native (dlopen not implemented in midipix yet)
- instability observed with fork and sockets

Due to the file locking issue, I would not recommend using it in production
with fork. I expect to have a solution for file locking in the future.

The implementation is mostly in
https://github.com/joebo/picoLisp-win-x86-64/blob/master/src64/arch/win-x86-64.l
or view the commit history
https://github.com/joebo/picoLisp-win-x86-64/commits/master to see a list
of all the changes. Most of the work was in debugging.

It can be run from cmd.exe using a combination of ntctty and ptycon
(included) which sets up the terminal emulator. It can also be run from
mingw64 with ./picolisp.exe. See notes in win.l or the release notes.
Beware, long path names seem to cause a problem (thanks rick!).

It's fairly complicated to set up to build from source because it requires
a new toolchain. It requires midipix, http://www.midipix.org, which is
pre-alpha. I plan to document the build steps once midipix is released. The
steps currently require joining the irc channel and asking for private git
access.

If you clone the github repo, you should be able to generate the assembly
file with cd src64;make x86-64.win - current version here:
https://github.com/joebo/picoLisp-win-x86-64/releases/download/0.02/win-x86-64.windows.base.s

Credits:
Thanks to Alex for pil64 and his debugging assistance
Thanks to Rick for testing and encouragement
Thanks to midipix team for a solid cygwin alternative


Please reply to the mailing list if you try it out or find it useful!

Links:
[1] - https://github.com/joebo/picoLisp-win-x86-64/releases/tag/0.02
[2] - https://github.com/joebo/picoLisp-win-x86-64/
[3] - http://www.midipix.org/
[4] - http://picolisp.com/wiki/?flinuxpicolisp (32-bit)


Re: Windows x64 PicoLisp preview

2016-08-17 Thread Joe Bogner
Thanks for the feedback everyone. I resurveyed the options on Windows this
morning for PicoLisp

1. pil32 compiled under mingw -- compiles but doesn't work due to issues
with reading from stdin -- example (load "lib.l") is read as (load "lib.")
.. similar failures when invoking from command line

2. pil32 compiled under cygwin - compiles and passes same tests as midipix
pil64. However, when running the app/main.l it crashes with "DB read: Bad
file descriptor".  This has come up before (
https://www.mail-archive.com/picolisp@software-lab.de/msg03430.html) and
still seems to be an issue

3. pil64 emu - compiles but fails on (wait) tests... seems to hang
indefinitely. Possibly can be fixed with *C-params, but I don't
particularly want to run emu

4. pil64 midipix-based preview port [this release] ... runs app/main.l and
I can click around and view records. I noticed some instability when
editing and will research further

5. pil64 running under windows 10 subsystem - not tested as I don't have
windows 10 x64

>From my usage #4 is the best bet it seems




On Wed, Aug 17, 2016 at 9:24 AM,  wrote:

> Great work Joe!
>
> As rick said, this will make windows work more bearable and open up
> opportunities to deploy picolisp, especially for little scripts and glue
> work.
>
> Many thanks to you, Alex, rick and the awesome guys from midipix :-)
>
>
>


picolisp windows update & other notes

2016-08-18 Thread Joe Bogner
I wrote up a few notes after working with the picolisp win-x86-x64 port
today

http://csilo.com/!article?2016/08/19/PicoLisp-win-x86-64-app/main-edit-workaround,-other-musings

I figured others may be interested. Feel free to reply here with any
comments. It's good to be working with pil again after a few years.


My work today was using the win-x86-64 port to run a load test against a c#
app. This load test ran with 50 works on my windows PC.

Here's a gist of the load test:
https://gist.github.com/joebo/fa91b263fece8adc3c18186fc1d6c50b

It works great to simulate web traffic and capture the response time. Much
easier than figuring out the latest and greatest stress test tool and
learning how to program it.

I needed to simulate a user from a random preconfigured list of users. Then
make a request to get the person's list of customers. Then pick a random
customer to get a list of that person's products. Then pick a product to
view the details for that customer/product.

Cheers!


task db example

2016-08-24 Thread Joe Bogner
Some discussion on irc this morning prompted me to create a simple example
showing how to interact with the db directly.

I posted it to the wiki and am sharing it here in case anyone would benefit

http://picolisp.com/wiki/?taskdb


Re: toy-forth-in-picolisp, and a 32-bit problem

2016-08-26 Thread Joe Bogner
Hi Jon - also works on windows 64bit version

: : : ff 0 if 77 else 88 then ;
-> +DefineWord
Done defining ff as (0 $200243534)
t
-> tempStack:


-> +DefineWord
Done defining fac as (_dup_ 1 _>_ $200244051)
5 fac .s
-> (120)



On Fri, Aug 26, 2016 at 11:26 AM, Brian Walker  wrote:

> Hi Jon,
>
> works great for me on linux 64bit version.
>
> /taj33n
>
>
> Am 26.08.2016 um 15:53 schrieb Jon Kleiser:
>
>> Hi,
>>
>> This summer I have had some fun trying to figure out how to implement a
>> super simple toy Forth. For a start, I chose PicoLisp as an implementation
>> language. You may find it here:
>>
>> https://github.com/jkleiser/toy-forth-in-picolisp
>>
>> There is one problem, however, occurring quite regularly when I run this
>> forth.l using 32-bit PicoLisp on Mac. As the README.md suggests, I start it
>> by doing this
>>
>> pil path/to/forth.l +
>>
>> If I then enter “: ff 0 if 77 else 88 then ;” (without the quotes), which
>> defines a new word “ff” (which when used always pushes 88 on the stack),
>> and then enter “t”, which is a (non-standard) word just for checking the
>> state of the “tempStack” field (probably empty), then I usually get a
>> “Segmentation fault: 11”.
>>
>> I have not seen that problem when using 64-bit PicoLisp (in Docker).
>>
>> Is this Segmentation fault caused by a bug in 32-bit PicoLisp, or is it
>> me doing something stupid?
>>
>> Have a nice weekend!
>>
>> /JonPԔ  �  &j)mX��� � �zV�u�.n7�� ���r��e===
>>
>> --
> UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe
>


Re: Article on fixed-point arithmetic in picolisp

2016-09-06 Thread Joe Bogner
Hey Rick,

Thanks for the article! It was informative and interesting. It should make
the scale operations less intimidating and awkward to a new user. I
particularly like how it highlights the benefits over floating point math.
What do you think about publishing some bits from the article on the wiki?



On Tue, Sep 6, 2016 at 1:11 AM,  wrote:

> [Let's try this one more time. I screwed up the headers before. Sorry.]
>
> Hello list!
>
> Here is a blog post that I wrote about fixed-point number operations in
> picolisp.
>
> http://the-m6.net/blog/fixed-point-arithmetic-in-picolisp.html
>
> It was fun to write and I hope you find it useful.  It might be a bit
> tedious for the veterans because it is written to inform a relative
> newcomer to picolisp about such things.  Anyway, as always, I'd
> appreciate any comment upon it by all you sharp folks who regularly
> teach me things here and on IRC.  Thanks!
>
> All the best, --Rick (rick42)
>
> P. S. -- I thought that writing this would be fairly easy; then I got
> into it.  :/  When I thought I was finished, I didn't realize that I had
>  more work to do and consequently I delayed publishing for another week.
>  Wow.  And that wringer was just *one* post!  I don't think I could do
> an *entire blog* on picolisp as some of you do -- that's for you
> adventurous and energetic people.  :D
> --
> UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe
>


web app example - todo w/mithril.js

2016-09-13 Thread Joe Bogner
I've been working on an example of using PicoLisp to create  as a single
page web application (javascript / SPA).

The code is available at https://github.com/joebo/pil-mithril-todo

You can play with the example here (may be temporary):

http://csilo.com:8088/

log in with admin/admin


I welcome any feedback!

Joe


Re: web app example - todo w/mithril.js

2016-09-14 Thread Joe Bogner
On Wed, Sep 14, 2016 at 7:52 AM, Mike Pechkin 
wrote:

> I will implement bcrypt in PicoLisp.
>
>
Great! It will be nice to eliminate that dependency on bcrypt.so


>


Re: web app example - todo w/mithril.js

2016-09-14 Thread Joe Bogner
rick, great suggestion and thanks for the feedback!

Added and deployed!
https://github.com/joebo/pil-mithril-todo/blob/master/app.js#L52



On Wed, Sep 14, 2016 at 8:37 PM,  wrote:

> Hi Joe!
>
> On Wed, 14 Sep 2016 00:14 -0400, Joe Bogner wrote:
> > I've been working on an example of using PicoLisp to create as a
> > single page web application (javascript / SPA).
> >
> > The code is available at https://github.com/joebo/pil-mithril-todo
> >
> > You can play with the example here (may be temporary):
> >
> > http://csilo.com:8088/
> >
> > log in with admin/admin
> >
> > I welcome any feedback!
>
> This is very nice, i.e. a nice digestible, but non-trivial and coherent,
> example that people can use to learn how to do such as this easily and
> quickly.  It also looks very professional, slick.
>
> A question: when you are done typing a task description in the text
> field, is it possible to have the task added when you then press ENTER
> there (i.e. without having to press the Add button)? Just wondering.
>
> Thanks for doing this!  Best, --Rick
> --
> UNSUBSCRIBE: mailto:picolisp@software-lab.de?subjectUnsubscribe
>


creating a todo app in less than 2 minutes (pil-mithril-scaffold)

2016-09-15 Thread Joe Bogner
I've created a new demo of using PicoLisp with mithril to quickly prototype
apps.

The key feature is a scaffolding which generates crud operations and forms
for any +ApiEntity

https://github.com/joebo/pil-mithril-scaffold/blob/master/README.md

Create a todo app in less than 2 minutes (cheated a bit by copy pasting),
but the entire app should is less than 50 lines of application-specific
code.

It includes login, session management, a todo list and the ability to pick
a tag for a todo.

Next up I may create a blog or simple CRM app

Not ready for production yet, but great for prototyping

More to come!

Joe


Re: bcrypt

2016-09-19 Thread Joe Bogner
Mike, this looks great. What license covers this work - I see CC0 in the
root LICENSE[1] but didn't want to assume? Can I redistribute the source
with my example app?

[1] -
https://bitbucket.org/mihailp/tankfeeder/src/f9ad69ad2a6ec35941f50c4ec1160e7a53ea3e67/LICENSE?at=default&fileviewer=file-view-default

On Sun, Sep 18, 2016 at 9:00 AM, Alexander Burger 
wrote:

> Hi Mike,
>
> > bcrypt is ready
>
> Cool! Thank you!
> ♪♫ Alex
> --
> UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe
>


Re: bcrypt

2016-09-19 Thread Joe Bogner
perfect, thanks!

On Mon, Sep 19, 2016 at 9:03 AM, Mike Pechkin 
wrote:

>
> all under CC0.
> you are free to do you want.
>
> On Mon, Sep 19, 2016 at 3:12 PM, Joe Bogner  wrote:
>
>> Mike, this looks great. What license covers this work - I see CC0 in the
>> root LICENSE[1] but didn't want to assume? Can I redistribute the source
>> with my example app?
>>
>> [1] - https://bitbucket.org/mihailp/tankfeeder/src/f9ad69ad2a6ec35
>> 941f50c4ec1160e7a53ea3e67/LICENSE?at=default&fileviewer=file-view-default
>>
>> On Sun, Sep 18, 2016 at 9:00 AM, Alexander Burger 
>> wrote:
>>
>>> Hi Mike,
>>>
>>> > bcrypt is ready
>>>
>>> Cool! Thank you!
>>> ♪♫ Alex
>>> --
>>> UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe
>>>
>>
>>
>


Re: Subscribe

2016-11-11 Thread Joe Bogner
Hi dean,

Welcome!

I would probably do this:

: (in '(ls) (make (until (eof) (link (line T)
-> ("app" "bin" "CHANGES" "COPYING" "CREDITS" "cygwin" "db2" "dbg"
"dbg.l" "dev" "doc" "doc64" "ersatz" "ext.l" "games" "img" "INSTALL"
"lib" "lib.css" "lib.l" "loc" "man" "misc" "picoblogorg" "pil" "plmod"
"rcsim" "README" "simul" "src" "src64" "test")

Some comments:

pil makes it easy to experiment. I would first start with this experiment:

: (in '(ls) (line T))
-> "app"

We see that it returns a single item. So, we want to build a list of
multiple items. An efficient way to do this is with make/link. We can
loop until eof using (until (eof))

Hope this helps!
Joe



On Fri, Nov 11, 2016 at 8:07 AM, dean  wrote:
> I'm just wondering how you would capture the output from 'ls' to a list for
> further processing.
> I the first instance...I'd like to cd to a specified dir and caputure all
> subdir names so that I can
> cd to them in turn and process their pdf files, labelled 2005.pdf, 2006.pdf
> etc
>
> I've been playing around with the examples
>
>
> I tried to bend this
> https://rosettacode.org/wiki/Get_system_command_output#PicoLisp
>
> : (in '(uname "-om") (line T))
>
> to
>
> : (in (call 'ls) (line T))
>
> but no-go
>
> Thank you in anticipation for your consideration and for
>
> creating and supporting such an interesting little language.
>
> BTW This is my very first lisp program let alone picolisp program.
>
>
-- 
UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe


Re: First post

2016-11-12 Thread Joe Bogner
Hello Eric! Thanks for the introduction. Welcome! Looking forward to
your questions!

On Sat, Nov 12, 2016 at 9:45 AM, CILz  wrote:
> Dear list,
>
> I take the opportunity of this first post to introduce myself as well as the
> reasons for which I come here.
>
> I am not a computer scientist nor a professional web developper but a kind
> of "power user" who often gets its hands dirty to build some applications as
> close as possible to what he wants... That being said, I have mostly built
> some websites using off the shelf CMS ;-)
>
> However, my last "product" is a custom web application fully written from
> scratch in R to access a graph database. And this is why I am here: I want
> to rebuild it in order to add some "expert system" like capacity...
>
> So starting to digg around, I first came to Prolog a few weeks ago and I
> started learning it from scratch. This very week, I discovered Picolisp. I
> started exploring it, and so far, I am really impressed! It looks very
> appealing: having at hand a powerful language, a built-in database system as
> well as Prolog make me dream ... though I don't know if I am skilled enough
> to be able to do anything useful!
>
> Any way, I have it up an running on my linux box ... so expect me to ask
> very basic questions soon :)
>
> Best,
>
> Eric
>
> --
> UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe
-- 
UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe


Re: (< @X 18) doesn't behave as expected with pilog

2016-11-12 Thread Joe Bogner
Untested, but what about using range/3 ?
http://software-lab.de/doc/refR.html#range/3



On Sat, Nov 12, 2016 at 9:59 AM, CILz  wrote:
> Hello,
>
> Let's say that I have those two facts in a pilog database:
>
> (be age (Paul 18))
> (be age (Vincent 17))
>
> I'm looking for the guy under 18 with this rule:
>
> (be underage (@X)
>   (age @X @Y)
>   (< @Y 18))
>
> If I ask (? (underage @X)) the result here is -> NIL where I expect to get
> @X=Vincent.
>
> If I modify the above rule with:
>
> (be underage (@X)
>   (age @X @Y)
>   (equal @Y 18))
>
> The same query (? (underage @X)) now gives @X=Paul which is the expected
> result.
>
> I'm sure I'm missing something in the first case but I don't know what. Any
> idea?
>
> Thanks,
>
> Eric
>
> --
> UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe
-- 
UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe


Re: (< @X 18) doesn't behave as expected with pilog

2016-11-14 Thread Joe Bogner
Hi Alex,

range/3 seems to work as I expected. Should it not be used here?

(be age (Paul 19) )
(be age (Kate 17) )

(be underage (@X)
  (age @X @Y)
  (range (0 . 18) @Y))

(? (underage @X) )
 @X=Kate





On Sat, Nov 12, 2016 at 10:44 AM, Alexander Burger  wrote:
> Hi Joe,
>
>> Untested, but what about using range/3 ?
>> http://software-lab.de/doc/refR.html#range/3
>
> Thanks! However, range/3 is probably not useful here. It is a rather
> specialized predicate for range checks in database queries.
>
> ♪♫ Alex
> --
> UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe
--
UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe


Re: map-reduce

2016-11-14 Thread Joe Bogner
Thanks for sharing. This is an impressive example to show how to
execute a computation in parallel

The parallel magic seems to be here:

(chain
   (mapcan
  '((F) (later (cons) (-file F)))
  *MAPFILES ) )
(wait NIL (full (made))) )

great work!

On Mon, Nov 14, 2016 at 8:30 AM, Mike Pechkin  wrote:
> hi,
>
> My parallel-like map-reduce on (later) function:
> https://goo.gl/S36x3N
>
> Besides more tests for build-in functions it opens the gate to implement
> Blake2xP versions of SHA3 finalist which have parallel versions for speed
> up.
>
> Mike
>
-- 
UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe


  1   2   >