Re: Announce: PicoLisp in Hardware (PilMCU)

2014-09-21 Thread Doug Snead
Oh boy! I've been thinking of something like this for a while. 

What is the low-hanging fruit here, in the sense of, what applications might we 
do faster/cheaper/better in hardware like this, than can be done otherwise?  

The idea of pilog in hardware excites me too ... maybe time to go back and dust 
off old 1980s Fifth Generation Computer Systems project application ideas - 
http://en.wikipedia.org/wiki/Fifth_generation_computer

Maybe some cool application that can be done better now with pilog in hardware 
than could be done otherwise.  Same for the old lisp-machine/Symbolics 
applications, I wonder if there is anything useful from Symbolics' experience, 
in retrospect?  

The Fifth Generation Computer project was considered a failure but seems to be 
relevant to to picolisp (and pilog) in hardware.  

It would be really cool if picolisp in hardware ends up accomplishing things 
that caused Symbolics Inc and The Fifth Generation Computer Systems project to 
stumble.   I expect this to be the case.

Doug





On Fri, 9/19/14, Alexander Burger a...@software-lab.de wrote:

 Subject: Announce: PicoLisp in Hardware (PilMCU)
 To: picolisp@software-lab.de
 Date: Friday, September 19, 2014, 4:39 AM
 
 Hello List,
 
 we are proud to announce PilMCU, the Lisp Machine on a Chip!
 :)
 
 We, that is George Orais (who persuaded me into the project)
 and me.
 Georg built the actual machine in Verilog, and I did the
 changes and
 extensions to PicoLisp.
 
 
 PilMCU is an implementation of 64-bit PicoLisp directly in
 hardware. A
 truly minimalistic system. PicoLisp is both the machine
 language and the
 operating system:
 
    * Memory management is trivial, just the
 Lisp heap and the stack
    * The built-in database is extended to
 hold a file system
    * One SSD per database file for mass
 storage
    * Processes run as tasks and coroutines
    * Events (timing and interrupts) via a
 'wait' instruction
    * Complex I/O protocols are delegated to
 peripheral chips
 
 The final hardware can be very lightweight. Low transistor
 count and
 power consumption. No overhead for an OS. It is conceivable
 for a later
 stage to put many interconnected CPUs on a single chip.
 
 At present, we have it running in the Verilog simulator, and
 in an
 emulator (adaption of the PicoLisp 'emu' architecture).
 
 
 How shall we proceed? We need investors (or crowdfunding) to
 polish,
 manufacture and distribute the real thing.
 
 We imagine something in the line of an Embedded Lisp
 Machine or a
 Lisp Machine Kit. Perhaps for home brewing, educational
 institutions
 and/or robotics research?
 
 Is anybody interested -- or knows people who are?
 
 
 For the fun of it, here is a sample session:
 
    $ make mcu    vvp -M.
 -mtty mcu   # Build and start Verilog engine
    : 
 
    $ make emu    ./emu
 ssd@ ssdA     # Or: Build and start the
 emulator
    : 
 
 Now we are in an environment equivalent to the standard 'pil
 +'. The
 database is open on two image files for two SSD drives.
 Besides the
 normal, full DB functionality
 
    : (show *DB)
    {1} (7 . {17})
       T ({2} {20} {56} {64} {105} {146})
    - {1}
 
 you can call 'in', 'out', 'load' and 'rm' on files which are
 maintained
 in external symbols:
 
    : (dir)
    - (lib.l lib/)
 
    : (dir lib)
    - (btree.l db.l dbg.l misc.l
 pilog.l sq.l)
 
    : (in lib/db.l (read))
    - (de dbs Lst (default *Dbs (_dbs
 1)))
 
    : (out foo/bar/mumble.l (prinl Hello
 world))
    - Hello world
    : (in foo/bar/mumble.l (line))
    - (H e l l o   w o r
 l d)
 
    : (dir foo/bar)
    - (mumble.l)
 
    : (cd foo/bar)
    - foo/bar/
    : (dir)
    - (mumble.l)
 
    : (pwd)
    - foo/bar/
 
 Path names are stored as a normal B-Tree in the DB root:
 
    : (scan)
    foo/bar/mumble.l {172}
    lib.l {2}
    lib/btree.l {64}
    lib/db.l {105}
    lib/dbg.l {20}
    lib/misc.l {56}
    lib/pilog.l {146}
    lib/sq.l {166}
 
 They point to external symbols, like {2} for lib.l.
 
    (load '{2})
 
 is equivalent to
 
    (load lib.l)
 
 The values of these symbols hold the file size:
 
    : (show '{2})
    {2} 12401
    - {2}
 
 They should not have properties, and store the raw file data
 invisibly
 in dynamically maintained DB blocks.
 
 The rest of the system is standard PicoLisp :)
 
 ♪♫ Alex
 -- 
 UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe

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


Re: Android Demo

2012-10-10 Thread Doug Snead

I'll have to review my notes and see where I was on that. After some initial 
successes compiling, after testing more, I remember some snags in either mini 
picolisp or full picolisp involving some ARM vs x86 differences.   




--- On Tue, 10/9/12, Thorsten Jolitz tjol...@googlemail.com wrote:

 From: Thorsten Jolitz tjol...@googlemail.com
 Subject: Re: Android Demo
 To: picolisp@software-lab.de
 Date: Tuesday, October 9, 2012, 10:06 AM
 Doug Snead semaphore_2...@yahoo.com
 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: pilog in ersatz

2012-07-09 Thread Doug Snead
The pilog trace can be helpful in these situations.

: (be bigger (me her))
: (be bigger (her son))
: (be bigger (son daughter))
: (be bigger (@x @y) (bigger @x @z) (bigger @z @y))

List the assertions you want to trace before the clause to be proved, in this 
case bigger :

: (? bigger (bigger @x meily))

4 (bigger @x meily)
1 (bigger me her)
4 (bigger her meily)
2 (bigger her son)
4 (bigger son meily)
3 (bigger son daughter)
4 (bigger daughter meily)
4 (bigger daughter @y)
4 (bigger daughter @y)
4 (bigger daughter @y)
4 (bigger daughter @y)
4 (bigger daughter @y)
4 (bigger daughter @y)
4 (bigger daughter @y)
4 (bigger daughter @y)
4 (bigger daughter @y)
4 (bigger daughter @y)
4 (bigger daughter @y)
4 (bigger daughter @y)
4 (bigger daughter @y)
4 (bigger daughter @y)
...


So, it is infinitely recurring when trying to prove (bigger daughter @y).

The numbers in front of the pilog trace output lines correspond to the rule 
being proved at that stage. 

Hope that helps!

Cheers,

Doug




--- On Sun, 7/8/12, Christophe Gragnic christophegrag...@gmail.com wrote:

 From: Christophe Gragnic christophegrag...@gmail.com
 Subject: pilog in ersatz
 To: picolisp@software-lab.de
 Date: Sunday, July 8, 2012, 11:36 AM
 Hi all, I'm currently investigating
 Picolisp to teach prefix notation,
 and Pilog to teach first order logic.
 
 I have a problem with a set of instructions in ersatz:
 
 : (be bigger (me her))
 - bigger
 : (be bigger (her son))
 - bigger
 : (be bigger (son daughter))
 - bigger
 : (be bigger (@x @y) (bigger @x @z) (bigger @z @y))
 - bigger
 : bigger
 - NIL
 : (? (bigger @x meily))
  @x=alix
  @x=sw
 
 Then ersatz freezes, no prompt.
 Any idea?
 
 
 chri
 
 -- 
 Envoyé de ma messagerie électronique.
 Merci de divulguer cette adresse mail au minimum (pour les
 envois en
 groupe, utilisez la copie invisible).
 --
 UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe

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


Re: pilog in ersatz

2012-07-09 Thread Doug Snead
--- On Sun, 7/8/12, Christophe Gragnic christophegrag...@gmail.com wrote:
 : (be bigger (me her))
 - bigger
 : (be bigger (her son))
 - bigger
 : (be bigger (son daughter))
 - bigger
 : (be bigger (@x @y) (bigger @x @z) (bigger @z @y))
 - bigger
 : bigger
 - NIL
 : (? (bigger @x meily))
  @x=alix
  @x=sw

Hmmm. Where do alix and sw originate?  I do not understand that. 

(I was using full picolisp for my tracing before, I should have mentioned.) 

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


Re: Android Web Server

2012-02-24 Thread Doug Snead
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 joebog...@gmail.com wrote:

From: Joe Bogner joebog...@gmail.com
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?subject=Unsubscribe


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

2012-02-22 Thread Doug Snead
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 semaphore_2...@yahoo.com wrote:

 From: Doug Snead semaphore_2...@yahoo.com
 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?subject=Unsubscribe


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

2012-02-22 Thread Doug Snead
Hi Alex,

Ah, ok ... hmmm, that's two different platforms I have seen that problem on, 
then. The Android NDK also compiles the latest picoLisp ok, but then, same as 
that other (more standard) linux, dies in that port function with the same 
error.  

I can drop back to a pre-IPv6 version of picolisp and try that.

Cheers,

Doug


--- On Wed, 2/22/12, Alexander Burger a...@software-lab.de wrote:

 From: Alexander Burger a...@software-lab.de
 Subject: Re: server - IP socket error: Address family not supported by
 To: picolisp@software-lab.de
 Date: Wednesday, February 22, 2012, 10:53 PM
 Hi Doug,
 
  IP socket error: Address family not supported by
 protocol
 
 This error usually has a very simple reason:
 
    Your platform doesn't support IPv6
 
 Cheers,
 - Alex
 -- 
 UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe

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


android success with full picolisp

2012-02-20 Thread Doug Snead
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?subject=Unsubscribe


Re: miniPicoLisp Transients

2012-01-26 Thread Doug Snead
--- On Thu, 1/26/12, Alexander Burger a...@software-lab.de wrote:
  (setq V 456)
  at the top level (not in a definition) that works as
 expected
 
 Again strange. It shouldn't matter how the symbol is used
 (globally or bound locally).

Hi Alex,

Thanks for the guidance!

On second look, I was wrong about  (setq V 456)  ... it returns V from the 
top level on the (incomplete) android arm port.  Close, though.  :-)

Cheers,

Doug



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


miniPicoLisp Trasnients

2012-01-25 Thread Doug Snead
Alex, 

I have a porting-related question for you. 

After more android testing I'm finding a problem with (transient) variables  
... (I think).

When I try a definition like this,

(de foo (x) x)

no problem,

(foo 123)

returns 123 as expected.


But when I try it this way:

(de baz (X) X)

(baz 123)

I should get 123 but instead I get:

X

However, if I try 

(setq V 456)

at the top level (not in a definition) that works as expected, and evaluating 
V later returns 456

I wonder why it might not see X as a transient?  (Er, I'm not even sure if 
transient is the the right terminology here.)

Does anything leap out at you there?  :-) 

Cheers,

Doug

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


Re: PicoLisp is DEAD (Was: PicoLisp and its (lack of) libraries)

2012-01-24 Thread Doug Snead
After many merry rounds of compilation and discovery, it seems that the 
ndk-build's compiler -falign-functions[=n] and friends align functions relative 
to this option, but off by one (+1, or is that just |1?).;-)

In pico.h, sadly, I besmirched the code thusly,

#ifdef ANDROID_ARM
// android arm seems to have weird off-by-one alignment
#define FUNCT2LISP_ALIGN(f) ((f)-1) // hopefully optimise to 
#define LISP2FUNCT_ALIGN(f) ((f)+1) // a single  inc  ...
#else
#define FUNCT2LISP_ALIGN(f) (f)
#define LISP2FUNCT_ALIGN(f) (f)
#endif

#define evSubr(f,x) (*(fun)( LISP2FUNCT_ALIGN( num(f) )  ~2 ) )(x)

so in boxSubr in main.c, 

   if (num(FUNCT2LISP_ALIGN(f))  3)
  giveup(Unaligned Function);
   return (any)(num(FUNCT2LISP_ALIGN(f)) | 2);

(Er, I bet I missed some places, need to check.)

And then to talk with java I used the miniPicoLisp string-based library mods 
mentioned earlier, with a little jni C glue to hold it together. 

Cheers,

Doug


--- On Mon, 1/23/12, Jakob Eriksson ja...@aurorasystems.eu wrote:

 From: Jakob Eriksson ja...@aurorasystems.eu
 Subject: Re: PicoLisp is DEAD (Was: PicoLisp and its (lack of) libraries)
 To: picolisp@software-lab.de
 Date: Monday, January 23, 2012, 11:47 PM
 
 
 On January 24, 2012 at 7:49 AM Doug Snead semaphore_2...@yahoo.com
 wrote:
 
 
  I have a (slightly hacked) version of miniPicoLisp
 running as an android
  native library as a proof of concept.  No no
 additional java interpretation
  penalty.
  
  
 Wow, this is interesting!
  
  
 
  My thought is that now I have a new tool - a way to
 make picolisp and pilog
  (prolog) work in android, but will do the UI in java
 like most android apps.
  
  
 That is how I plan to use (mini)PicoLisp in my program too.
  
  
  
 
  But miniPicoLisp is pure, and easier to port.
  
 Indeed, and for me the most interesting right now.
  
 best regards,
 Jakob
  
 --
 UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe

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


Re: PicoLisp is DEAD (Was: PicoLisp and its (lack of) libraries)

2012-01-23 Thread Doug Snead
--- On Mon, 1/23/12, Jakob Eriksson ja...@aurorasystems.eu wrote:
 The Java version opens up the path to Android jobs - and I
 have an impression that those are still a kind of Wild West. 

I have a (slightly hacked) version of miniPicoLisp running as an android native 
library as a proof of concept.  No no additional java interpretation penalty. 

The C-compiler (gcc?) for the ARM processor used in android ndk-build has odd 
ideas about function alignment that gave me a hard time until I saw what was 
happening. 

My thought is that now I have a new tool - a way to make picolisp and pilog 
(prolog) work in android, but will do the UI in java like most android apps. 

Not sure if porting the full PicoLisp to androig ndk jni would be easier or 
harder then the Cygwin port, say. The Cygwin port wasn't difficult ... 
until we discovered the Many Joys of Win32 file locking.  

But miniPicoLisp is pure, and easier to port. 

:-)

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


re: tags

2011-11-14 Thread Doug Snead
FWIW ... here's something I use instead of ctags for picolisp. 

$ cat /usr/local/bin/lisptags

#!/bin/sh 
# make a tags file for pico lisp source files.
# use:
#   lisptags foo.l bar.l baz.l ... bof.l
# generate the file 'tags'
# [based on lisptags csh script by John Foderaro, c.1982]
awk '
/^[ \t]*\(d[em][ \t]/ { print $2 \t FILENAME \t?^ $0 $? }
/^[ \t]*\(class[ \t]/ { print $2 \t FILENAME \t?^ $0 $? }
' $* | sort  tags


Doug


--- On Mon, 11/14/11, Henrik Sarvell hsarv...@gmail.com wrote:

 From: Henrik Sarvell hsarv...@gmail.com
 Subject: Re: How to get the signature of function and method definitions
 To: picolisp@software-lab.de
 Date: Monday, November 14, 2011, 6:59 AM
 It's at the end here:
 http://www.prodevtips.com/2010/09/29/emacs-color-themes-tags-cedet-ecb-and-other-customizations/
 
 Not much to it, I do things old school ie I put the
 download in
 /opt/picolisp and simply cd there in a shell and do: ctags
 -e -R
 --languages=-JavaScript,-PHP,-C,-Make,-HTML
 

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


Re: error message line numbers

2011-09-06 Thread Doug Snead
Thanks for the reply, Alex.  

I need to use Windows without cygwin dlls for an application I'm working on 
now.  So, I had been using miniPicoLisp in my application, which compiles ok 
under mingw.  That let me avoid even trying to compile regular PicoLisp using 
mingw, and the porting issues that would involve. 

But now I might have to take a look at trying PicoLisp with mingw.  I know the 
file locking will probably be an issue, but not sure what else might be a snag 
with PicoLisp under mingw. 

On the other hand, I was able to hack in some support for line numbers and file 
names for error messages in miniPicoLisp, relatively quickly.  

Cheers,

Doug




--- On Sun, 9/4/11, Alexander Burger a...@software-lab.de wrote:

 From: Alexander Burger a...@software-lab.de
 Subject: Re: error message line numbers
 To: picolisp@software-lab.de
 Date: Sunday, September 4, 2011, 11:29 PM
 Hi Doug,
 
  Is there a way I can make (mini)PicoLisp give me line
 numbers from .l source files in error messages?  There
 are lots of gnu and/or linux tools (like vim) and IDEs etc.,
 that want error messages in a format similar to what gcc
 spits out, like:
  
  Baz.cpp:321: error: 'foobar' was not declared in this
 scope
  
  (I poked around in the code and on the site looking,
 but missed it if it is there.)
 
 All other PicoLisp implementations (64-bits, 32-bits and
 Ersatz) have
 this feature. They keep track of the file name and line
 number in the
 'inFile' structure (or LineNumberReader in case of Java).
 
 For MiniPicoLisp this is difficult, because it uses plain
 stdio instead
 of a dedicated 'inFile' structure.
 
 Cheers,
 - Alex
 -- 
 UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe

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


error message line numbers

2011-09-04 Thread Doug Snead
Hi Alex,

Is there a way I can make (mini)PicoLisp give me line numbers from .l source 
files in error messages?  There are lots of gnu and/or linux tools (like vim) 
and IDEs etc., that want error messages in a format similar to what gcc spits 
out, like:

Baz.cpp:321: error: 'foobar' was not declared in this scope

(I poked around in the code and on the site looking, but missed it if it is 
there.)

Cheers

Doug

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


Re: pilog dcg with args

2011-07-27 Thread Doug Snead
Hi Alex,

Thanks for the picolisp pointers :-)  The sub? shrinks down one of the awkward 
bits there. Unfortunately, I didn't see sub? in miniPicoLisp.  The replace 
seems like a better idea than using the surgical patch there - probably not a 
good idea to modify a list passed in as an argument like I am doing with patch. 

Cheers,

Doug







--- On Sun, 7/24/11, Alexander Burger a...@software-lab.de wrote:

 From: Alexander Burger a...@software-lab.de
 Subject: Re: pilog dcg with args
 To: picolisp@software-lab.de
 Date: Sunday, July 24, 2011, 2:36 AM
 Hi Doug,
 
  http://victoriafamilyrobotics.net/vfr1/media/read_line.l
 
 Please allow me to post some minor hints:
 
 
 When a single character is checked for a number of values
 like in
 
    (or (= X ,) (= X .) (= X ?))
 
 then I would write instead:
 
    (sub? X ,.?)
 
 
 For the modification of a list
 
    (patch L , '(  ,))
    (patch L . '(  .))
    (patch L ? '(  ?))
 
 I would use
 
    (replace L  , '(  ,)  .
 '(  .)  ? '(  ?))
 
 Note, however, that 'replace' is non-destructive, so you
 need to use the
 returned value in the following expression (or 'setq' it to
 'L').
 
 Cheers,
 - Alex
 -- 
 UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe

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


Re: pilog and Definite Clause Grammar (DCG)

2011-07-20 Thread Doug Snead

THANK YOU! 

I haven't tested that yet but I think that is exactly what I was looking for 
there.  Might be something to consider adding to pilog.l  Seems to be fairly 
standard in prologs - and useful for creating parsers :-)

Beautiful code, thanks again so much! 

Cheers,

Doug




--- On Wed, 7/20/11, Alexander Burger a...@software-lab.de wrote:

 From: Alexander Burger a...@software-lab.de
 Subject: Re: pilog and Definite Clause Grammar (DCG)
 To: picolisp@software-lab.de
 Date: Wednesday, July 20, 2011, 2:20 AM
 Hi Doug,
 
  What's the best way to handle Definite Clause Grammar
 syntax in pilog?
  ..
  So, I'm hoping for some pilog rules or a macro maybe
 that can handle
  the -- (or equivalent) of DCG in pilog :-)
 
 I don't fully understand the context or purpose, but
 
    http://en.wikipedia.org/wiki/Definite_clause_grammar
 
 says that DCG notation is just syntactic sugar for normal
 definite
 clauses in Prolog.
 
 So you can write a function 'dcg' which does the necessary
 translation.
 
 I would simply call 'be' here, using 'macro' because 'be'
 doesn't
 evaluate its arguments (i.e. is a FEXPR):
 
    (de dcg CL
       (macro
          (be
             ^(if (pair (cadr
 CL))
            
    (list (car CL) (list (cons (caadr CL) '@A)
 '@A))
            
    (cons
                
   (car CL)
                
   '(@In @Out)
                
   (let Vars
                
      (make
                
         (link @In)
                
         (for (I . @) (cddr CL)
                
            (link (pack
 @ I)) )
                
         (link @Out) )
                
      (mapcar list
                
         (cdr CL)
                
         Vars
                
         (cdr Vars) ) ) ) ) ) ) )
 
 With that, the example in Wikipedia could be written as
 
    (dcg sentence  nounPhrase
 verbPhrase)
    (dcg nounPhrase  det noun)
    (dcg verbPhrase  verb nounPhrase)
    (dcg det [the])
    (dcg det [a])
    (dcg noun [cat])
    (dcg noun [bat])
    (dcg verb [eats])
 
 This expands to
 
    : (rules 'sentence 'nounPhrase
 'verbPhrase 'det 'noun 'verb)
    1 (be sentence (@In @Out) (nounPhrase
 @In @1) (verbPhrase @1 @Out))
    1 (be nounPhrase (@In @Out) (det
 @In @1) (noun @1 @Out))
    1 (be verbPhrase (@In @Out) (verb
 @In @1) (nounPhrase @1 @Out))
    1 (be det ((the . @A) @A))
    2 (be det ((a . @A) @A))
    1 (be noun ((cat . @A) @A))
    2 (be noun ((bat . @A) @A))
    1 (be verb ((eats . @A) @A))
    - verb
 
 Does this help?
 
 Cheers,
 - Alex
 -- 
 UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe

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


pilog and Definite Clause Grammar (DCG)

2011-07-19 Thread Doug Snead
Alex (or anyone),

What's the best way to handle Definite Clause Grammar syntax in pilog? 

Definite Clause Grammar (DCG) and Prolog supports a special rule syntax for 
writing DCGs. The syntax is simpler, much closer to the syntax one uses in 
writing context-free grammar rules. When using the DCG syntax, the programmer 
doesn't have to write all the string variables threaded through the nonterminal 
procedure calls...
http://www.cs.sunysb.edu/~warren/xsbbook/node10.html

http://www.csupomona.edu/~jrfisher/www/prolog_tutorial/7_1.html
etc.

So, I'm hoping for some pilog rules or a macro maybe that can handle the -- 
(or equivalent) of DCG in pilog :-) 

Cheers,

Doug


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


pilog: Prolog Tutorial, 2.19 Actions and plans

2011-07-15 Thread Doug Snead
Here's another prolog-to-pilog translation, this time from John Fisher's 
excellent Prolog Tutorial, 2.19 Actions and plans 
http://www.csupomona.edu/~jrfisher/www/prolog_tutorial/2_19.html 

prolog:
 http://www.csupomona.edu/~jrfisher/www/prolog_tutorial/2_19pl.txt 

to pilog:
  http://victoriafamilyrobotics.net/vfr1/media/sec2_19.l

This was an easier example than golog.l, but I definitely needed some of the 
call-related tricks I learned before! 

To run it, for example, here's do([on(c,b),on(b,a),on(a,table)]) -- shown about 
three-fourths of the way down the tutorial page -- which is defined as test t_4 
in the pilog source file sec2_19.l

# ~/lisp/miniPicoLisp
$ ./pil sec2_19.l  -t_4 -bye
1 (do ((on c b) (on b a) (on a table)))
1 (do_all ((on c b) (on b a) (on a table)) ((on c b) (on b a) (on a table)))
2 (do_all ((on c b) (on b a) (on a table)) ((on c b) (on b a) (on a table)))
1 (achieve (on c b))
1 (do_all ((on c b) (on b a) (on a table)) ((on c b) (on b a) (on a table)))
1 (do_all ((on b a) (on a table)) ((on c b) (on b a) (on a table)))
2 (do_all ((on b a) (on a table)) ((on c b) (on b a) (on a table)))
1 (achieve (on b a))
1 (do_all ((on c b) (on b a) (on a table)) ((on c b) (on b a) (on a table)))
2 (do_all ((on c b) (on b a) (on a table)) ((on c b) (on b a) (on a table)))
1 (achieve (on c b))
1 (do_all ((on c b) (on b a) (on a table)) ((on c b) (on b a) (on a table)))
1 (do_all ((on b a) (on a table)) ((on c b) (on b a) (on a table)))
1 (do_all ((on a table)) ((on c b) (on b a) (on a table)))
3 (do_all NIL ((on c b) (on b a) (on a table)))
on/move:
1 (be on (a table))
2 (be on (b a))
3 (be on (c b))
1 (be move (a b table))
2 (be move (b c table))
3 (be move (c table b))
4 (be move (c b table))
5 (be move (b table a))
6 (be move (c table b))


Cheers,

Doug


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


Re: The PicoLisp Ticker

2011-07-15 Thread Doug Snead

I think you created a bot-trap :-)

--- On Fri, 7/15/11, Alexander Burger a...@software-lab.de wrote:

 From: Alexander Burger a...@software-lab.de
 Subject: The PicoLisp Ticker
 To: picolisp@software-lab.de
 Date: Friday, July 15, 2011, 12:58 AM
 Hi all,
 
 let me share my funny experiences about the PicoLisp
 Ticker, and how it
 is handled by Mr. Google:
 
    http://picolisp.com/5000/-2-1i.html
 
 Cheers,
 - Alex
 -- 
 UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe

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


re: Ninety-Nine Lisp Problems: pilog

2011-07-15 Thread Doug Snead
re: the 24jul10 comment: The more of the higher-numbered problems... are 
really typical Prolog problems! All of them involve recursive searches in some 
solution space. http://picolisp.com/5000/-2-1K.html 

Then perhaps picolisp's Prolog (pilog) would be ideal?  I'm always happy to see 
pilog examples.   

(BTW - Many people might not realise the heart of pilog, the prove function, is 
written in C and seems very fast. For some prolog applications, it may be fast 
or faster than compiled prologs - would like to see some benchmarks to 
investigate that feeling. But for years, I was under the false impression that 
pilog was completely written in lisp and so pilog programs were doubly 
interpreted, but I was wrong: the heart of the pilog interpreter is C.) 

I'm searching for a pilog A* (Astar) implementation example these days. :-] 

Cheers,

Doug

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


heap miniPicoLisp question

2011-07-13 Thread Doug Snead
~/build/miniPicoLisp
# ./pil 
: (heap)
- 1
: (heap T)
- 0
: 

Shouldn't I see something else - or is that correct for miniPicoLisp ? 

Cheers,

Doug

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


android picolisp using ndk/jni

2011-07-07 Thread Doug Snead
http://developer.android.com/sdk/ndk/overview.html :
Typical good candidates for the NDK are self-contained, CPU-intensive 
operations that don't allocate much memory, such as signal processing, physics 
simulation, and so on.

Ok, here's a plan for :-) a real Android picolisp ... start by taking a version 
of picolisp, and begin cutting it back by dropping everything ndk c/c++ headers 
do not support.So, the idea would be you'd get much of picolisp, hopefully 
more than minipicolisp, at least as much as ersatz, (I would think), and with 
no java interpretation penalty for the lisp interpreter. 

re: ... that don't allocate much memory. Fine; allocate what you need per 
application on init (from java), pass it to android picolisp to use. 


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


Re: pilog question

2011-07-05 Thread Doug Snead
Hi Alex,

Ah, the situation is not so bad IMO.  To begin with, this is an obscure thing 
to do, I think - maybe somewhat pedantic. It forces golog to be prolog, in a 
sense. And there are workarounds which you provided. And I think you're right: 
it should be possible to restructure the involved golog.l rules to do this 
better. 

Maybe another rule or a lisp function can be written, which gets the bindings 
instantiated and copied out to another, less partially unified, expression. 

Or maybe a way to make that pilog magic number to bind at the desired level, 
*and all levels above that also*, perhaps if a negative magic numbers appears 
there. (But I wouldn't touch doProve, if it slows it down!)

In any event, the golog.l source and simple test program are now in the public 
domain and so hopefully better pilog programmers than I are able to smooth that 
out. 

I think translating golog into pilog has been a great review of prolog and 
pilog and golog for me personally - hopefully useful for others on the list and 
elsewhere! 

I'm guessing picolisp/pilog for embedded systems will get more popular over 
time, as people see the advantages :-) 

Thanks for all the help!

Doug






--- On Mon, 7/4/11, Alexander Burger a...@software-lab.de wrote:

 From: Alexander Burger a...@software-lab.de
 Subject: Re: pilog question
 To: picolisp@software-lab.de
 Date: Monday, July 4, 2011, 10:55 PM
 Hi Doug,
 
  Hmmm, what's the best answer for stackoverflow? 
  
       (2 cons (- @F)))
  
  Tune the magic number to allow the correct
 unification bindings to
  reach up into rules which are calling this one, as far
 as needed, in a
  given application. The value of 2 here works for one
 test, but use 3 to
  make the other test work.
 
 Hmm, unsatisfactory ... :(
 
 I'm not very happy with the situation. It is a design flaw
 in Pilog.
 
 
 A cleaner solution would be to restructure the involved
 rules in such a
 way that the bindings are propagated up the normal way
 through the
 call hierarchy (and not from a deeply nested level directly
 to the top).
 I'm not sure how to do it in the case of golog, though.
 
 Cheers,
 - Alex
 -- 
 UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe

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


pilog question

2011-07-04 Thread Doug Snead
Consider these five pilog assertions.

(be do ((Question @P) @S @S) (holds @P @S))

(be holds (@A @S)
   (restoreSitArg @A @S @F)
   (2 cons (- @F)))

(be On (3 s0))
(be On (5 s0))

(be restoreSitArg ((On @N) @S (On @N @S)))

I define some tests.

(de t_1 () # ok
  (? holds On restoreSitArg (holds (On @N) s0))  )

(de t_2 () #  ?
  (? do holds On restoreSitArg (do (Question (On @N)) s0 s0))  )

Run the first one.

(t_1)
1 (holds (On @N) s0)
1 (restoreSitArg (On @N) s0 (On @N s0))
1 (On 3 s0)
 @N=3
2 (On 5 s0)
 @N=5
- NIL

Ok, in that first test, I asked for solutions to (holds (On @N) s0)), tracing 
on.

Those are solutions I would expect, and they are correct. 

Second test.

(t_2)
1 (do (Question (On @N)) s0 s0)
1 (holds (On @N) s0)
1 (restoreSitArg (On @N) s0 (On @N s0))
1 (On 3 s0)
 @N=NIL
2 (On 5 s0)
 @N=NIL
- NIL

Now here, (holds (On @N) s0) is also attempted to be proved - because it is a 
sub-goal of (do (Question (On @N)) s0 s0).

My question is, why the difference when (holds (On @N) s0) is proved? 

In one case solutions are found, in the other case it seems to miss the same 
solutions to the same goal. 

Cheers,

Doug

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


Re: pilog question

2011-07-04 Thread Doug Snead
Thanks Alex!

I ended up taking it up to (5 cons (- @F)) to get the first simple elevator 
example working.  Still a bit wonky in that respect. (Might have to adjust that 
magic unification level number per application!)  

But this definitely shows golog pilog is possible. 

Here's a page where golog.l and an example program (simple elevator) may be 
downloaded  http://victoriafamilyrobotics.net/vfr1/golog  

Cheers,

Doug





--- On Mon, 7/4/11, Alexander Burger a...@software-lab.de wrote:

 From: Alexander Burger a...@software-lab.de
 Subject: Re: pilog question
 To: picolisp@software-lab.de
 Date: Monday, July 4, 2011, 2:18 AM
 Hi Doug,
 
  (be do ((Question @P) @S @S) (holds @P @S))
  
  (be holds (@A @S)
     (restoreSitArg @A @S @F)
     (2 cons (- @F)))
 
 Maybe this mechanism of explicitly specifying a number for
 the outer
 environment for unifying a clause is an an unfortunate
 limitation of
 Pilog. I don't know a better way, though.
 
 As I said, '2' tells the interpreter to unify in level 2,
 meaning
 the next level outside of 'holds'. So the query
 
    (? (holds (On @N) s0))
 
 works, because you are unifying with the top level.
 
 On the other hand, if you'd defined
 
    (be holds (@A @S)
       (restoreSitArg @A @S @F)
       (3 cons (- @F)) )
 
 i.e. specify level '3', the above query would not bind
 '@N', but the
 second query
 
    (? (do (Question (On @N)) s0 s0))
 
 would bind it in turn.
 
 
 So as long as 'do' doesn't have '@N' in its environment
 (i.e. the level
 above 'hold'), specifying '2' in 'hold' causes the binding
 to get lost.
 
 I'm not sure if the Pilog interpreter could be easily
 rewritten to
 behave in a better way.
 
 Would it help to use '3' in 'hold'? Or, if you have cases
 where you also
 need '2', to use two versions of 'hold'?
 
 Cheers,
 - Alex
 -- 
 UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe

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


Re: pilog question

2011-07-04 Thread Doug Snead
Hmmm, what's the best answer for stackoverflow? 

 (2 cons (- @F)))

Tune the magic number to allow the correct unification bindings to reach up 
into rules which are calling this one, as far as needed, in a given 
application. The value of 2 here works for one test, but use 3 to make the 
other test work.

? 



--- On Mon, 7/4/11, Jakob Eriksson ja...@vmlinux.org wrote:

 From: Jakob Eriksson ja...@vmlinux.org
 Subject: Re: pilog question
 To: picolisp@software-lab.de
 Date: Monday, July 4, 2011, 5:04 AM
 
 
 http://stackoverflow.com/questions/6571200/pilog-assertion
 
 
 On Mon, Jul 04, 2011 at 12:26:46AM -0700, Doug Snead
 wrote:
  Consider these five pilog assertions.
  
  (be do ((Question @P) @S @S) (holds @P @S))
  
  (be holds (@A @S)
     (restoreSitArg @A @S @F)
     (2 cons (- @F)))
  
  (be On (3 s0))
  (be On (5 s0))
  
  (be restoreSitArg ((On @N) @S (On @N @S)))
  
  I define some tests.
  
  (de t_1 () # ok
    (? holds On restoreSitArg (holds (On
 @N) s0))  )
  
  (de t_2 () #  ?
    (? do holds On restoreSitArg (do
 (Question (On @N)) s0 s0))  )
  
  Run the first one.
  
  (t_1)
  1 (holds (On @N) s0)
  1 (restoreSitArg (On @N) s0 (On @N s0))
  1 (On 3 s0)
   @N=3
  2 (On 5 s0)
   @N=5
  - NIL
  
  Ok, in that first test, I asked for solutions to
 (holds (On @N) s0)), tracing on.
  
  Those are solutions I would expect, and they are
 correct. 
  
  Second test.
  
  (t_2)
  1 (do (Question (On @N)) s0 s0)
  1 (holds (On @N) s0)
  1 (restoreSitArg (On @N) s0 (On @N s0))
  1 (On 3 s0)
   @N=NIL
  2 (On 5 s0)
   @N=NIL
  - NIL
  
  Now here, (holds (On @N) s0) is also attempted to be
 proved - because it is a sub-goal of (do (Question (On @N))
 s0 s0).
  
  My question is, why the difference when (holds (On @N)
 s0) is proved? 
  
  In one case solutions are found, in the other case it
 seems to miss the same solutions to the same goal. 
  
  Cheers,
  
  Doug
  
  -- 
  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: pilog: unification in variables that are clauses

2011-07-01 Thread Doug Snead
Thanks Alex!!!

We have golog in pilog.  Er, I think :-)  If not we're pretty dang close.   
Still trying to get the simple elevator example going from Knowledge in 
Action as a test.  http://www.cs.toronto.edu/cogrobo/kia/simpleElevator 
 http://books.google.com/books?q=%22proc%28goFloor%22  etc.

After golog, maybe indigolog ? 

With miniPicoLisp at 100 to 150k (depending on platform, build options, etc.) 
and with pilog + golog loaded, it has to be the smallest footprint golog (with 
a respectable prolog and lisp under the hood), around.  Might be right for 
embedded systems, I'm thinking. 

Cheers,

Doug









--- On Thu, 6/30/11, Alexander Burger a...@software-lab.de wrote:

 From: Alexander Burger a...@software-lab.de
 Subject: Re: pilog: unification in variables that are clauses
 To: picolisp@software-lab.de
 Date: Thursday, June 30, 2011, 11:55 PM
 Hi Doug,
 
 the following works:
 
    (be a (3))
 
    (be foo @C
       (2 - @C) )
 
 
    : (? (foo (a @Z)))
     @Z=3           
     
    - NIL
 
 I spied what 'call/1' is doing ;-) That number magic with
 '2' is a bit
 tricky, I'm never sure what level to pick. Basically it
 tells the
 interpreter with which level it should unify (here, the
 level outside of
 'foo').
 
 
 Actually, you could also use
 
    (be foo (@C)
       (2 cons (- @C)) )
 
 but this needs additional consing for the expression to
 match, so I
 would avoid it. It depends on what else is done with '@C'.
 
 Cheers,
 - Alex
 -- 
 UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe

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


pilog: unification in variables that are clauses

2011-06-30 Thread Doug Snead
--- On Wed, 6/29/11, Alexander Burger a...@software-lab.de wrote:

 So this should be written as

(be holds (@A @S)
 (or
  ((restoreSitArg @A @S @F) (@ solve (list (- @F
  ((not (restoreSitArg @A @S @F)) (isAtom @A) (@ solve (list (- @A ) )

 holds(A,S) :- restoreSitArg(A,S,F), F ;
  \+ restoreSitArg(A,S,F), isAtom(A), A.

Now I think that the variables-as-clauses are getting me.  In this rule, F 
might get bound to (unified with?) a clause with variables. For example, F 
might be bound to something like on(N,s0)  When the F clause (now bound to 
on(N,s0)) is then proved, the N variable in on(N,s0) gets bound to something 
(3, for example).  

[trace]  ?- holds(on(N), s0 ).
   Call: (6) holds(on(_G386), s0) ? creep
   Call: (7) restoreSitArg(on(_G386), s0, _G462) ? creep
   Exit: (7) restoreSitArg(on(_G386), s0, on(_G386, s0)) ? creep
   Call: (7) on(_G386, s0) ? creep
   Exit: (7) on(3, s0) ? creep
   Exit: (6) holds(on(3), s0) ? creep
N = 3 .


When I try to do this as (@ (solve (list (- @F in pilog, taking it through 
lisp , it prevents the values of the unified vars in @F from being used in the 
surrounding pilog rule.

? (? (holds (On @N) s0))
- T
? (solve '((holds (On @N) s0)))
- (T)

I wonder what I should do in this case, where a variable can be bound to a 
clause like that and the variables in that clause need to be bound, too? 

Cheers,

Doug

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


Re: pilog: unification in variables that are clauses

2011-06-30 Thread Doug Snead
Hi Alex,

Thanks for your help!

holds(A,S) :- restoreSitArg(A,S,F), F ;
   \+ restoreSitArg(A,S,F), isAtom(A), A.

What I really want is this:

(be holds (@A @S)
   (or
 ((restoreSitArg @A @S @F) @F)
 ((not (restoreSitArg @A @S @F)) (isAtom @A) @A) ) )

But the above (with a @F or @A for a clause) doesn't work. :-(  

This -

(be holds (@A @S)
   (or
 ((restoreSitArg @A @S @F) (@ - @F))
 ((not (restoreSitArg @A @S @F)) (isAtom @A)  (@ - @A)) ) )

gives me the same results as using the (@ solve (list (- @F))) clause. Neither 
that nor (@ - @F) seem to unify variables in @F (which is bound to a clause)

:  (solve '((holds (On @N) s0)))
- (T)

Solves, but it also should tell me @N is bound to 3


Cheers,

Doug



--- On Thu, 6/30/11, Alexander Burger a...@software-lab.de wrote:

 From: Alexander Burger a...@software-lab.de
 Subject: Re: pilog: unification in variables that are clauses
 To: picolisp@software-lab.de
 Date: Thursday, June 30, 2011, 12:27 AM
 On Thu, Jun 30, 2011 at 09:20:43AM
 +0200, Alexander Burger wrote:
  At least, a simple (@ . @A) should work. Doesn't it?
 
 Wait ... probably not a good idea.
 
 But this should work: (@ - @A)
 -- 
 UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe
 
-- 
UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe


Re: pilog: unification in variables that are clauses

2011-06-30 Thread Doug Snead
Here's the issue boiled down to a simpler test case :-) First, swi-prolog:

# cat t.pl 

a(3).

foo(N) :- N.

bar(a(X)) :- a(X).


# swipl -f t.pl 
% /root/prolog/t.pl compiled 0.00 sec, 2,800 bytes ...

?- trace.
true.

[trace]  ?- bar(a(Z)).
   Call: (6) bar(a(_G386)) ? creep
   Call: (7) a(_G386) ? creep
   Exit: (7) a(3) ? creep
   Exit: (6) bar(a(3)) ? creep
Z = 3.

[trace]  ?- foo(a(Z)).
   Call: (6) foo(a(_G386)) ? creep
   Call: (7) a(_G386) ? creep
   Exit: (7) a(3) ? creep
   Exit: (6) foo(a(3)) ? creep
Z = 3.


In both cases, Z is correctly bound to 3. (The foo rule is the one we are 
interested in.)


$ cat t.l 

(be a (3))

(be foo (@C)
  (@C - @C))

(be bar ((a @N))
   (a @N))

~/lisp/miniPicoLisp
$ ./pil  t.l 
: (? a bar (bar (a @X)))
1 (bar (a @N))
1 (a 3)
 @X=3
- NIL


That is correct:  @X=3  ... however :


: (? a foo (foo (a @X)))
1 (foo (a @X))
 @X=NIL
- NIL
: 

But they should be the same, as @X = 3 is a (is the) solution. Moreover, in foo 
(a @X) is never even tried to be proven.   

So I think this test case demonstrates the issue.  



 I still don't understand why this test of @A and/or @F for
 being non-NIL is necessary at all. This looks unusual to me. 

  holds(A,S) :- restoreSitArg(A,S,F), F ;
   \+ restoreSitArg(A,S,F), isAtom(A), A.

Me too. At first, I also thought they simply were testing for non-NIL there. 

But the intent of the 'naked' F and A clauses there seems to be this: If the 
data bound to F (or A) is itself a clause, then that clause gets proved and 
variables in it get unified/bound. 

So after the first restoreSitArg(A,S,F), F starts out as partially bound to a 
clause like on(N,s0) - which itself has an unbound variable, N. 

After F is proven, N is bound to 3 (because on(3,s0) is asserted elsewhere, and 
so N = 3 is a solution). 

A bit tricky, with variables bound to clauses which, in turn, have in them 
other unbound variables that may get bound.

Using call/1 there (not sure if this is the way I should use it) gives similar 
results, where (a @X) is not attempted to be proven. 

$ cat t.l 
(be a (3))

(be foo (@C)
  # (@C - @C))
  (call @C))

~/lisp/miniPicoLisp
$ ./pil  t.l 
: (? a foo call (foo (a @X)))
1 (foo (a @X))
1 (call (a @X))
- NIL
: 

Cheers,

Doug

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


Re: Picked from HN: `First-class environments.'

2011-06-30 Thread Doug Snead
Nice!  I like that site rosettacode.org lots.  (I stopped counting how many 
computer 'languages' I have assimilated over the years!) 

This example again shows off picolisp/pilog nicely. 

  http://rosettacode.org/wiki/24_game/Solve#PicoLisp

I think the perl solution may be a tad smaller. But most of us can't scan the 
perl one easily - the perl example there is dense and appears to be obfuscated. 
 The picolisp/pilog example is not obfuscated and is smooth and clean IMO.  :-) 
  


--- On Thu, 6/30/11, Alexander Burger a...@software-lab.de wrote:

 From: Alexander Burger a...@software-lab.de
 Subject: Re: Picked from HN: `First-class environments.'
 To: picolisp@software-lab.de
 Date: Thursday, June 30, 2011, 5:50 AM
 Hi dexen + all,
 
 I accepted the challenge, and posted a new task to
 RosettaCode:
 
    http://rosettacode.org/wiki/First_class_environments
 
 The PicoLisp solution is quite clean, IMHO.
 
 Cheers,
 - Alex
 -- 
 UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe

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


Re: pilog: unification in variables that are clauses

2011-06-30 Thread Doug Snead
The solve way seems to some closest to doing it.

~/lisp/miniPicoLisp
$ cat t.l 
(be a (3))

(be foo (@C)
  # (@C - @C)
  # (call @C)
  (@ print (solve (list (- @C
  )

$ ./pil  t.l 
: (? a foo (foo (a @Z)))
1 (foo (a @Z))
(((@Z . 3)))- T


So I can see that it is correctly solving for @Z this way. But it doesn't take 
that binding (@Z = 3) back into the foo rule. 


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


pilog question

2011-06-29 Thread Doug Snead
I have a question about how or/2 works in pilog.  Here's my test of or/2:

~/lisp/miniPicoLisp
$ ./pil 
: (be a (3))
- a
: (be b (3))
- b
: (? (a 3))
- T
: (be foo (@N) (or (a @N) (b @N)))
- foo
: (? foo a b or (foo 3))
1 (foo 3)
1 (or (a 3) (b 3))
- NIL
: 

Shouldn't that be T ?   

It seems to not to try to prove either (a 3) or (b 3).  Am I using or/2 
incorrectly in pilog? 


Here's that in swi-prolog for comparison:

~/prolog
# cat t.pl

a(3).

b(3).

foo(N) :- a(N) ; b(N).



 ~/prolog
# swipl -f t.pl 
% /root/prolog/t.pl compiled 0.00 sec, 2,804 bytes
Welcome to SWI-Prolog (Multi-threaded, 32 bits, Version 5.10.4)
Copyright (c) 1990-2011 University of Amsterdam, VU Amsterdam
SWI-Prolog comes with ABSOLUTELY NO WARRANTY. This is free software,
and you are welcome to redistribute it under certain conditions.
Please visit http://www.swi-prolog.org for details.

For help, use ?- help(Topic). or ?- apropos(Word).

?- a(3).
true.

?- foo(3).
true .

?- 



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


and/2 another pilog question

2011-06-29 Thread Doug Snead
More pilog adventures!  

Alex, would it be possible to give pilog an and/2 rule similar to the or/2 rule 
that pilog has now?  Sometimes refactoring pilog around the lack of an and/2 is 
a pain.  Here's an example, where a rule has a kind of a logical expression 
(with prolog backup): 


holds(A,S) :- restoreSitArg(A,S,F), F ;
   \+ restoreSitArg(A,S,F), isAtom(A), A.

I'd like to do something like:

(be holds (@A @S) (or 
(and 
  (restoreSitArg @A @S @F) 
  (@ solve (list (- @F
(and
 (not (restoreSitArg @A @S @F))
 (isAtom @A) 
 (@ solve (list (- @A))) ) ) ) 

Or's ok - but no and. (In pilog.)  I think it is fully (?) backtracking over 
that expression in prolog too.  But using a LISP and clause in a rule, like 
this:

 (@ and (solve ...) (solve ...)) 

Won't do backtracking over the legs of that (lisp) and.  

My solution so far is to make the parts of the conjunction be separate rules to 
get the desired backtracking:

(be holds (@A @S) (or
   ((holdsRestoreSitArg @A @S @F)
(holdsNotRestoreSitArg @A @S @F

(be holdsRestoreSitArg (@A @S @F)
(restoreSitArg @A @S @F)
(@ solve (list (- @F))) )

(be holdsNotRestoreSitArg (@A @S @F)
(not (restoreSitArg @A @S @F))
(isAtom @A)
(@ solve (list (- @A))) )

(The (@ solve (list (- @x))) -type clause here is trying to treat a naked 
variable as a rule clause - a workaround because you can't have a pilog 
variable in place of a rule clause - or at least it doesn't get instantiated 
like prolog if you try, rather.  But this is a separate issue from the and/2 
request.) 

Cheers,

Doug

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


Re: and/2 another pilog question

2011-06-29 Thread Doug Snead

Ha! The and is implicit ... I should seen that - the or/2 example there was a 
clue.  

Thanks for the assistance!!  I feel close to getting golog (and elevator 
example) working. 

Cheers,

Doug




--- On Wed, 6/29/11, Alexander Burger a...@software-lab.de wrote:

 From: Alexander Burger a...@software-lab.de
 Subject: Re: and/2 another pilog question
 To: picolisp@software-lab.de
 Date: Wednesday, June 29, 2011, 9:12 PM
 Hi Henrik,
 
  What is select ( http://software-lab.de/doc/refS.html#select/3 ) using
  internally for the filter part?
  
  Seems to me the filter part is a kind of implicit
 and.
 
 Right.
 
 As I wrote in the previous mails, all clauses in a Prolog
 rule (not only
 in 'select/3') are combined by an implict AND.
 
 Cheers,
 - Alex
 -- 
 UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe
 
-- 
UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe


Re: golog in minipicolisp

2011-06-26 Thread Doug Snead
--- On Sun, 6/26/11, Doug Snead semaphore_2...@yahoo.com wrote:
 (be isAtom (@A) (not (equal @A (Neg @W))) 
      (or (equal @A (And @W1 @W2)))
         (or (equal @A (If @W1 @W2)))
      (or (equal @A
 (Is @W1 @W2)))
     (or (equal @A (Or @W1 @W2)))
     (or (equal @A (some @X @W)))
     (or (equal @A (all @X @W

I mean:

(be isAtom (@A) (not (or (equal @A (Neg @W)) 
  (equal @A (And @W1 @W2))
  (equal @A (If @W1 @W2))
  (equal @A (Is @W1 @W2))
  (equal @A (Or @W1 @W2))
  (equal @A (some @X @W))
  (equal @A (all @X @W)

:-)

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


Re: tracing pilog

2011-06-26 Thread Doug Snead

Thanks Alex!The more I look at it, the more I like pilog for golog because 
golog uses prolog-ish backtracking so heavily.  When I look at this attempt to 
make a lua golog for example 
http://drops.dagstuhl.de/opus/volltexte/2010/2631/pdf/10081.Ferrein.2631.pdf , 
I think a picolisp/pilog -based golog might be a better approach than using lua 
for this, at least.  (And by translating the swi prolog golog into pilog, I 
seem to be able to understand golog programs better, at least.)  

Cheers,

Doug




--- On Sun, 6/26/11, Alexander Burger a...@software-lab.de wrote:

 From: Alexander Burger a...@software-lab.de
 Subject: Re: tracing pilog
 To: picolisp@software-lab.de
 Date: Sunday, June 26, 2011, 12:31 AM
 Hi Doug,
 
  What's the best way to trace pilog?
 
 Pilog clauses can indeed be traced.
 
 Unfortunately, I don't find a good description at the
 moment. The
 reference of '?' (and of 'prove' which is the internal
 machinery of the
 query front end '?') just briefly mentions it:
 
    http://software-lab.de/doc/ref_.html#?
    http://software-lab.de/doc/refP.html#prove
 
 It works by simply passing the names of the clauses you
 want to trace
 right after the '?' (i.e. the ['sym' ..] arguments).
 
 
 A simple example, using the 'append' clause:
 
 Without tracing
 
    : (? (append (a b c) @X (a b c d e f)))
     @X=(d e f)
    - NIL
 
 
 With tracing
 
    : (? append (append (a b c) @X (a b c d e
 f)))
    2 (append (a b c) @Y (a b c d e f))
    2 (append (b c) @Y (b c d e f))
    2 (append (c) @Y (c d e f))
    1 (append NIL (d e f) (d e f))
     @X=(d e f)
 
 The trace output lists all clauses that _matched_, and
 always starts
 with a number indicating _which_ of the clauses in the
 definition
 matched.
 
 The definition of 'append' is
 
    : (rules 'append)
    1 (be append (NIL @X @X))
    2 (be append ((@A . @X) @Y (@A . @Z))
 (append @X @Y @Z))
    - append
 
 
 The symbolic arguments to '?' can of course also specify
 clauses
 somewhere deeply nested in the Pilog definitions, not just
 those passed
 to '?' on the top level.
 
 Cheers,
 - Alex
 -- 
 UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe

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


Re: tracing pilog

2011-06-26 Thread Doug Snead

This is exactly what I was looking for, thanks!

--- On Sun, 6/26/11, Alexander Burger a...@software-lab.de wrote:
 It works by simply passing the names of the clauses you
 want to trace right after the '?' (i.e the ['sym' ..] arguments).
 ... With tracing
    : (? append (append (a b c) @X (a b c d e f)))


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


Re: embedding minipicolisp

2011-06-22 Thread Doug Snead
Hi Alexander,

Ha!  That last code snippet got me to where I needed to get :-) THANKS!!

(Now when I close my eyes I see pilog - what does that mean?) 

Cheers,

Doug






--- On Wed, 6/22/11, Alexander Burger a...@software-lab.de wrote:

 From: Alexander Burger a...@software-lab.de
 Subject: Re: embedding minipicolisp
 To: picolisp@software-lab.de
 Date: Wednesday, June 22, 2011, 12:28 AM
 Hi Doug,
 
  I can then doPrint() on what doRead() returns -
 although I don't see
  the customary parentheses around the list I hand that
 to doEval().
 
 Calling the high-level Lisp function 'doEval' is not a good
 idea,
 because it first evaluates its arguments, which is not what
 is needed
 here.
 
 The same is the case for 'doRead', but it doesn't do much
 harm if you
 just pass it NIL (i.e. no arguments). And also for
 'doPrint': If you
 pass it something other than a number, if will print not
 that item but
 its value. Better just call 'print()' for debugging.
 
 So instead of calling 'doEval', you could do
 
    any res;
    cell c1;
 
    Push(c1, doRead(Nil));
    x = EVAL(data(c1));
    drop(c1);
    return x;
 
 
  doEval() returns a value (an any pointer, which when
 cast to a long is 6 which seems odd). 
 
 '6' is a valid 'any', the number '1':
 
          num   
   xx10
           2   
    0110
 
 Cheers,
 - Alex
 -- 
 UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe

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


Re: embedding minipicolisp

2011-06-20 Thread Doug Snead
Ok, here's my first attempt at using minipicolisp as a library. (Leaving aside 
the issue of get/put for now.   Basically replacing main() with:

#if !LIBRARY
/*** Main ***/
int main(int ac, char *av[]) {
   char *p;

   . . .


#else
// we're building as a library

void miniPicoLisp_init( const char * home_dir )
{
   heapAlloc();
   initSymbols();
   
   if (home_dir) {
  int l = strlen(home_dir) + 1;
  Home = malloc( l );
  memcpy(Home, home_dir, l );
  Home[ l ] = '\0';
   }

   Reloc = Nil;
   InFile = stdin,  Env.get = getStdin;
   OutFile = stdout,  Env.put = putStdout;

   // ??
   ApplyArgs = cons(cons(consSym(Nil,0), Nil), Nil);
   ApplyBody = cons(Nil,Nil);
}

any miniPicoLisp_dostring( char *str )
{
   return load(NULL, 0, mkStr(str));
}

#endif


And then testing it with this: 

#include pico.h
extern void miniPicoLisp_init( const char * home_dir );
extern any miniPicoLisp_dostring( char *str );
#define MAX_STR 1024

int main(int ac, char *av[]) {
   char buf[MAX_STR];

   miniPicoLisp_init( NULL );

   while (fgets(buf, MAX_STR, stdin) != NULL) { // read
any v = miniPicoLisp_dostring( buf );   // eval
doPrint( v );   // print
   }

   return 0;
}




Doug





--- On Sat, 6/18/11, Alexander Burger a...@software-lab.de wrote:

 From: Alexander Burger a...@software-lab.de
 Subject: Re: embedding minipicolisp
 To: picolisp@software-lab.de
 Date: Saturday, June 18, 2011, 11:21 PM
 Hi Doug,
 
  I'd like to embed minipicolisp in C applications I'd
 like to be able
  to create a minipicolisp environment, and then pass
 strings to it
  (commands) for execution. It would also be great to be
 able get back the
  results in a string.
 
 The mechanism in PicoLisp to execute a string is 'load'. If
 an argument
 to 'load' starts with a hyphen, the rest is interpreted as
 an expression
 (without the surrounding parentheses). This mechanism is
 normally used
 to run expressions from the command line.
 
 The lower level functions for that are 'str', both for
 converting a
 transient symbol to a list (without the surrounding
 parentheses) and to
 do the reverse, and EVAL() (which is actually not a
 function but a
 macro).
 
 Unfortunately, there is no way currently to convert a C
 string directly
 to an executable Lisp expression (without the intermediate
 transient
 symbol).
 
 
  In lua, you'd do something like,
   L = lua_open();
 
 Here you'd need a function that initialized the PicoLisp
 VM, as is done
 by main(), i.e. calls heapAlloc(), initSymbol() etc.
 
 
   luaL_dostring(L, str_in );
   str_out = l_results_to_string(L);
 
 You need a C function similar to 'loadAll()'. It would call
 'mkStr()' on
 the C string to create the transient symbol, then load() to
 run the
 expression.
 
 Better would be to cook something more specialized, similar
 to parse(),
 to avoid the intermediate transient symbol step.
 
 
 To pack the result into a C string, you need a mechanism
 similar to
 doStr().
 
 You define a function which writes a single byte into a C
 character
 array,
 
    void putCharC(int c) {
       *CBytePtr++ = c;
    }
 
 and store a pointer to that function into 'Env.put':
 
    void (*putSave)(int);
 
    putSave = Env.put;
    Env.put = putCharC;
    print(result);
    Env.put = putSave;
 
 
 Hope this helps.
 
 Cheers,
 - Alex
 -- 
 UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe

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


golog in minipicolisp ?

2011-06-17 Thread Doug Snead
Alexander (or anyone!),

I'm looking at something called golog 
http://www.cs.toronto.edu/cogrobo/main/systems/index.html   it is a A 
high-level agent programming language... based on Prolog (usually Eclipse, SWI, 
LPA, and Quintus.)

An interpreter in SWI Prolog can be found here.
http://www.cs.toronto.edu/cogrobo/Systems/golog_swi.pl
An interpreter in ECLIPSE Prolog can be found here.
http://www.cs.toronto.edu/cogrobo/Systems/gologinterpreter.pl 

The .pl prolog gologs above look (deceptively) simple. I don't know pilog well 
enough to be able to tell if there is something about gologinterpreter.pl (or 
golog_swi.pl, same thing) that I will NOT be able to do in minipicolisp's 
pilog.   

I'd like to try to converting gologinterpreter.pl into pilog (especially for 
minipicolisp). I am hoping that this will be both possible and straightforward. 
  

Any thoughts? 

Cheers,

Doug

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


Re: script for generating tags for picolisp

2010-08-17 Thread Doug Snead
Here's one shell script I used to use for that (I called it lisptags) ... 
hopefully it still works :-)

#!/bin/sh 
# make a tags file for pico lisp source files.
# use:
#   lisptags foo.l bar.l baz.l ... bof.l
# generate the file 'tags'
# [based on lisptags csh script by John Foderaro, c.1982]
awk '
/^[ \t]*\([bd][em][ \t]/ {
n=$2;
gsub(/^\(/,,n);
gsub(/\)$/,,n);
print n \t FILENAME \t?^ $0 $?;
}
/^[ \t]*\(class[ \t]/ {
n=$2;
gsub(/^\(/,,n);
gsub(/\)$/,,n);
print n \t FILENAME \t?^ $0 $?;
if (n ~ /^\+/) {
  gsub(/^\+/,,n);
  print n \t FILENAME \t?^ $0 $?;
}
}
' $* | sort  tags

= = =



--- On Tue, 8/17/10, Edwin Eyan Moragas e...@yndy.org wrote:

 From: Edwin Eyan Moragas e...@yndy.org
 Subject: script for generating tags for picolisp
 To: picolisp@software-lab.de
 Date: Tuesday, August 17, 2010, 12:05 AM
 Hi all,
 
 anybody who made an attempt to create such kind of script?
 or maybe a
 resource somewhere in the interwebs for this?
 
 cheers,
 
 /e
 -- 
 UNSUBSCRIBE: mailto:picol...@software-lab.de?subject=unsubscribe
 


  
-- 
UNSUBSCRIBE: mailto:picol...@software-lab.de?subject=unsubscribe


Re: Concurrency

2009-10-09 Thread Doug Snead
--- On Fri, 10/9/09, Tomas Hlavaty t...@logand.com wrote:=0A How many pro=
cesses do you need?=A0 I can fork about 500=0A from one parent=0A (limite=
d by my OS set up).=A0 And because picolisp is,=0A well, pico, it=0A do=
esn't take much memory (picolisp uses less that 2MB).=0A=0AAnd if picolisp =
is built as a shared object/dll, then additional picolisp processes may con=
sume even less memory. =0A=0ADoug=0A=0A=0A=0A  
-- 
UNSUBSCRIBE: mailto:picol...@software-lab.de?subject=unsubscribe