Foil - a Foreign Object Interface for Lisp, is now available
Foil provides a protocol and code to interface between Lisp and
instances of runtimes such as the JVM and CLR, offering comprehensive,
safe, dynamic, efficient, and portable access to Java and CLI libraries
from Lisp, with an emphasis on working in Lisp.
Foil is open source, released under the Common Public License.
Find out more at:
http://foil.sourceforge.net
Regards,
Rich Hickey
From: Peter Seibel
Subject: Re: [Ann] Foil - a Foreign Object Interface for Lisp
Date:
Message-ID: <m3zmxt7f44.fsf@gigamonkeys.com>
"richhickey" <··········@gmail.com> writes:
> Foil - a Foreign Object Interface for Lisp, is now available
>
> Foil provides a protocol and code to interface between Lisp and
> instances of runtimes such as the JVM and CLR, offering comprehensive,
> safe, dynamic, efficient, and portable access to Java and CLI libraries
> from Lisp, with an emphasis on working in Lisp.
>
> Foil is open source, released under the Common Public License.
>
> Find out more at:
>
> http://foil.sourceforge.net
Is this The Library Formerly Known as JFLI?
-Peter
--
Peter Seibel ·····@gigamonkeys.com
Lisp is the red pill. -- John Fraser, comp.lang.lisp
Peter Seibel wrote:
> "richhickey" <··········@gmail.com> writes:
>
>
>>Foil - a Foreign Object Interface for Lisp, is now available
>>
>>Foil provides a protocol and code to interface between Lisp and
>>instances of runtimes such as the JVM and CLR, offering comprehensive,
>>safe, dynamic, efficient, and portable access to Java and CLI libraries
>>from Lisp, with an emphasis on working in Lisp.
>>
>>Foil is open source, released under the Common Public License.
>>
>>Find out more at:
>>
>>http://foil.sourceforge.net
>
>
> Is this The Library Formerly Known as JFLI?
>
> -Peter
>
It seems to use a similar protocol, but is completly out-of-process,
communication with the foreign run-time is done over sockets
From the website :
* jfli did not see wide porting, due to its use of LispWorks'
sophisticated FLI to access JNI, and the lack of corresponding
facilities in some other Lisps
* I found that I needed to access already-running instances of the
JVM, for instance servlet containers, as done in Lisplets, and felt I
could accomplish similar things with less effort with Foil + marshallers
* I wanted to access the CLR/CLI in a similar fashion to Java
* It allows for more flexibility in dealing with threading issues
Point (2) above seems like a big plus. Oh, and i suppose we can answer
the "where are lisp libraries" question with "Well, we have access to
more libraries than Java and C# combined!"
If i had either environment installed i'd be playing with this right
now, i just know one of our members is going to need something like this
at one point. wonder if it will work with Mono.
--
Drew Crampsie
drewc at tech dot coop
"Never mind the bollocks -- here's the sexp's tools."
-- Karl A. Krueger on comp.lang.lisp
> If i had either environment installed i'd be playing with this right
> now, i just know one of our members is going to need something like
this
> at one point. wonder if it will work with Mono.
>
>
> --
> Drew Crampsie
> drewc at tech dot coop
> "Never mind the bollocks -- here's the sexp's tools."
> -- Karl A. Krueger on comp.lang.lisp
I'm trying to get this working under SBCL, but I'm still a noob.
Anyone?
;; porting section - hopefully everything LW-specific is here and the
rest is straight CL
;; find equivalents for your CL
(defun string-append (&rest strings)
#+:lispworks(apply #'lispworks::string-append strings))
(defun add-special-free-action (fsym)
#+:lispworks(hcl:add-special-free-action fsym))
(defun flag-special-free-action (obj)
#+:lispworks(hcl:flag-special-free-action obj))
(defun make-value-weak-hash-table ()
#+:lispworks(make-hash-table :weak-kind :value))
;;;;; end porting section ;;;;;;;;;;;;;;;;;;;;;;;;;;
Peter Seibel <·····@gigamonkeys.com> writes:
> "richhickey" <··········@gmail.com> writes:
[...]
>> http://foil.sourceforge.net
>
> Is this The Library Formerly Known as JFLI?
Kind of but not really, by the looks of the web page:
The design of Foil owes much to jfli, an in-process solution to
the same problem for Java, and it remains extremely similar in its
Lisp interface. Several factors motivated the significant
difference in the Foil design - its use of an out-of-process
instance of the foreign runtime:
* jfli did not see wide porting, due to its use of LispWorks'
sophisticated FLI to access JNI, and the lack of
corresponding facilities in some other Lisps
* I found that I needed to access already-running instances of
the JVM, for instance servlet containers, as done in
Lisplets, and felt I could accomplish similar things with
less effort with Foil + marshallers
* I wanted to access the CLR/CLI in a similar fashion to Java
* It allows for more flexibility in dealing with threading
issues
From: Peter Seibel
Subject: Re: [Ann] Foil - a Foreign Object Interface for Lisp
Date:
Message-ID: <m3ekf57blh.fsf@gigamonkeys.com>
Bruce Stephens <············@cenderis.demon.co.uk> writes:
> Peter Seibel <·····@gigamonkeys.com> writes:
>
>> "richhickey" <··········@gmail.com> writes:
>
> [...]
>
>>> http://foil.sourceforge.net
>>
>> Is this The Library Formerly Known as JFLI?
>
> Kind of but not really, by the looks of the web page:
Ah, of course RTFWP. Thanks. Anyway, this means, Rich, we need a
FOIL-based version of your response to the Groovy/Bloglines GUI
challenge. ;-)
-Peter
--
Peter Seibel ·····@gigamonkeys.com
Lisp is the red pill. -- John Fraser, comp.lang.lisp
As drewc already clarfied, the bloglines stuff is Foil based. Here are
some screenshots of a little GUI apropos app done with Foil and Windows
Forms, SWT/Windows, and SWT/OS X (the latter 2 from the same source):
http://sourceforge.net/project/screenshots.php?group_id=125543
Peter Seibel wrote:
> Ah, of course RTFWP. Thanks. Anyway, this means, Rich, we need a
> FOIL-based version of your response to the Groovy/Bloglines GUI
> challenge. ;-)
>
> -Peter
>
And how about RTRTYOP (read the responses to your own posts) :)
from Rich's version of the blogles reader :
;homegrown Lisp <-> Java/CLI bridge library
(load "/dev/foil/foil")
(use-package :foil)
;generated wrappers for java libs
(load "/foil/java-lang")
(load "/foil/java-util")
(load "/foil/swt")
(load "/foil/commons-httpclient")
looks like foil to me :) i've been having a bad brain day as well.
--
Drew Crampsie
drewc at tech dot coop
"Never mind the bollocks -- here's the sexp's tools."
-- Karl A. Krueger on comp.lang.lisp
From: Peter Seibel
Subject: Re: [Ann] Foil - a Foreign Object Interface for Lisp
Date:
Message-ID: <m3acpt76za.fsf@gigamonkeys.com>
drewc <·····@rift.com> writes:
> Peter Seibel wrote:
>
>> Ah, of course RTFWP. Thanks. Anyway, this means, Rich, we need a
>> FOIL-based version of your response to the Groovy/Bloglines GUI
>> challenge. ;-)
>> -Peter
>>
>
> And how about RTRTYOP (read the responses to your own posts) :)
Heh. I glanced at Rich's code but saved it for careful study later.
And then I think one of the Lisp blogs mentioned that it used "the
unreleased JFLI". Thus my original question of whether this was now
JFLI. But turns out I was actually waiting for FOIL all along. Or
something.
-Peter
--
Peter Seibel ·····@gigamonkeys.com
Lisp is the red pill. -- John Fraser, comp.lang.lisp
From: shvedunov
Subject: Re: [Ann] Foil - a Foreign Object Interface for Lisp
Date:
Message-ID: <388od8F5ejasdU1@individual.net>
Tried it with .NET 1.1 and Allegro 6.2 Trial (Windows).
First I've got error concerning non-fbound ENSURE-PACKAGE,
fixed it by compiling foil.lisp. After that foil.lisp loaded ok,
and even successfully connected to FoilCLISvr. But when I tried
to load foil-cli.lisp, it gave me some weird errors concerning
name conflicts, including name clash with NIL.
How can I fix this?..
Thanks,
Ivan
You don't need foil-cli to use foil. These are support files for
generating wrappers. Once foil.lisp is loaded and you have a
foilclisvr running, bind to the servers streams and you're ready to go.
There is code in foil/foil-cli/foilcli/boot.lisp for binding to the
server. Try
(def-foil-class "System.Collections.Hashtable")
; and you can start using a hash table
Rich and are working on eliminating the boot-strapping issues related
to getting these server up quickly. We have a simple solution that we
are working on getting in place shortly.
Thanks,
Eric
From: shvedunov
Subject: Re: [Ann] Foil - a Foreign Object Interface for Lisp
Date:
Message-ID: <388oi5F5ejasdU2@individual.net>
(I mean that it apparently had some contact with CLISvr as it
displayed some warning messages seemingly containing names from .NET
assemblies; connection was made by socket:make-socket "manually", of
course)
"richhickey" <··········@gmail.com> writes:
> Foil - a Foreign Object Interface for Lisp, is now available
>
> Foil provides a protocol and code to interface between Lisp and
> instances of runtimes such as the JVM and CLR, offering comprehensive,
> safe, dynamic, efficient, and portable access to Java and CLI libraries
> from Lisp, with an emphasis on working in Lisp.
>
> Foil is open source, released under the Common Public License.
>
> Find out more at:
>
> http://foil.sourceforge.net
>
> Regards,
>
> Rich Hickey
This patch makes it work with acl. (Not tested very extensively.)
cmucl should also work, but it hangs while trying to read from the
socket.
diff -b -u -r1.21 foil.lisp
--- foil.lisp 24 Feb 2005 16:37:54 -0000 1.21
+++ foil.lisp 25 Feb 2005 16:56:31 -0000
@@ -72,7 +72,10 @@
;; find equivalents for your CL
(defun string-append (&rest strings)
- #+:lispworks(apply #'lispworks::string-append strings))
+ #+:lispworks(apply #'lispworks::string-append strings)
+ #-:lispworks
+ (apply #'concatenate 'string
+ (mapcar #'(lambda (s) (if (symbolp s) (symbol-name s) s)) strings)))
(defun add-special-free-action (fsym)
#+:lispworks(hcl:add-special-free-action fsym))
@@ -81,7 +84,9 @@
#+:lispworks(hcl:flag-special-free-action obj))
(defun make-value-weak-hash-table ()
- #+:lispworks(make-hash-table :weak-kind :value))
+ #+:lispworks(make-hash-table :weak-kind :value)
+ #+cmu (make-hash-table :weak-p t)
+ #+allegro (make-hash-table :values :weak))
;;;;; end porting section ;;;;;;;;;;;;;;;;;;;;;;;;;;
@@ -151,13 +156,16 @@
(defun make-fref (id rev &key type hash val)
(let ((ret (make-instance 'fref :id id :rev rev :type type :hash
hash :val val)))
- (flag-special-free-action ret)
+ #+lispworks (flag-special-free-action ret)
+ #+cmu (ext:finalize ret #'foil::free-fref)
+ #+allegro (excl:schedule-finalization ret #'foil::free-fref)
ret))
(defun free-fref (obj)
(when (typep obj 'fref)
(push obj (fvm-free-list (fref-vm obj)))))
+#+lispworks
(add-special-free-action 'foil::free-fref)
(defmethod print-object ((fref fref) stream)
@@ -350,7 +358,8 @@
(mapc #'ensure-foil-class supers)
(unless (and class (subtypep class 'standard-object))
(setf class
- (clos:ensure-class class-sym
+ (#+lispworks clos:ensure-class #+cmu pcl:ensure-class #+allegro mop:ensure-class
+ class-sym
:direct-superclasses (if supers
(mapcar #'class-symbol supers)
'(fref)))))
Andras
Andras Simon <······@math.bme.hu> writes:
>
> This patch makes it work with acl. (Not tested very extensively.)
> cmucl should also work, but it hangs while trying to read from the
> socket.
Adding a newline to the resultMessage in RuntimeServer.java solves
this. Now both cmucl and sbcl seem to work.
Andras
ps. I see that there is now a foil mailing list, so I'll send
patches there.
Andras Simon wrote:
> Andras Simon <······@math.bme.hu> writes:
> ...
>
> ps. I see that there is now a foil mailing list, so I'll send
> patches there.
Hm, where?
It /almost/ works under SBCL now ... I think :)
···········@gmail.com writes:
> Andras Simon wrote:
> > Andras Simon <······@math.bme.hu> writes:
> > ...
> >
> > ps. I see that there is now a foil mailing list, so I'll send
> > patches there.
>
> Hm, where?
>
> It /almost/ works under SBCL now ... I think :)
Same here. I get lots of
WARNING: (FUNCALL SB-KERNEL::H) lost:
invalid number of arguments: 0
in SBCL and
Warning: (FUNCALL LISP::HOOK) lost:
Invalid number of arguments: 0
in CMUCL when trying to dump-wrapper-defs-to-file. ACL seems to work
fine.
Andras
Got it working under SBCL now:
http://sourceforge.net/tracker/index.php?func=detail&aid=1152387&group_id=125543&atid=702908
..messing with awt and swing (what do Java-people actually use these
days?) now. This is fun .... :)
···········@gmail.com writes:
> Got it working under SBCL now:
> http://sourceforge.net/tracker/index.php?func=detail&aid=1152387&group_id=125543&atid=702908
>
> ..messing with awt and swing (what do Java-people actually use these
> days?) now. This is fun .... :)
I answered this on the foil-users list, because this discussion really
belongs there.
Andras
From: shvedunov
Subject: Re: [Ann] Foil - a Foreign Object Interface for Lisp
Date:
Message-ID: <3897jmF5ld97cU1@individual.net>
Thanks a lot!
Now it works with Allegro. Seems to be incredibly powerful thing. Thanks.