guile-user
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Embedding guile in a C application.


From: Binesh Bannerjee
Subject: Re: Embedding guile in a C application.
Date: Mon, 31 May 2004 01:54:49 -0400 (EDT)

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On Sun, 30 May 2004, Linas Vepstas wrote:

On Sun, May 30, 2004 at 02:32:56AM -0400, Binesh Bannerjee was heard to remark:
        I'd like to embed a Guile interpreter inside the app,

Try reading some of teh guile tutorials.

In your C code, you'd want to call scm_c_eval_string () to evaluate a
string e.g. scm_c_eval_string ("(define f (lambda (x) (+ 1 x)))");

Nice, thanks!

I actually couldn't find any of the tutorials, but, searching for scm_c_eval_string on google gave me enough direction to move...

I'll attach my code, just in case someone else has the same
question.

Thanks again!
Binesh Bannerjee

        #include <stdio.h>
        #include <libguile.h>

        void inner_main(void *closure,int argc,char **argv) {
                scm_c_eval_string("(define f (lambda (x) (+ 1 x)))");
                SCM s = scm_c_eval_string("(f 5)");
                int q = SCM_INUM(s);
                fprintf(stderr,"%d\n",q);
        }

        int main(int argc,char *argv[]) {
                scm_boot_guile(argc,argv,inner_main,0);
                return(0);
        }

- -- "When Webster's dictionary used a sparrow to stand for all birds, emus and
 ostriches and penguins and eagles did not go on the attack."
        -- "The Blank Slate" -- Steven Pinker

    PGP  Key: http://www.hex21.com/~binesh/binesh-public.asc
PGP Key fingerprint = 421D B4C2 2E96 B8EE 7190  A0CF B42F E71C 7FC3 AD96

    SSH2 Key: http://www.hex21.com/~binesh/binesh-ssh2.pub
OpenSSH  Key: http://www.hex21.com/~binesh/binesh-openssh.pub
BubbleBabble = xibeb-voges-havez-pabaf-debop-cylil-lelyc-viruv-bygeg-zotoh-dixex
 Fingerprint = 9d:7c:84:5d:80:e3:65:8d:ee:9e:a3:b9:56:0a:e9:ad

    SSH1 Key: http://www.hex21.com/~binesh/binesh-ssh1.pub

CipherKnight Seals:
        http://www.hex21.com/~binesh/binesh-seal.tar.bz2.cs256
        http://www.hex21.com/~binesh/binesh-seal.zip.cs256
        http://www.hex21.com/~binesh/binesh-certificate.gif.cs256
        Decrypt with CipherSaber2 N=256, Password="WelcomeJedi!" (No quotes)

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.4 (GNU/Linux)
Comment: pgpenvelope 2.10.2 - http://pgpenvelope.sourceforge.net/

iD8DBQFAusi+tC/nHH/DrZYRAu4CAJ9Y+YjgRVPsiirCA/URW03MVcnTvwCgrGJU
eo8UOkzuHO6ooW0mkT+mhlk=
=Skv4
-----END PGP SIGNATURE-----




reply via email to

[Prev in Thread] Current Thread [Next in Thread]