On Wed, Feb 01, 2006 at 04:48:02AM +0100, Pascal Bourguignon wrote:
> Stuart Sierra writes:
> > Jeremy Smith <[EMAIL PROTECTED]> writes:
> > > As promised on comp.lang.lisp to some howls of protest, I
> > > have integrated Python, and its libraries, with Lisp.

I too pondered doing this for Perl, either embedded or via pipes, and
for the same reasons.

I started http://www.cliki.net/Cut%20and%20shut [and went quiet for a
while], now I have enough pipework to use Perl for testing my Lisp
implementation of substr.

My original plan was to make an "escape hatch", to do in Perl the
tasks I couldn't figure out in Lisp.  It didn't work out that way.

The problems I've had so far have been solved either by poking about
(slow but interesting) or asking on #lisp (thanks folks!).  The tasks
I've set myself in Lisp aren't urgent.

As for protest, I did receive a little bemusement and some suggestions
for other routes that might do what I want (clawk).  There's no point
protesting, it's no more or less polluting than any other large body
of code that might be used as a library.


> LTK does it for TCL.
> It could be interesting to share code between these projects.

I pinched the tcl-piping code from ltk (thanks Peter) because it is an
exactly parallel solution.  The shortcut to "spawn a process and read
sexpr from it" was too good to pass by.  Hmm...  I can't see the
recipe in the cl-cookbook, but anyway I didn't know of it when I did
this.

My code isn't ready for release, it just sort of escaped.  In case
anyone is interested, I stashed it at
http://www.t8o.org/~mca1001/cgi/viewcvs/lisp/perl-tricks.lisp

Quick synopsis,

  PERL-TRICKS> (run-perl "$] + 10")
  WARNING: Starting eval2list.pl
  WARNING: First line = "'start"
  (:IN "$] + 10" :OUT 15.008007)
  PERL-TRICKS> (run-perl "warn 'whee'; die 'ouch'")
  (:IN "warn 'whee'; die 'ouch'"
       :ERROR
       "ouch at (eval 2) line 1, <> line 2."
       :WARNINGS
       ("whee at (eval 2) line 1, <> line 2.")
       :OUT
       NIL)

Just enough to be useful for testing things.  Oh, and access to
"Inline::ASM - Write Perl Subroutines in assembler" for those who feel
the need.  8-)


Elsewhere in this thread, Brad Beveridge wrote:

> [...] I wonder how hard it would be to autogenerate Lisp functions
> that call Python functions?  I'd guess it wouldn't be too bad.

I believe introspection is possible in Python, at least to some
extent.  You can walk the symbol tables of all packages in Perl.

Question is, for what will you autogenerate Lisp functions?  Less than
everything, I think.  And how to decide between generic and plain?


Also in Perl's case you may bump into the AUTOLOAD system.

It's evil and nasty, often abused when there are tidier ways to do
it...  and occasionally really handy.

You can't know whether a method or subroutine exists in the package
until you call it.  At runtime, FooPackage::AUTOLOAD may either

 - do some stuff,
 - create relevant symbol table entry(ies), then do stuff,
 - or just barf.

"Stuff" is variously loaded from .so/.dll files, compiled from chunks
of Perl that were considered not worth compiling up front, or just
made up on the fly.

I mention this not to make your skin crawl, but to point out that in
other languages the things that appeared to be corner cases are
actually tiny extradimensional rifts.


Matthew  #8-)
_______________________________________________
Gardeners mailing list
[email protected]
http://www.lispniks.com/mailman/listinfo/gardeners

Reply via email to