From: ·····@uci.edu
Subject: Calling scheme/lisp from C shared object - commercial application
Date: 
Message-ID: <878158605.25708@dejanews.com>
Hi all,

I would like to invoke Lisp or Scheme to evaluate functions from within
a C/C++ program.  Ideally, here's how I would like it to work:

    lisp_loadFunction("(defun square(x)(* x x))");

    result = lisp_callFunction("(square 2)");

I am writing a Sun shared object so the lisp implementation cannot
include a main program.  Since I am not writing main I do not have access
to argv[0] as required for use of some scheme implementations such as
ELK.

This would be for use in a commercial product.	I talked to a couple of
the commercial vendors and have not found a product that will work,
although one company did offer to modify their product to do this.

Does anyone know of any lisp/scheme implementation that would work for me?

Thanks alot,

Mark

-------------------==== Posted via Deja News ====-----------------------
      http://www.dejanews.com/     Search, Read, Post to Usenet

From: Johann Hibschman
Subject: Re: Calling scheme/lisp from C shared object - commercial application
Date: 
Message-ID: <6399rs$27f$1@agate.berkeley.edu>
In article <···············@dejanews.com>,  <·····@uci.edu> wrote:

>This would be for use in a commercial product.	I talked to a couple of
>the commercial vendors and have not found a product that will work,
>although one company did offer to modify their product to do this.
>
>Does anyone know of any lisp/scheme implementation that would work for me?

I'm not absolutely sure that it'll do what you want it to, but have you
looked at SIOD?  It seems to fit the bill as a small-footprint Scheme
designed for embedded use.

Unfortunately, there isn't all that much documentation out there.  You
basically have to deduce the workings from the mostly-uncommented
source code and a few examples.  There's a SIOD user's web page, and
the author, George Carrette, has a web page for it at:

	 http://people.delphi.com/gjc/siod.html

Hopefully it will do what you need it to do.  It certainly does provide
functions like:
	repl_c_string("(define (square x) (+ x 2))",0,0,0)
and there are a few ways to get access to stuff defined in the current
REPL.

I hope that helps,

- Johann
-- 
Johann A. Hibschman         | Grad student in Physics, working in Astronomy.
······@physics.berkeley.edu | Probing pulsar pair production processes.
From: Shriram Krishnamurthi
Subject: Re: Calling scheme/lisp from C shared object - commercial application
Date: 
Message-ID: <j7vra93i5xa.fsf@africa.cs.rice.edu>
MzScheme (http://www.cs.rice.edu/CS/PLT/packages/mzscheme/) will do
this sort of thing for you.  It gives you a complete Scheme, including
continuations and tail calling, and has extensions like modules and
objects so you won't have to change Scheme's at any point.  And it
runs on a wide variety of platforms.

'shriram
From: David Betz
Subject: Re: Calling scheme/lisp from C shared object - commercial application
Date: 
Message-ID: <34587D13.571@xlisper.mv.com>
·····@uci.edu wrote:
> 
> Hi all,
> 
> I would like to invoke Lisp or Scheme to evaluate functions from within
> a C/C++ program.  Ideally, here's how I would like it to work:
> 
>     lisp_loadFunction("(defun square(x)(* x x))");
> 
>     result = lisp_callFunction("(square 2)");
> 
> I am writing a Sun shared object so the lisp implementation cannot
> include a main program.  Since I am not writing main I do not have access
> to argv[0] as required for use of some scheme implementations such as
> ELK.
> 
> This would be for use in a commercial product.  I talked to a couple of
> the commercial vendors and have not found a product that will work,
> although one company did offer to modify their product to do this.
> 
> Does anyone know of any lisp/scheme implementation that would work for me?
> 
> Thanks alot,
> 
> Mark
> 
> -------------------==== Posted via Deja News ====-----------------------
>       http://www.dejanews.com/     Search, Read, Post to Usenet

You can do this with XLISP 3.0 which is a Scheme superset. The calls
would look like:

xlValue val;
xlEvaluateCString(NULL,0,"(define (square x) (* x x))");
xlEvaluateCString(&val,1,"(square 2)");
result = xlGetFixnum(val);

XLISP 3.0 can be used as a library under Unix or as a .DLL under Windows
95.

David Betz

-- 
David Betz
·····@xlisper.mv.com
·········@aol.com
(603) 472-2389
From: Mark Galassi
Subject: Re: Calling scheme/lisp from C shared object - commercial application
Date: 
Message-ID: <76hg9tsjez.fsf@odie.lanl.gov>
·····@uci.edu writes:
>     lisp_loadFunction("(defun square(x)(* x x))");
> 
>     result = lisp_callFunction("(square 2)");

Since everyone has mentioned how their dialect does it, I'll throw in
a word for Guile, which is designed for this kind of thing.

You would do the above with [note I use Scheme syntax, not CL]:

  SCM result;
  /* [...] */
  gh_eval_str("(define (square x) (* x x))");
  result = gh_eval_str("(square 2)");

> I am writing a Sun shared object so the lisp implementation cannot
> include a main program.  Since I am not writing main I do not have access
> to argv[0] as required for use of some scheme implementations such as
> ELK.

You don't need access to argv[0] for Guile, but you would have to
"enter" the interpreter by offering it a sacrificial function.  The
interpreter would only be valid in that function.  I'm experimenting
with ways of making Guile not require this, but to be robust it needs
a C library call that returns the stack base, and that is not
standard.

> This would be for use in a commercial product.	I talked to a couple of
> the commercial vendors and have not found a product that will work,
> although one company did offer to modify their product to do this.

You can use Guile in a commercial product as long as you respect the
GLGPL (a slight modification of the LGPL).  The GLGPL says you don't
have to offer source for the rest of your program -- just for Guile.
But you must use Guile unmodified.

-- 
             Mark Galassi --- astrophysicist, hacker, writer
             Cygnus Solutions and Los Alamos National Laboratory
                                 ·······@cygnus.com or ·······@nis.lanl.gov
                                 http://nis-www.lanl.gov/~rosalia/
From: Ulric Eriksson
Subject: Re: Calling scheme/lisp from C shared object - commercial application
Date: 
Message-ID: <644v5m$ckk$1@home.edu.stockholm.se>
In article <··············@odie.lanl.gov>,
Mark Galassi  <·······@nis.lanl.gov> wrote:
>
>·····@uci.edu writes:
>
>> I am writing a Sun shared object so the lisp implementation cannot
>> include a main program.  Since I am not writing main I do not have access
>> to argv[0] as required for use of some scheme implementations such as
>> ELK.
>
>You don't need access to argv[0] for Guile, but you would have to
>"enter" the interpreter by offering it a sacrificial function.  The
>interpreter would only be valid in that function.  I'm experimenting
>with ways of making Guile not require this, but to be robust it needs
>a C library call that returns the stack base, and that is not
>standard.

Given Guile's relationship with SIOD, have you looked at the way
it's done there? That code looks like system dependent magic,
but it does work and simplifies the initialization from the
main program's point of view.

Ulric
-- 
Should we or should we not follow the advice of the galactically stupid?
From: Howard R. Stearns
Subject: Re: Calling scheme/lisp from C shared object - commercial application
Date: 
Message-ID: <345E4A50.167EB0E7@elwood.com>
Check out Eclipe Common Lisp at
http://www.elwood.com/eclipse-info/index.htm

·····@uci.edu wrote:
> 
> Hi all,
> 
> I would like to invoke Lisp or Scheme to evaluate functions from within
> a C/C++ program.  Ideally, here's how I would like it to work:
> 
>     lisp_loadFunction("(defun square(x)(* x x))");
> 
>     result = lisp_callFunction("(square 2)");
> 
> I am writing a Sun shared object so the lisp implementation cannot
> include a main program.  Since I am not writing main I do not have access
> to argv[0] as required for use of some scheme implementations such as
> ELK.
> 
> This would be for use in a commercial product.  I talked to a couple of
> the commercial vendors and have not found a product that will work,
> although one company did offer to modify their product to do this.
> 
> Does anyone know of any lisp/scheme implementation that would work for me?
> 
> Thanks alot,
> 
> Mark
> 
> -------------------==== Posted via Deja News ====-----------------------
>       http://www.dejanews.com/     Search, Read, Post to Usenet