This is the mail archive of the guile@cygnus.com mailing list for the guile project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

embedding question: defining symbols?


Hail to the People Of Guile,

I have a question:

I have a C++ program, where various structures contain scopes, eg.

        class Bla {
                Dictionary<Identifier*> dict_;

                double some_user_defined_value ()
                {
                        Identifier *id =dict_.lookup ("user_defined_id_name");
                        return id->to_double();
                }
        };

I would like to use Guile symbols, lookup and typing functions to
replace my home-brewn junk.  How do I do this?  Ideally, the above
code would transform to something like

        SCM str2symbol (const char *S); /* intern S */

        class Bla
        {
                SCM my_env_;

                double some_user_defined_value ()
                {
                        static SCM my_symbol =
                          scm_protect (str2symbol ("user_defined_id_name"))
                        return scm2double (scm_lookup_var (my_symbol));
                }
        }

If I have understood SICP correctly, I would somehow have to associate
an environment with every instance of Bla, but how would I do this?


-- 

Han-Wen Nienhuys, hanwen@cs.uu.nl ** GNU LilyPond - The Music Typesetter 
      http://www.cs.uu.nl/people/hanwen/lilypond/index.html