From: Peter Seibel
Subject: Combining Perl and Lisp?!
Date: 
Message-ID: <3munb8$p70@kadath.zeitgeist.net>
Ok, so it sounds a little crazy but I was wondering if anyone has any
insight on how I might combine Perl and Lisp. Specifically, I'm writing
some Perl scripts to deal with CGI stuff for a web site and having to do
a lot of manipulations that I would rather do in Lisp. But I don't want
to do the whole thing in Lisp. Am I completely insane? Can this work?

--------------------------------------------------------
Peter Seibel                    Mother Jones Interactive
······@mojones.com               http://www.mojones.com/
--------------------------------------------------------

From: David Gadbois
Subject: Re: Combining Perl and Lisp?!
Date: 
Message-ID: <3n18dc$jh6@peaches.cs.utexas.edu>
Peter Seibel  <······@mojones.com> wrote:
>Ok, so it sounds a little crazy but I was wondering if anyone has any
>insight on how I might combine Perl and Lisp. Specifically, I'm writing
>some Perl scripts to deal with CGI stuff for a web site and having to do
>a lot of manipulations that I would rather do in Lisp. But I don't want
>to do the whole thing in Lisp. Am I completely insane? Can this work?

Sure.  I have several WWW servers that have CGI scripts that just
initiate a TCP connection to a lisp process, pass the arguments over,
and copy out the results.  I do it this way because it is really
trivial to generate HTML on the fly in Lisp.

Another alternative is to run John C. Mallery's CL-HTTP server.  Check
out http://www.ai.mit.edu/projects/iiip/doc/cl-http/server.html.  They
are working on MCL and UNIX-based Lisp versions.  It lets you define
mappings between URLs and Lisp functions to call and is a whole lot
more secure than the CGI script mechanism.  Even if you don't run this
server, study the source for the HTML authoring macros.

--David Gadbois
From: Tom Christiansen
Subject: Re: Combining Perl and Lisp?!
Date: 
Message-ID: <3n3lpj$6t6@csnews.cs.colorado.edu>
In comp.lang.perl, Peter Seibel <······@mojones.com> writes:
:Ok, so it sounds a little crazy but I was wondering if anyone has any
:insight on how I might combine Perl and Lisp. Specifically, I'm writing
:some Perl scripts to deal with CGI stuff for a web site and having to do
:a lot of manipulations that I would rather do in Lisp. But I don't want
:to do the whole thing in Lisp. Am I completely insane? Can this work?

Ouch.  

It's not worth the bother.  There are plenty of CGI modules and libraries
available for perl.  And perl handles nested lists and associative arrays
just fine:

    $lpp = [
	[ a, b, c ],
	[ d, e, [f, g ], h],
    ];

And then 

    $lpp->[1][2][1]

Or

    @lpp = (
	[ a, b, c ],
	[ d, e, [f, g ], h],
    );

and then 

    $lpp[1][2][1]


Structures are easy, too, by using associative rather than regular
arrays:

    %foo = (
	field1 => value1,
	field2 => value2,
	field3 => value3,
	field4 => value4,
    );

And then $foo{field2} or whatever.  Here's a longer example:

    %foo = (
	field1 => [a, b, c],
	field2 => [d, e, f],
	field3 => [g, [ h, i, j ], c],
	field4 => {
	    subfield1 => value1,
	    subfield2 => value2,
	    subfield3 => value3,
	},
    );

And then access it as 

    $foo{field1}[2] 		# yeilds 'c'
    $foo{field3}[1][2] 		# yeilds 'j'
    $foo{field4}{subfield2}	# yields 'value3'


In perl, strings, arrays (lists) of strings, associative arrays of strings,
and functions are all first class citizens by most common uses of that
phrase, so I see no reason why you should have to deal with lisp at all.

--tom
From: Marco Antoniotti
Subject: Re: Combining Perl and Lisp?!
Date: 
Message-ID: <MARCOXA.95Apr20220628@mosaic.nyu.edu>
In article <··········@csnews.cs.colorado.edu> Tom Christiansen <·······@mox.perl.com> writes:

   From: Tom Christiansen <·······@mox.perl.com>
   Newsgroups: comp.lang.perl,comp.lang.lisp
   Date: 19 Apr 1995 18:46:11 GMT
   Organization: Perl Consulting and Training
   Lines: 69
   References: <··········@kadath.zeitgeist.net>
   Reply-To: ·······@mox.perl.com (Tom Christiansen)
   Originator: ·······@mox
   Xref: cmcl2 comp.lang.perl:48849 comp.lang.lisp:17857

   In comp.lang.perl, Peter Seibel <······@mojones.com> writes:
   :Ok, so it sounds a little crazy but I was wondering if anyone has any
   :insight on how I might combine Perl and Lisp. Specifically, I'm writing
   :some Perl scripts to deal with CGI stuff for a web site and having to do
   :a lot of manipulations that I would rather do in Lisp. But I don't want
   :to do the whole thing in Lisp. Am I completely insane? Can this work?

   Ouch.  

   It's not worth the bother.  There are plenty of CGI modules and libraries
   available for perl.  And perl handles nested lists and associative arrays
   just fine:

       $lpp = [
	   [ a, b, c ],
	   [ d, e, [f, g ], h],
       ];

   And then 

       $lpp->[1][2][1]

   Or

       @lpp = (
	   [ a, b, c ],
	   [ d, e, [f, g ], h],
       );

   and then 

       $lpp[1][2][1]


   Structures are easy, too, by using associative rather than regular
   arrays:

       %foo = (
	   field1 => value1,
	   field2 => value2,
	   field3 => value3,
	   field4 => value4,
       );

   And then $foo{field2} or whatever.  Here's a longer example:

       %foo = (
	   field1 => [a, b, c],
	   field2 => [d, e, f],
	   field3 => [g, [ h, i, j ], c],
	   field4 => {
	       subfield1 => value1,
	       subfield2 => value2,
	       subfield3 => value3,
	   },
       );

   And then access it as 

       $foo{field1}[2] 		# yeilds 'c'
       $foo{field3}[1][2] 		# yeilds 'j'
       $foo{field4}{subfield2}	# yields 'value3'


   In perl, strings, arrays (lists) of strings, associative arrays of strings,
   and functions are all first class citizens by most common uses of that
   phrase, so I see no reason why you should have to deal with lisp at all.

I have never really learned Perl, but the presence of different '%',
'$', ·@', '{}' and so on makes me say that I see no reason why you
should have to deal with Perl at all. :)

Happy Lisping
--
Marco Antoniotti - Resistente Umano
-------------------------------------------------------------------------------
Robotics Lab		| room: 1220 - tel. #: (212) 998 3370
Courant Institute NYU	| e-mail: ·······@cs.nyu.edu

...e` la semplicita` che e` difficile a farsi.
...it is simplicity that is difficult to make.
				Bertholdt Brecht
From: Philip Greenspun
Subject: Re: Combining Perl and Lisp?!
Date: 
Message-ID: <PHILG.95Apr23232934@camelot.ai.mit.edu>
In article <··········@kadath.zeitgeist.net> Peter Seibel <······@mojones.com> writes:

   Ok, so it sounds a little crazy but I was wondering if anyone has any
   insight on how I might combine Perl and Lisp. Specifically, I'm writing
   some Perl scripts to deal with CGI stuff for a web site and having to do
   a lot of manipulations that I would rather do in Lisp. But I don't want
   to do the whole thing in Lisp. Am I completely insane? Can this work?

Yes, you are insane... but in an MIT kind of way.  I built all the
initial CGI scripts for Travels with Samantha

http://webtravel.org/samantha/

in Scheme-48.  Jonathan Rees, the author of Scheme 48 made a nice
painless CGI interface for Scheme 48 and you end up with little
programs that are only about 100K in size to launch (easy on your Web
server performance).  Check the "Credit and Copyright" section of
Samantha if you want to find out more about Scheme 48.

I built an interface from an Oracle database to the Web in Oraperl and
the initial scripts were really easy because of the nice way that
Oraperl links the Oracle C libraries.  However, the nastacious
character of perl bit me when I tried to do things that would have
been remarkably easy in Lisp.

My new motto for perl:  a moment of pleasure; a lifetime of regret.


--

      -- Philip Greenspun

-------------------------------------------------------------
MIT Department of Electrical Engineering and Computer Science
545 Technology Square, Rm 609, Cambridge, MA 02139, (617) 253-8574
Personal Web URL:  http://www-swiss.ai.mit.edu/philg/