Best scheme for embedding in C?

This is a discussion on Best scheme for embedding in C? within the Scheme forums in Programming Languages category; Hi, which would be the best scheme implementation for embedding in a C program. I think what I need is a scheme that is provided as a library that I can link with the rest of my app. But main() will be in the C application, not in the scheme library. I would want to be able to create scheme functions callable from the C application. I would also need to call C functions from scheme. I think maybe guile does all this, but was wondering if there were any others out there that can work this way. It would ...

Go Back   Application Development Forum > Programming Languages > Scheme

Object Mix

Register FAQ Calendar Search Today's Posts Mark Forums Read
  #1  
Old 08-24-2008, 09:39 PM
Neil Baylis
Guest
 
Default Best scheme for embedding in C?

Hi,

which would be the best scheme implementation for embedding in a C
program. I think what I need is a scheme that is provided as a library
that I can link with the rest of my app. But main() will be in the C
application, not in the scheme library. I would want to be able to
create scheme functions callable from the C application. I would also
need to call C functions from scheme.

I think maybe guile does all this, but was wondering if there were any
others out there that can work this way. It would need to work on
Linux x86 and OSX x86.

Thanks,

Neil
Reply With Quote
  #2  
Old 08-25-2008, 01:58 AM
namekuseijin
Guest
 
Default Re: Best scheme for embedding in C?

On 24 ago, 22:39, Neil Baylis <neil.bay...@gmail.com> wrote:
> Hi,
>
> which would be the best scheme implementation for embedding in a C
> program. I think what I need is a scheme that is provided as a library
> that I can link with the rest of my app. But main() will be in the C
> application, not in the scheme library. I would want to be able to
> create scheme functions callable from the C application. I would also
> need to call C functions from scheme.
>
> I think maybe guile does all this, but was wondering if there were any
> others out there that can work this way. It would need to work on
> Linux x86 and OSX x86.
>
> Thanks,
>
> Neil


Have you looked at tinyscheme? Not quite R5RS-compatible, let alone
R6RS, but a fine and lightweight Scheme terp.

http://tinyscheme.sourceforge.net/home.html
Reply With Quote
  #3  
Old 08-25-2008, 02:29 AM
Friedrich
Guest
 
Default Re: Best scheme for embedding in C?

Neil Baylis <neil.baylis@gmail.com> writes:

> Hi,
>
> which would be the best scheme implementation for embedding in a C
> program. I think what I need is a scheme that is provided as a library
> that I can link with the rest of my app. But main() will be in the C
> application, not in the scheme library. I would want to be able to
> create scheme functions callable from the C application. I would also
> need to call C functions from scheme.
>
> I think maybe guile does all this, but was wondering if there were any
> others out there that can work this way. It would need to work on
> Linux x86 and OSX x86.

AFAIKT this was the "goal" of Guile and it should replace Emacs Lisp,
but this never has taken place really. If you are a bit flexible about
the language you might like to check lush (which stated goals is for
"embedding"
http://lush.sourceforge.net/

Regards
Friedrich

--
Please remove just-for-news- to reply via e-mail.
Reply With Quote
  #4  
Old 08-25-2008, 03:06 AM
Pascal J. Bourguignon
Guest
 
Default Re: Best scheme for embedding in C?

Friedrich <just-for-news-frido@q-software-solutions.de> writes:

> Neil Baylis <neil.baylis@gmail.com> writes:
>
>> Hi,
>>
>> which would be the best scheme implementation for embedding in a C
>> program. I think what I need is a scheme that is provided as a library
>> that I can link with the rest of my app. But main() will be in the C
>> application, not in the scheme library. I would want to be able to
>> create scheme functions callable from the C application. I would also
>> need to call C functions from scheme.
>>
>> I think maybe guile does all this, but was wondering if there were any
>> others out there that can work this way. It would need to work on
>> Linux x86 and OSX x86.

> AFAIKT this was the "goal" of Guile and it should replace Emacs Lisp,
> but this never has taken place really. If you are a bit flexible about
> the language you might like to check lush (which stated goals is for
> "embedding"
> http://lush.sourceforge.net/


Well then, you might also consider ECL : http://ecls.sourceforge.net
which is a nice embeddable CL implementation.

--
__Pascal Bourguignon__ http://www.informatimago.com/

ADVISORY: There is an extremely small but nonzero chance that,
through a process known as "tunneling," this product may
spontaneously disappear from its present location and reappear at
any random place in the universe, including your neighbor's
domicile. The manufacturer will not be responsible for any damages
or inconveniences that may result.
Reply With Quote
  #5  
Old 08-25-2008, 06:24 PM
Blake McBride
Guest
 
Default Re: Best scheme for embedding in C?

Neil Baylis wrote:
> Hi,
>
> which would be the best scheme implementation for embedding in a C
> program. I think what I need is a scheme that is provided as a library
> that I can link with the rest of my app. But main() will be in the C
> application, not in the scheme library. I would want to be able to
> create scheme functions callable from the C application. I would also
> need to call C functions from scheme.
>
> I think maybe guile does all this, but was wondering if there were any
> others out there that can work this way. It would need to work on
> Linux x86 and OSX x86.
>
> Thanks,
>
> Neil



I have used plt-scheme (MzScheme) in the past to do exactly what you are
stating. I was able to call C to Scheme, then back to C, then back to
Scheme to many levels of recursion without any problems. It worked well
and was easy to do. The only problem I seem to remember is that I was
unable to get it to work with native threads.

Blake McBride
Reply With Quote
  #6  
Old 08-26-2008, 08:33 AM
asandroq
Guest
 
Default Re: Best scheme for embedding in C?

Hallo,

On Aug 24, 10:39*pm, Neil Baylis <neil.bay...@gmail.com> wrote:
> Hi,
>
> which would be the best scheme implementation for embedding in a C
> program. I think what I need is a scheme that is provided as a library
> that I can link with the rest of my app. But main() will be in the C
> application, not in the scheme library. I would want to be able to
> create scheme functions callable from the C application. I would also
> need to call C functions from scheme.
>


I am currently using Gambit-C for this. You can call C functions
from Scheme, Scheme functions from C etc.

-alex
Reply With Quote
  #7  
Old 08-26-2008, 11:41 AM
Neil Baylis
Guest
 
Default Re: Best scheme for embedding in C?

On Aug 26, 5:33*am, asandroq <asand...@gmail.com> wrote:
> Hallo,
>
> On Aug 24, 10:39*pm, Neil Baylis <neil.bay...@gmail.com> wrote:
>
> > Hi,

>
> > which would be the best scheme implementation for embedding in a C
> > program. I think what I need is a scheme that is provided as a library
> > that I can link with the rest of my app. But main() will be in the C
> > application, not in the scheme library. I would want to be able to
> > create scheme functions callable from the C application. I would also
> > need to call C functions from scheme.

>
> * * *I am currently using Gambit-C for this. You can call C functions
> from Scheme, Scheme functions from C etc.
>
> -alex


I'm finding that when I link against the gambit runtime, I get
duplicate definitions of main(). Is it possible to make a gambit
runtime library that doesn't declare main()?
Reply With Quote
  #8  
Old 08-26-2008, 11:44 AM
Neil Baylis
Guest
 
Default Re: Best scheme for embedding in C?

On Aug 24, 10:58*pm, namekuseijin <namekusei...@gmail.com> wrote:
> On 24 ago, 22:39, Neil Baylis <neil.bay...@gmail.com> wrote:
>
>
>
> > Hi,

>
> > which would be the best scheme implementation for embedding in a C
> > program. I think what I need is a scheme that is provided as a library
> > that I can link with the rest of my app. But main() will be in the C
> > application, not in the scheme library. I would want to be able to
> > create scheme functions callable from the C application. I would also
> > need to call C functions from scheme.

>
> > I think maybe guile does all this, but was wondering if there were any
> > others out there that can work this way. It would need to work on
> > Linux x86 and OSX x86.

>
> > Thanks,

>
> > Neil

>
> Have you looked at tinyscheme? *Not quite R5RS-compatible, let alone
> R6RS, but a fine and lightweight Scheme terp.
>
> http://tinyscheme.sourceforge.net/home.html


This looks like a possibility, thanks. I would prefer a compiler, but
this might work for me.
Reply With Quote
  #9  
Old 08-26-2008, 02:12 PM
Neil Baylis
Guest
 
Default Re: Best scheme for embedding in C?

Just a clarification of what I'm trying to accomplish...

I'm trying to understand how one would write a plugin in scheme (or
CL). For example, a screensaver, a firefox plugin, an itunes plugin,
or a photoshop plugin.

The plugin needs to export an entry point that the main app calls.
This will be with c calling conventions. During this call, the plugin
initializes itself, allocates memory, etc. It obtains pointers to
functions it must call, and provides pointers to functions that the
main app can call. Maybe they pass c structs between them.

However: the main app is already linked, and has its own main() entry
point. To provide a plugin, you don't link against the main app.
Instead, it discovers your plugin at runtime (by searching some well
known path), and calls your exported entry point.
Reply With Quote
  #10  
Old 08-26-2008, 03:09 PM
asandroq
Guest
 
Default Re: Best scheme for embedding in C?

On Aug 26, 12:41*pm, Neil Baylis <neil.bay...@gmail.com> wrote:
>
> I'm finding that when I link against the gambit runtime, I get
> duplicate definitions of main(). Is it possible to make a gambit
> runtime library that doesn't declare main()?


You must compile the C sources Gambit-C generates with ___LIBRARY
defined (-D___LIBRARY). For a complete example, look for the `pthread'
example in Gambit-C source package.

-alex
Reply With Quote
Reply


Thread Tools
Display Modes


All times are GMT -5. The time now is 08:28 PM.


Powered by vBulletin® Version 3.7.2
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.2.0
vB Ad Management by =RedTyger=

In an effort to better serve ads to our visitors, cookies are used on objectmix.com. For more information, check out our Privacy Policy.