Re: Announce: ErsatzLisp (Java PicoLisp)

2011-12-09 Thread Alexander Burger
On Fri, Dec 09, 2011 at 07:56:52AM +0100, Alexander Burger wrote:
> > nice to have a link to this kind of Ersatz documentation from the
> > wiki.
> 
> Good idea. I can prepare a first version.

Here is my first try:

   http://picolisp.com/5000/!wiki?ErsatzReflection

It can also be found via the "Documentation" menu. Please feel free to
improve it!

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


Re: Announce: ErsatzLisp (Java PicoLisp)

2011-12-08 Thread Alexander Burger
Hi Jon,

> Is the "update" below what's available on Ersatz documentation? I
> couldn't find this info anywhere else. I think it would have been

Yes, I think that's all :(

> nice to have a link to this kind of Ersatz documentation from the
> wiki.

Good idea. I can prepare a first version. You might then add your
experiences, if you like.

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


Re: Announce: ErsatzLisp (Java PicoLisp)

2011-12-08 Thread Jon Kleiser

Hi Alex,

Is the "update" below what's available on Ersatz documentation? I 
couldn't find this info anywhere else. I think it would have been nice 
to have a link to this kind of Ersatz documentation from the wiki.


/Jon

On 11/4/10 7:53 PM, 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:picolisp@software-lab.de?subject=Unsubscribe


Re: Announce: ErsatzLisp (Java PicoLisp)

2010-12-03 Thread Alexander Burger
Hi Tomas,

> But my original point was, can you use Class instances directly in
> ErsatzLisp?  E.g. something like

No, I didn't want to go that far. I just pass the class names.

After all, the dynamic lookup of the class during reflection is
neglectible compared to the rest of the overhead. You just get more
adminstrative overhead of you keep the classes around when you just need
to handle the names.

But it could be easily added, of course.

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


Re: Announce: ErsatzLisp (Java PicoLisp)

2010-12-03 Thread Tomas Hlavaty
Hi Alex,

>>(java "javax.swing.JFrame" T "Animation")
>> 
>> or
>> 
>>(interface "java.awt.event.MouseListener" ...
>> 
>> In wl, there is no need for this because I can do this at read-time,
>> like the above example:
>> 
>>`(jclass "java.lang.System")
>> 
>> Also, I can do it only once, see the 'import' function and how it is
>> used in swing.l and swt.l.
>
> This is also the same in ErsatzLisp. 'interface' returns a Proxy object
> (as 'java' returns an arbitrary Java object) which can be kept in a
> variable etc.

Ok.

But my original point was, can you use Class instances directly in
ErsatzLisp?  E.g. something like

   (interface MouseListener ...

   where (val 'MouseListener) instanceof java.lang.Class for
   "java.awt.event.MouseListener" (in other words
   java.awt.event.MouseListener.class)

Cheers,

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


Re: Announce: ErsatzLisp (Java PicoLisp)

2010-12-02 Thread Alexander Burger
Hi Tomas,

> > I cannot see, though, whether you also handle a mapping of Lisp lists
> > from/to Java arrays, which doubles the code in the case of ErsatzLisp.
> 
> I think there are two functions: 'jv2l' and 'jvector'.

I see. I cannot find out how it works, however. I tried:

   : (setq S (jnew (jclass 'java.lang.String) "abcde"))
   -> "abcde"

   :  (S 'getBytes)
   -> [...@1027b4d]

How do I retrieve the actual bytes then? I tried 'jv2l' and 'jvector'
but get an error "No Cons.obj".


For example, in ErsatzLisp I do this as

   : (setq S (java "java.lang.String" T "abcde"))
   -> $String

   : (java (java S "getBytes"))
   -> (97 98 99 100 101)

You also do the opposite (construct a string out of single bytes)

   : (java "java.lang.String" T (mapcar byte: (100 101 102)))
   -> $String

   : (java @)
   -> "def"

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


Re: Announce: ErsatzLisp (Java PicoLisp)

2010-12-02 Thread Alexander Burger
Hi Tomas,

> > BTW, how can I access existing objects (like "java.lang.System.err")
> > in wl? I can only find 'jnew', which creates new objects.
> 
> Like this:
> 
>(jfield `(jclass "java.lang.System") 'err)

I see. Thanks!


> Basically, because Java objects are
> first class citizens in the wl interpreter, I need very little special

The same is the case in ErsatzLisp.


> > possibly want to use ErsatzLisp in real applications (e.g. Android
> > apps) if I find the time.
> 
> Well, to be pedantic in regards to speed optimisations, whenever you do
> something class specific you perform a class lookup based on the class

Right. But such calls happen infrequent compared to the execution of the
language itself. To make it practically usable, I want the raw Lisp code
to run as fast as possible. There I'm not satisfied even with
ErsatzLisp, and wl is still another factor slower.


>(java "javax.swing.JFrame" T "Animation")
> 
> or
> 
>(interface "java.awt.event.MouseListener" ...
> 
> In wl, there is no need for this because I can do this at read-time,
> like the above example:
> 
>`(jclass "java.lang.System")
> 
> Also, I can do it only once, see the 'import' function and how it is
> used in swing.l and swt.l.

This is also the same in ErsatzLisp. 'interface' returns a Proxy object
(as 'java' returns an arbitrary Java object) which can be kept in a
variable etc.

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


Re: Announce: ErsatzLisp (Java PicoLisp)

2010-12-02 Thread Tomas Hlavaty
Hi Alex,

> However, I see that in the function 'jarg' you are doing the same (check
> for all kinds of types).

yes, it happens in Java methods: 'jarg' and 'isInstance'.  These are
necessary to automatically handle primitive types and I think it is
impossible to reduce it further while preserving the functionality.

> I cannot see, though, whether you also handle a mapping of Lisp lists
> from/to Java arrays, which doubles the code in the case of ErsatzLisp.

I think there are two functions: 'jv2l' and 'jvector'.

Cheers,

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


Re: Announce: ErsatzLisp (Java PicoLisp)

2010-12-02 Thread Tomas Hlavaty
Hi Alex,

> BTW, how can I access existing objects (like "java.lang.System.err")
> in wl? I can only find 'jnew', which creates new objects.

Like this:

   (jfield `(jclass "java.lang.System") 'err)

There are some useful functions defined in java.wl file, implemented in
picolisp instead of in native java.  Basically, because Java objects are
first class citizens in the wl interpreter, I need very little special
purpose native functions and the rest can be build on top of that in
picolisp.

> It is just that I've put much more stress on execution speed, as I
> possibly want to use ErsatzLisp in real applications (e.g. Android
> apps) if I find the time.

Well, to be pedantic in regards to speed optimisations, whenever you do
something class specific you perform a class lookup based on the class
name passed in: e.g.

   (java "javax.swing.JFrame" T "Animation")

or

   (interface "java.awt.event.MouseListener" ...

In wl, there is no need for this because I can do this at read-time,
like the above example:

   `(jclass "java.lang.System")

Also, I can do it only once, see the 'import' function and how it is
used in swing.l and swt.l.

Cheers,

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


Re: Announce: ErsatzLisp (Java PicoLisp)

2010-12-01 Thread Alexander Burger
Hi Tomas,

> >> > 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?
> >
> > I say that the above code is a mess because it still has to check for
> > each possible type and take the appropriate action. As you can see, it
> > covers bytes, characters, integers, longs, doubles, bigIntegers,
> > strings, objects, byte arrays, char arrays, int arrays, long arrays and
> > double arrays. Other types, like short integers, or string arrays etc.
> > are not covered (and I hope they are not such important). BTW, I just
> > notice that booleans (and boolean arrays) are also missig; booleans
> > might be needed.
> >
> > I cannot see a generic way to do that.
> 
> I haven't looked at your code, but you might have a look at wl
> interpreter we discussed some time ago.  The java ffi was quite complete

Yes, thank you!

However, I see that in the function 'jarg' you are doing the same (check
for all kinds of types).

I cannot see, though, whether you also handle a mapping of Lisp lists
from/to Java arrays, which doubles the code in the case of ErsatzLisp.


> and quite generic and more importantly, completely automatic, althought
> not the fastest due to relying on reflection completely.  There is code
> for finding the right method and constructor with matching prototypes

In that sense, the same happens in ErsatzLisp.

It is just that I've put much more stress on execution speed, as I
possibly want to use ErsatzLisp in real applications (e.g. Android apps)
if I find the time.


BTW, how can I access existing objects (like "java.lang.System.err") in
wl? I can only find 'jnew', which creates new objects.

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


Re: Announce: ErsatzLisp (Java PicoLisp)

2010-11-30 Thread Tomas Hlavaty
Hi Alex,

>> > 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?
>
> I say that the above code is a mess because it still has to check for
> each possible type and take the appropriate action. As you can see, it
> covers bytes, characters, integers, longs, doubles, bigIntegers,
> strings, objects, byte arrays, char arrays, int arrays, long arrays and
> double arrays. Other types, like short integers, or string arrays etc.
> are not covered (and I hope they are not such important). BTW, I just
> notice that booleans (and boolean arrays) are also missig; booleans
> might be needed.
>
> I cannot see a generic way to do that.

I haven't looked at your code, but you might have a look at wl
interpreter we discussed some time ago.  The java ffi was quite complete
and quite generic and more importantly, completely automatic, althought
not the fastest due to relying on reflection completely.  There is code
for finding the right method and constructor with matching prototypes
and something similar for fields to get and set them IIRC.

Cheers,

Tomas

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


Re: Announce: ErsatzLisp (Java PicoLisp)

2010-11-18 Thread Alexander Burger
On Thu, Nov 18, 2010 at 04:11:24PM +0100, Jakob Eriksson wrote:
> > 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?
> 
> Is this related to introspection?
> http://stackoverflow.com/questions/206/java-introspection-and-reflection

Yes, I'm using the reflection API to find out classes and fields.

I say that the above code is a mess because it still has to check for
each possible type and take the appropriate action. As you can see, it
covers bytes, characters, integers, longs, doubles, bigIntegers,
strings, objects, byte arrays, char arrays, int arrays, long arrays and
double arrays. Other types, like short integers, or string arrays etc.
are not covered (and I hope they are not such important). BTW, I just
notice that booleans (and boolean arrays) are also missig; booleans
might be needed.

I cannot see a generic way to do that.

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


Re: Announce: ErsatzLisp (Java PicoLisp)

2010-11-18 Thread Jakob Eriksson
On 11/17/2010 06:13 PM, Alexander Burger wrote:
> 
> 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?

Is this related to introspection?
http://stackoverflow.com/questions/206/java-introspection-and-reflection

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


Re: Announce: ErsatzLisp (Java PicoLisp)

2010-11-18 Thread Jon Kleiser

Hi Alex,

I'll try to find an example to test it. ;-)

/Jon

On 18-11-10 09:50 , Alexander Burger wrote:

Hi Jon,


(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'

I would suggest that this 'public' function should allow multiple
any's, so that you can do a chained get-value. ;-)

This is a good idea, as it is along the line of the 'get' family of
functions.

I added this feature, and released a new version. Do you know of an
example to test it?

Cheers,
- Alex


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


Re: Announce: ErsatzLisp (Java PicoLisp)

2010-11-18 Thread Alexander Burger
Hi Jon,

> >(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'
> I would suggest that this 'public' function should allow multiple
> any's, so that you can do a chained get-value. ;-)

This is a good idea, as it is along the line of the 'get' family of
functions.

I added this feature, and released a new version. Do you know of an
example to test it?

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


Re: Announce: ErsatzLisp (Java PicoLisp)

2010-11-18 Thread Jon Kleiser

Hi again,

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.

..

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'
I would suggest that this 'public' function should allow multiple any's, 
so that you can do a chained get-value. ;-)


/Jon
--
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


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 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
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
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 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-15 Thread Alexander Burger
Hi Jon,

> machine. When I tried "(data @)" in your Example below, I got "data
> -- Undefined". Did you change something lately? Will this 'java'

Oops, yes. 'data' is now also covered by 'java':

   (java 'obj ['cnt]) -> any
  This correspends to the old 'data' function.

   (java 'obj 'msg 'any ..) -> obj
   (java 'cls 'msg 'any ..) -> obj
   (java 'cls 'T 'any ..) -> obj


> function be documented somewhere? ;-)

Yes, should be in the future. Let's first clear the smoke and see how
useful it turns out ;-)


> Do you now if it would be possible, or easy, to build a simple HTTP
> server in ErsatzLisp? Or, maybe a better solution would be to

This should also be possible. The only problem I see at the moment is
the missing 'fork', so we need a non-forking server. We had some
discussion about that already here in this list, iirc.

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


Re: Announce: ErsatzLisp (Java PicoLisp)

2010-11-15 Thread Jon Kleiser

Hi Alex,

I've now had the chance to test your latest ErsatzLisp, on a Linux 
machine. When I tried "(data @)" in your Example below, I got "data -- 
Undefined". Did you change something lately? Will this 'java' function 
be documented somewhere? ;-)


Do you now if it would be possible, or easy, to build a simple HTTP 
server in ErsatzLisp? Or, maybe a better solution would be to combine 
ErsatzLisp with a standard HTTP server. Maybe a combination of 
ErsatzLisp and the Play framework (www.playframework.org) could be 
something?


/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: Done! -- Was: Announce: ErsatzLisp (Java PicoLisp)

2010-11-13 Thread Alexander Burger
Hi Jon,

>  I look forward to try this ErsatzLisp, but I have no Java 1.6 available 
>  yet. I tried to install it on Ubuntu, but I didn't succeed. I ended up 
>  with a broken package, and haven't managed to clean up the mess yet. ;-)

Oh - too bad! Sometimes everything goes wrong.


>  Maybe you could write a note on this ErsatzLisp on the Forum News 
>  section here: http://picolisp.com/5000/-2-B.html

Yes, good idea. That's what that page is for after all.


>  I'm also curious about "bootstrapping the 64-bit version". What's in 
>  it?

I wrote a little about that in http://software-lab.de/INSTALL and
http://software-lab.de/doc64/README. In a nutshell:

While Ersatz PicoLisp should work right of the box (perhaps an illusion
as we see in your case ;-), and Pil32 just needs a C compiler to build,
does Pil64 need a running PicoLisp system to build the "*.s" files from
the sources "src64/*.l".

Now the build process started by (cd src64; make picolisp) is clever
enough to fall back to "ersatz/picolisp" if there is no "bin/picolisp"
yet. That's all. This assumes, however, that a Java runtime system is
installed. If not, the pre-generated "*.s" files can be downloaded.

The rationale behind that is: These "*.s" files are relatively large,
and quite redundant as they can be easily built from the "src64/*.l"
files. Until now we have only "*.s" files for the 'x86-64' architecture
and 'linux' platform. But if there are more in the future, the release
size would explode.

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


Re: Done! -- Was: Announce: ErsatzLisp (Java PicoLisp)

2010-11-13 Thread Jon Kleiser
 On Fri, 12 Nov 2010 20:04:01 +0100, Alexander Burger 
  wrote:
> On Sat, Oct 30, 2010 at 07:07:01PM +0200, Alexander Burger wrote:
>> In the near future I will continue, trying to supply as many missing
>> parts as possible. The next will probably be the *Run/task 
>> mechanisms
>> (using java.nio.channels.Selector), remaining I/O functions, and
>> networking.
>
> Done! I do now consider Ersatz PicoLisp complete :)
>
> At least one of the primary purposes, bootstrapping the 64-bit 
> version,
> is achieved. As a consequence I removed the rather large 
> pre-generated
> "*.s" files from the distribution. They will now be automatically 
> build
> by 'make' if a Java runtime system is installed. If not, they are
> available for download ("http://software-lab.de/x86-64.linux.tgz";).
>
> Most things work surprisingly well, and better than I initially
> expected. "ersatz/README" tells a little more.
>
> Cheers,
> - Alex

 Hi Alex,

 I look forward to try this ErsatzLisp, but I have no Java 1.6 available 
 yet. I tried to install it on Ubuntu, but I didn't succeed. I ended up 
 with a broken package, and haven't managed to clean up the mess yet. ;-)
 Maybe you could write a note on this ErsatzLisp on the Forum News 
 section here: http://picolisp.com/5000/-2-B.html
 I'm also curious about "bootstrapping the 64-bit version". What's in 
 it?

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


Re: Done! -- Was: Announce: ErsatzLisp (Java PicoLisp)

2010-11-12 Thread Alexander Burger
Hi Jakob,

> Totally cool!   I consider the main benefit that we have a PicoLisp in
> Java, which we need to be hype compliant. :)

Very true ;-)
-- 
UNSUBSCRIBE: mailto:picol...@software-lab.de?subject=unsubscribe


Re: Done! -- Was: Announce: ErsatzLisp (Java PicoLisp)

2010-11-12 Thread Jakob Eriksson



On 11/12/2010 08:04 PM, Alexander Burger wrote:
[...]

> Done! I do now consider Ersatz PicoLisp complete :)


Totally cool!   I consider the main benefit that we have a PicoLisp in
Java, which we need to be hype compliant. :)

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


Done! -- Was: Announce: ErsatzLisp (Java PicoLisp)

2010-11-12 Thread Alexander Burger
On Sat, Oct 30, 2010 at 07:07:01PM +0200, Alexander Burger wrote:
> In the near future I will continue, trying to supply as many missing
> parts as possible. The next will probably be the *Run/task mechanisms
> (using java.nio.channels.Selector), remaining I/O functions, and
> networking.

Done! I do now consider Ersatz PicoLisp complete :)

At least one of the primary purposes, bootstrapping the 64-bit version,
is achieved. As a consequence I removed the rather large pre-generated
"*.s" files from the distribution. They will now be automatically build
by 'make' if a Java runtime system is installed. If not, they are
available for download ("http://software-lab.de/x86-64.linux.tgz";).

Most things work surprisingly well, and better than I initially
expected. "ersatz/README" tells a little more.

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


Re: Announce: ErsatzLisp (Java PicoLisp)

2010-11-05 Thread Alexander Burger
Hi Jon,

> In PicoLisp, it is legal to compare data items of arbitrary type.
> How do ersatz compare arbitrary Java classes and objects to other
> PicoLisp types? Are they less than T? Less than Numbers?

They are larger than numbers, and less than T, because they are normal
anonymous symbols (like you create with 'box' or 'new'). They just
happen to carry a Java object as an attachment, and when printed they
don't show something as $12345 like other anonymous symbols, but $Class.

Comparing them to each other follows the same mechanism as other
anonymous symbols, i.e. they use the hashCode(). The C and asm versions
of PicoLisp use the address for that.


An interesting feature is perhaps that you can give these symbols
another name (with 'name', the same way you can change the name of
anonymous and transient symbols in PicoLisp). Example:

   : (setq S (java "java.lang.String" T "Hello world"))
   -> $String

   : (data S)
   -> "Hello world"

   : (name S "Hello World Symbol")
   -> "Hello World Symbol"

   : S
   -> "Hello World Symbol"

   : (data S)
   -> "Hello world"

So the name is not relevant for the Java object attachment. If the
symbol has no name (is anonymous), then the class of the attachment is
printed. Otherwise, the normal name is printed, but the symbol doesn't
lose its "nature" as a Java object.

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


Re: Announce: ErsatzLisp (Java PicoLisp)

2010-11-05 Thread Jon Kleiser

On 11/5/10 10:56 AM, Alexander Burger wrote:

Hi Jon,


This looks very interesting. However, I have some problems building
ersatz on my Intel Mac:

..:picoLisp jkleiser$ (cd ersatz; ./mkJar)
PicoLisp.java:15: cannot find symbol
symbol  : class Console


I see. java.io.Console is avaliable only in Java 1.6 or higher. That's
why I wrote that in "ersatz/README".

Too bad. Is there no up-to-date JRE available for the Mac?

Cheers,
- Alex


Hi Alex,

I may have to upgrade the OS on this Mac to 10.6.something.

Another ersatz question:
In PicoLisp, it is legal to compare data items of arbitrary type. How do 
ersatz compare arbitrary Java classes and objects to other PicoLisp 
types? Are they less than T? Less than Numbers?


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


Re: Announce: ErsatzLisp (Java PicoLisp)

2010-11-05 Thread Jakob Eriksson
On 11/05/2010 10:56 AM, Alexander Burger wrote:

> 
> Too bad. Is there no up-to-date JRE available for the Mac?
Should be:

http://discussions.apple.com/thread.jspa?threadID=2315116&tstart=1

http://www.piranhamethod.com/2010/04/installing-jre-1-6-on-your-mac-os-x-leopard-10-5-8-or-later/

// Jakob

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


Re: Announce: ErsatzLisp (Java PicoLisp)

2010-11-05 Thread Alexander Burger
Hi Jon,

> This looks very interesting. However, I have some problems building
> ersatz on my Intel Mac:
> 
> ..:picoLisp jkleiser$ (cd ersatz; ./mkJar)
> PicoLisp.java:15: cannot find symbol
> symbol  : class Console

I see. java.io.Console is avaliable only in Java 1.6 or higher. That's
why I wrote that in "ersatz/README".

Too bad. Is there no up-to-date JRE available for the Mac?

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


Re: Announce: ErsatzLisp (Java PicoLisp)

2010-11-05 Thread Jon Kleiser

Hi Alex,

This looks very interesting. However, I have some problems building 
ersatz on my Intel Mac:


..:picoLisp jkleiser$ (cd ersatz; ./mkJar)
PicoLisp.java:15: cannot find symbol
symbol  : class Console
location: class PicoLisp
   final static Console Term = System.console();
^
PicoLisp.java:15: cannot find symbol
symbol  : method console()
location: class java.lang.System
   final static Console Term = System.console();
 ^
2 errors

/Jon

On 11/4/10 7:53 PM, 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-04 Thread Alexander Burger
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-10-31 Thread Alexander Burger
Hi Jakob,

> I don't think you need to include fork.

Yeah, it is a bit heavy. It would mean to start a new thread, and copy
all Lisp data. Not really difficult though.


> Database support should be
> possible, I guess, but I am not sure about locking.

Locking _might_ work with "java.nio.channels.FileLock", but I remember
bad experiences with that under Cygwin.

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


Re: Announce: ErsatzLisp (Java PicoLisp)

2010-10-31 Thread Jakob Eriksson
On Sat, Oct 30, 2010 at 07:07:01PM +0200, Alexander Burger wrote:
> Hi all,
> 
> the Java version of PicoLisp, which is part of the testing release since
> a few weeks, is now in a state where I dare to say that the language is
> usable (just the plain language).

Very cool!



> In the near future I will continue, trying to supply as many missing
> parts as possible. The next will probably be the *Run/task mechanisms
> (using java.nio.channels.Selector), remaining I/O functions, and
> networking. What seems definitely impossible in plain Java is raw
> console input ('key', line editing). About other parts like 'fork' and
> database support I'm not sure yet.

I don't think you need to include fork. Database support should be
possible, I guess, but I am not sure about locking.


// Jakob

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


Announce: ErsatzLisp (Java PicoLisp)

2010-10-30 Thread Alexander Burger
Hi all,

the Java version of PicoLisp, which is part of the testing release since
a few weeks, is now in a state where I dare to say that the language is
usable (just the plain language).

In the near future I will continue, trying to supply as many missing
parts as possible. The next will probably be the *Run/task mechanisms
(using java.nio.channels.Selector), remaining I/O functions, and
networking. What seems definitely impossible in plain Java is raw
console input ('key', line editing). About other parts like 'fork' and
database support I'm not sure yet.

It resides in the "ersatz/" directory. More infos in "ersatz/README".

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