Re: Announce: ErsatzLisp (Java PicoLisp)

2010-11-17 Thread Jon Kleiser

Hi Alex,

In your description below I can see no way to
- set a value of a public field of an object, or
- set a value of a public field of a class

Is this something that you may add later?

/Jon


On 04-11-10 19:53 , Alexander Burger wrote:

Hi all,

here is an update.

Besides the basic I/O system and half-baked network functions (until now
only 'connect', 'accept' and a partial 'port'), we have now a set of
functions interfacing to the Java Reflection API.

I'd like to describe them shortly, and hear your opinions. You can try
it if you like if you download the current testing release.


The central function is called 'java'. It comes in three forms:

(java 'cls 'T 'any ..) -  obj
This is a constructor call, returning a Java object. 'cls' is the
name of a Java class, like java.lang.StringBuilder.

(java 'cls 'msg 'any ..) -  obj
This calls a static method 'msg' for a class 'cls'.

(java 'obj 'msg 'any ..) -  obj
This calls a dynamic method 'msg' for an object 'obj'

Example:

: (setq Sb (java java.lang.StringBuilder T abc))
-  $StringBuilder
: (java Sb append (char: 44))
-  $StringBuilder
: (java Sb append 123)
-  $StringBuilder
: (java Sb toString)
-  $String
: (data @)
-  abc,123

The function 'data' in the last line converts back from Java objects to
PicoLisp data.


Then we have 'public', it supports two forms:

(public 'obj 'any) -  obj
   Returns the value of a public field 'any' in object 'obj'

(public 'cls 'any) -  obj
   Returns the value of a public field 'any' in class 'cls'

Example:

: (public java.lang.System err)
-  $PrintStream
: (java @ println Hello world)
Hello world
-  NIL


Finally, we have a set of type conversion functions, to produce Java
objects from Lisp data:

(byte: 'num|sym) -  obj
(char: 'num|sym) -  obj
(int: 'num) -  obj
(long: 'num) -  obj
(big: 'num) -  obj

We saw the usage of 'char:' in the StringBuilder example above.


So the 'any' arguments to the 'java' function can either be
- 'T' or 'NIL', then the type is boolean
- A number, then it must fit in 32 bits and will be passed as 'int'
- A normal symbol, then it will be passed as 'String'
- A Java object, as returned by 'java' or one of the 'xxx:'
  conversion functions.
- A list, then all elements must be of the same type and will be
  passed as 'Array'

I hope this reflection interface is a good compromise between simplicity
and usefulness.

Cheers,
- Alex


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


Re: Announce: ErsatzLisp (Java PicoLisp)

2010-11-17 Thread Alexander Burger
Hi Jon,

 In your description below I can see no way to
 - set a value of a public field of an object, or
 - set a value of a public field of a class

You are right.

 Is this something that you may add later?

Hmm, I would actually prefer not to add it. For one thing, the political
correct way in Java is using set() methods for that.

But more important is that this would require quite a mess of code,
analog to what is there for getting the values of public fields. If you
look at lines 99 through 142 of ersatz/fun.src (actual version), you
see a lot of tedious type ('instanceof') checks. And they don't even
cover all possible cases! The same would be required for the opposite
direction. Or does anybody know a better way?

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


Re: Announce: ErsatzLisp (Java PicoLisp)

2010-11-17 Thread Alexander Burger
Hi all,

now I simplified the file structure of Ersatz PicoLisp a little, to make
it better usable as a stand-alone system.


The start-up script 'erl' (as it was described in ersatz/README and
INSTALL) doesn't exist any longer, and it now can (or should) be
started directly as

   $ ersatz/picolisp
   :


A minimal package is also available, indepentent from the standard
Picolisp release, under

   http://software-lab.de/ersatz.tgz

It contains the README, but no sources or documentation. There are only
three runtime files: The picolisp start-up script, the JAR file and a
combined lib.l.


Anyone care to try it under another OS, e.g. Windoofs?

This would probably require making a batch file ersatz/picolisp.bat,
along the line of ersatz/picolisp. The PID is probably not available
there, so some arbitrary number might be used.

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


Re: Announce: ErsatzLisp (Java PicoLisp)

2010-11-17 Thread Alexander Burger
On Wed, Nov 17, 2010 at 06:54:52PM +0100, Alexander Burger wrote:
 Anyone care to try it under another OS, e.g. Windoofs?
 
 This would probably require making a batch file ersatz/picolisp.bat,
 along the line of ersatz/picolisp. The PID is probably not available
 there, so some arbitrary number might be used.

Josef Bartl just tried it for me. The line

   java -DPID=42 -jar picolisp.jar -on *Dbg lib.l

works just fine under Windows.


To make a proper batch file, I think something like

   java -DPID=42 -jar picolisp.jar -on *Dbg lib.l %1 %2 %3 %4 %5 %6

should be used, right? Or is there some better way, corresponding to the
$@ argument expansion in bash?

The dummy PID (here 42) should better be replaced by some number unique
at each invocation, but I have no idea.

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


Re: Announce: ErsatzLisp (Java PicoLisp)

2010-11-17 Thread Alexander Burger
On Wed, Nov 17, 2010 at 07:58:20PM +0100, Alexander Burger wrote:
java -DPID=42 -jar picolisp.jar -on *Dbg lib.l

Further simplified now: The (on *Dbg) moved to lib.l.

Thus

   java -DPID=42 -jar picolisp.jar lib.l

is enough now.

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


Re: Announce: ErsatzLisp (Java PicoLisp)

2010-11-17 Thread Mansur Mamkin

 I've just tried it on my Windows 7 (64bit) with JRE 1.6.0_22 (32bit)
It works fine, the only thing is java is not in my PATH,
so I needed to write full path to java.exe :)
C:\Program Files (x86)\Java\jre6\bin\java.exe -DPID=42 -jar 
picolisp.jar lib.l



On Wed, Nov 17, 2010 at 07:58:20PM +0100, Alexander Burger wrote:

java -DPID=42 -jar picolisp.jar -on *Dbg lib.l

Further simplified now: The (on *Dbg) moved to lib.l.

Thus

java -DPID=42 -jar picolisp.jar lib.l

is enough now.

Cheers,
- Alex


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