From: dan b
Subject: Lisp as a scripting language from within C++?
Date: 
Message-ID: <8dea8c27.0109101253.22650b1b@posting.google.com>
I'm writing a small, simple tile based RPG using C++ to hopefully
expand my knowledge, and I'd like to know how I can use Common Lisp as
a scripting language from within the C++ engine. Yes, I know it would
be much slower than scheme, guile, or TCL, but I want to do it anyway
just for the experience and the fun of it. I'm on a Unix machine
(FreeBSD 4.3 to be exact) and i use the CMU Common lisp compiler. If
it's possisble to use it as a scripting language, could I have a few
links to show how I would go about doing this, as i have no idea where
to even start. Thanks!

From: Marco Antoniotti
Subject: Re: Lisp as a scripting language from within C++?
Date: 
Message-ID: <y6c7kv64uw1.fsf@octagon.mrl.nyu.edu>
·······@Hotmail.com (dan b) writes:

> I'm writing a small, simple tile based RPG using C++ to hopefully
> expand my knowledge, and I'd like to know how I can use Common Lisp as
> a scripting language from within the C++ engine. Yes, I know it would
> be much slower than scheme, guile, or TCL,

Since when a language for which native compilers exist, is slower than
"scheme, guile, or TCL,"? (And you forgot the innominable one).

Are you trolling?

Cheers

-- 
Marco Antoniotti ========================================================
NYU Courant Bioinformatics Group        tel. +1 - 212 - 998 3488
719 Broadway 12th Floor                 fax  +1 - 212 - 995 4122
New York, NY 10003, USA                 http://bioinformatics.cat.nyu.edu
                    "Hello New York! We'll do what we can!"
                           Bill Murray in `Ghostbusters'.
From: dan b
Subject: Re: Lisp as a scripting language from within C++?
Date: 
Message-ID: <2a80e447.0109101728.17226da0@posting.google.com>
Marco Antoniotti <·······@cs.nyu.edu> wrote in message news:<···············@octagon.mrl.nyu.edu>...
> ·······@Hotmail.com (dan b) writes:
> 
> > I'm writing a small, simple tile based RPG using C++ to hopefully
> > expand my knowledge, and I'd like to know how I can use Common Lisp as
> > a scripting language from within the C++ engine. Yes, I know it would
> > be much slower than scheme, guile, or TCL,
> 
> Since when a language for which native compilers exist, is slower than
> "scheme, guile, or TCL,"? (And you forgot the innominable one).
> 
> Are you trolling?
> 
> Cheers


Woah, chill out, i didn't mean to offend you. I meant as a SCRIPTING
LANGUAGE, i've HEARD, scheme, guile, and TCL are better suited. Back
to my original question, do you know how I could use Common Lisp for
that purpose?
From: Eugene Zaikonnikov
Subject: Re: Lisp as a scripting language from within C++?
Date: 
Message-ID: <680a835d.0109110250.213cb9f3@posting.google.com>
·······@hotmail.com (dan b) wrote in message 
[...]
> I meant as a SCRIPTING LANGUAGE, i've HEARD, scheme, guile, and TCL 
> are better suited.

Even if they are, Common Lisp in general is *not* slower than Scheme,
and CMU CL is defenitely faster than Guile (a particular Scheme dialect)
and TCL.

> Back to my original question, do you know how I could use Common Lisp 
> for that purpose?

Take a look at http://langband.sf.net - a rougelike RPG using 
Common Lisp both as a scripting and the main implementation language.
It's author usually can be found on IRC channel #lisp at
irc.openprojects.net.
--
  Eugene.
From: Thomas F. Burdick
Subject: Re: Lisp as a scripting language from within C++?
Date: 
Message-ID: <xcvy9nmdzyx.fsf@conquest.OCF.Berkeley.EDU>
·······@Hotmail.com (dan b) writes:

> I'm writing a small, simple tile based RPG using C++ to hopefully
> expand my knowledge, and I'd like to know how I can use Common Lisp as
> a scripting language from within the C++ engine. Yes, I know it would
> be much slower than scheme, guile, or TCL, but I want to do it anyway
> just for the experience and the fun of it. I'm on a Unix machine
> (FreeBSD 4.3 to be exact) and i use the CMU Common lisp compiler. If
> it's possisble to use it as a scripting language, could I have a few
> links to show how I would go about doing this, as i have no idea where
> to even start. Thanks!

Actually, it's almost certain to be much faster than Guile Scheme or
TCL.  CMUCL makes it very easy for the Lisp program to call out to C,
but it's not so easy for C to call into Lisp.  It's possible, but I
would not recommend it as a way of adding scripting to your program.
Think about it and see if you can come up with a way for it to make
sense for the Lisp to call up into C, and if you can, use CMUCL.

If you can't, try ECLS <http://ecls.sourceforge.net/>, which is
designed to be embedded in C apps.  It's not ANSI compliant, but it's
moving in that direction.  And the limbo between CLtL1 and ANSI CL is
a much nicer place to be than Scheme or, god forbid, TCL.
From: dan b
Subject: Re: Lisp as a scripting language from within C++?
Date: 
Message-ID: <2a80e447.0109110608.35a64eb5@posting.google.com>
So it's hard for C to call lisp eh? Hmmm... I was worried about that.
I'm not good enough at lisp to write it in lisp, plus it's graphical
and thats even more advanced if i was to write it in lisp. Well i'll
check out the links you guys gave me. Thanks for answering my
questions.
From: Thomas F. Burdick
Subject: Re: Lisp as a scripting language from within C++?
Date: 
Message-ID: <xcvpu8xeej2.fsf@famine.OCF.Berkeley.EDU>
·······@hotmail.com (dan b) writes:

> So it's hard for C to call lisp eh? Hmmm... I was worried about that.
> I'm not good enough at lisp to write it in lisp, plus it's graphical
> and thats even more advanced if i was to write it in lisp. Well i'll
> check out the links you guys gave me. Thanks for answering my
> questions.

Calling between Lisp and other languages is outside of the scope of
the spec, so statements like "it's hard for C to call Lisp" aren't
very useful.  It is hard for C to call CMUCL.  It's not so hard for C
to call into ECLS.  Try to remember that CL isn't a one-implementation
language, unlike most things people try to use for scripting.
From: Christopher Stacy
Subject: Re: Lisp as a scripting language from within C++?
Date: 
Message-ID: <usndtzka7.fsf@spacy.Boston.MA.US>
>>>>> On 11 Sep 2001 07:08:40 -0700, dan b ("dan") writes:
 dan> So it's hard for C to call lisp eh? Hmmm... I was worried about that.

It's not a standard part of Lisp, and in some compilers it is easy,
as several people pointed out.   (It's the same problem as calling Java.)
From: Geoffrey Summerhayes
Subject: Re: Lisp as a scripting language from within C++?
Date: 
Message-ID: <Hbgn7.15409$%N2.910495@news20.bellglobal.com>
"dan b" <·······@Hotmail.com> wrote in message
·································@posting.google.com...
> I'm writing a small, simple tile based RPG using C++ to hopefully
> expand my knowledge, and I'd like to know how I can use Common Lisp as
> a scripting language from within the C++ engine. Yes, I know it would
> be much slower than scheme, guile, or TCL, but I want to do it anyway
> just for the experience and the fun of it. I'm on a Unix machine
> (FreeBSD 4.3 to be exact) and i use the CMU Common lisp compiler. If
> it's possisble to use it as a scripting language, could I have a few
> links to show how I would go about doing this, as i have no idea where
> to even start. Thanks!

Search for "Abuse" by crack-dot-com. 2D side scrolling shooter.
They posted the complete code for the game when they went out
of business. The main graphic engine is in C++ with a mini-lisp
interpreter, possibly compiler, built into it. The entire game
logic is written in Lisp. It's also annoyingly fast. Their web
page was still up a year ago, it seems to have finally disappeared.
There were numerous ports to Linux around the web at one time,
check some ftp sites, it's probably still around.

Geoff
From: Olivier Lefevre
Subject: Re: Lisp as a scripting language from within C++?
Date: 
Message-ID: <3b9e6282@news.core.genedata.com>
> Search for "Abuse" by crack-dot-com.

The game seems to live on at abuse2.com and the code at
http://sourceforge.net/projects/abuse2

-- O.L.
From: Geoffrey Summerhayes
Subject: Re: Lisp as a scripting language from within C++?
Date: 
Message-ID: <Tlzn7.18930$2r.1638986@news20.bellglobal.com>
"Olivier Lefevre" <···············@genedata.com> wrote in message
·············@news.core.genedata.com...
> > Search for "Abuse" by crack-dot-com.
>
> The game seems to live on at abuse2.com and the code at
> http://sourceforge.net/projects/abuse2
>

Interesting. It's a shame they don't have to much there
at the moment although it looks like they've put the entire
original source in the CVS tree. I was thinking about tackling
a rewrite of the code myself and making it Win32-DX friendly.
Since they are aiming for a Win-Linux mix I hope they dump the
assembly code and rely on the compilers instead of consigning
it to x86 machines.

Geoff
From: Erik Naggum
Subject: Re: Lisp as a scripting language from within C++?
Date: 
Message-ID: <3209194749900066@naggum.net>
* ·······@Hotmail.com (dan b)
> I'm writing a small, simple tile based RPG using C++ to hopefully
> expand my knowledge, and I'd like to know how I can use Common Lisp as
> a scripting language from within the C++ engine.  Yes, I know it would
> be much slower than scheme, guile, or TCL, but I want to do it anyway
> just for the experience and the fun of it.

  Are you referring to the startup time of the interpreter, or to the
  execution time of the code once the interpreter is executing?  Do you
  expect to be able to pre-compile most of the code that will be run, or do
  you intend to ship tons of source code into your system?

///
From: dan b
Subject: Re: Lisp as a scripting language from within C++?
Date: 
Message-ID: <2a80e447.0109111605.1aae03fb@posting.google.com>
>   Are you referring to the startup time of the interpreter, or to the
>   execution time of the code once the interpreter is executing?  Do you
>   expect to be able to pre-compile most of the code that will be run, or do
>   you intend to ship tons of source code into your system?

Again-- I am just a newbie, and i'm not sure what the best way to do
it would be, so I'm not sure myself. I was just wondering if it's even
possible-- if so i was looking for links to show how it could be done,
if anyone has more...
From: dave linenberg
Subject: Re: Lisp as a scripting language from within C++?
Date: 
Message-ID: <3B9EB568.5F4F0AD1@home.com>
dan b wrote:

> >   Are you referring to the startup time of the interpreter, or to the
> >   execution time of the code once the interpreter is executing?  Do you
> >   expect to be able to pre-compile most of the code that will be run, or do
> >   you intend to ship tons of source code into your system?
>
> Again-- I am just a newbie, and i'm not sure what the best way to do
> it would be, so I'm not sure myself. I was just wondering if it's even
> possible-- if so i was looking for links to show how it could be done,
> if anyone has more...

I've called Lisp from C using the following techniques:

The server:
* create a socket server which forks off the following process for each client
trying to connect -
* create a pseudoterminal  (see W.Richard Stevens, Advanced Unix Programming)
* start up CMUCL Lisp in the pseudo terminal
* I have created C functions callable from Lisp which enable it to transmit lisp
data or code back to the client over a socket in a self-describing XDR format

The client:
* A GUI GTK program connects to the lisp server.
* The GUI program executes commands on the lisp server, as if it were on the
same machine or in
the same process space
* If a result is desired, the server is instructed to relay data or code in an
XDR format back to the client.

Using these techniques, I have been able to send code to a lisp server, which
then returns code ..which can
in turn be resent back to the server  (etc etc) until finally data is sent back
to the C program.  Thread(s) are spawned in the client which receives the data,
decodes it, and processes it.

(I actually embed a terminal  (gnome ZVT_TERM  widget) in my client, and I even
employ readline, to make CMUCL code entry easier if I desire to hand to hand
enter it instead of having widget clicks generate it).  Also, my C program uses
the lispreader library (www.complang.tuwien.ac.at/~schani/lispreader/), and all
data returned from CMUCL, gets decoded in C into a lisp_object_t* object, so I
can car , cdr and cons (manipulate) it in C in a lispy way.

There is heavy use of threading, forking, as well as placing graphics events
into the gtk event stack.  The code is currently proprietary, but this should
give you a start.

I'm not sure this is the *best* way of doing it, but it works, and it is
**very** fast.


Dave Linenberg
From: dan b
Subject: Re: Lisp as a scripting language from within C++?
Date: 
Message-ID: <2a80e447.0109120601.5084c608@posting.google.com>
> I've called Lisp from C using the following techniques:
> 
> The server:
> * create a socket server which forks off the following process for each client
> trying to connect -
> * create a pseudoterminal  (see W.Richard Stevens, Advanced Unix Programming)
> * start up CMUCL Lisp in the pseudo terminal
> * I have created C functions callable from Lisp which enable it to transmit lisp
> data or code back to the client over a socket in a self-describing XDR format
> 
> The client:
> * A GUI GTK program connects to the lisp server.
> * The GUI program executes commands on the lisp server, as if it were on the
> same machine or in
> the same process space
> * If a result is desired, the server is instructed to relay data or code in an
> XDR format back to the client.
> 
> Using these techniques, I have been able to send code to a lisp server, which
> then returns code ..which can
> in turn be resent back to the server  (etc etc) until finally data is sent back
> to the C program.  Thread(s) are spawned in the client which receives the data,
> decodes it, and processes it.
> 
> (I actually embed a terminal  (gnome ZVT_TERM  widget) in my client, and I even
> employ readline, to make CMUCL code entry easier if I desire to hand to hand
> enter it instead of having widget clicks generate it).  Also, my C program uses
> the lispreader library (www.complang.tuwien.ac.at/~schani/lispreader/), and all
> data returned from CMUCL, gets decoded in C into a lisp_object_t* object, so I
> can car , cdr and cons (manipulate) it in C in a lispy way.
> 
> There is heavy use of threading, forking, as well as placing graphics events
> into the gtk event stack.  The code is currently proprietary, but this should
> give you a start.
> 
> I'm not sure this is the *best* way of doing it, but it works, and it is
> **very** fast.
> 
> 
> Dave Linenberg

Wow! That's a little advanced for me but it might be doable, i've done
linux sockets a little. Thanks alot for that!
From: Dennis Dunn
Subject: Re: Lisp as a scripting language from within C++?
Date: 
Message-ID: <qiUn7.51241$VX3.1852373@e3500-atl1.usenetserver.com>
Hey Dan,

You might want to take a look at "librep." It lives on Sourceforge
http://librep.sourceforge.net/ and seems like it might be what you need.  It
is a Lisp system that is meant to be embedded into an application to provide
scripting functionality in that app.

Good luck.

--dennis
From: H�kon Alstadheim
Subject: Re: Lisp as a scripting language from within C++?
Date: 
Message-ID: <m0u1y6o4uy.fsf@alstadhome.cyberglobe.net>
"Dennis Dunn" <········@bellsouth.net> writes:

> Hey Dan,
> 
> You might want to take a look at "librep." It lives on Sourceforge

Anyone care to characterise where librep lives in the family-trees of
Lisp and Scheme dialects? I seem to remember reading that it started
out as a clone of emacs lisp, and then drifted towards standard lisp.
(Which standard lisp might that be, i.e. when did this drift happen).

Somewhere else I encountered some talk about Scheme in librep. I
believe it encapsulates some kind of embedded Scheme dialect, but how
this works is kind of hazy to me.

The reason I'm asking is because most of sawfish ( default WM for
GNOME) is written in this lispish language. Much of that in a
seemingly Scheemish subset of that lispish language. This language
makes me a bit --- unnhh --- uncomfortable, and as a newbie I need
some guru to tell me exactly why. The more details the better. A good
place to start would be talking about how SETF does not work in
librep.

-- 
H�kon Alstadheim, Montreal, Quebec, Canada  
From: Philip Lijnzaad
Subject: Re: Lisp as a scripting language from within C++?
Date: 
Message-ID: <u7zo7y16c7.fsf@sol6.ebi.ac.uk>
> A good place to start would be talking about how SETF does not work in
> librep.

If librep is emacs-like, perhaps one could lift all the setf macros out of
Dave Gillespie's emacs 'cl package (or better, integrate it with the librep
distro)?

                                                                       Philip
-- 
Real programs don't eat cache (Malay)
-----------------------------------------------------------------------------
Philip Lijnzaad, ········@ebi.ac.uk \ European Bioinformatics Institute,rm A2-08
+44 (0)1223 49 4639                 / Wellcome Trust Genome Campus, Hinxton
+44 (0)1223 49 4468 (fax)           \ Cambridgeshire CB10 1SD,  GREAT BRITAIN
From: Janis Dzerins
Subject: Re: Lisp as a scripting language from within C++?
Date: 
Message-ID: <8766amb57d.fsf@asaka.latnet.lv>
·········@enitel.no (H�kon Alstadheim) writes:

> "Dennis Dunn" <········@bellsouth.net> writes:
> 
> > Hey Dan,
> > 
> > You might want to take a look at "librep." It lives on Sourceforge
> 
> Anyone care to characterise where librep lives in the family-trees of
> Lisp and Scheme dialects? I seem to remember reading that it started
> out as a clone of emacs lisp, and then drifted towards standard lisp.
> (Which standard lisp might that be, i.e. when did this drift happen).

http://librep.sourceforge.net/librep-manual.html

  librep is a dialect of Lisp, designed to be used both as an
  extension language for applications, and for use as a general
  programming language. It was originally written to be
  mostly-compatible with Emacs Lisp, but has subsequently diverged
  markedly. Its aim is to combine the best features of Scheme and
  Common Lisp and provide an environment that is comfortable for
  implementing both small and large scale systems. It tries to be a
  "pragmatic" programming language.

Although looking at http://librep.sourceforge.net/ I can't see
anything from Common Lisp being added to it.

-- 
Janis Dzerins

  If million people say a stupid thing it's still a stupid thing.