[Top][All Lists]

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

Re: Gurus? Care to re-explain the absense of gh_set_x() for me?

From: Brett Viren
Subject: Re: Gurus? Care to re-explain the absense of gh_set_x() for me?
Date: Fri, 13 Jul 2001 10:58:41 -0400 (EDT)

Sam Tregar writes:
 > On Fri, 13 Jul 2001, Matthias Koeppe wrote:
 > > You should not attempt to code this as a C function.  += is not simply
 > > a new procedure but needs to be a *special form* (i.e., a new syntax).
 > > So I suggest you make a macro that expands (+= A B) into (SET! A (PLUS
 > > A B)) and bind it to `+='.  In Scheme, this is easily done with
 > > DEFINE-MACRO; if you insist in doing this from the C level, try your
 > > luck with the functions in `macro.h'.  Then implement PLUS as a C
 > > function that simply computes the desired value.
 > Let me explain more about what I'm doing.  I'm writing a Perl module
 > called Inline::Guile.  One part of this project is an overloaded Perl
 > object that will represent a Guile SCM.  To build an overloaded object in
 > Perl you need to define functions for each of Perl's operators, +=
 > included.  These operator functions can be written in Perl or in C but
 > obviously not in Guile.
 > Does that make it clear why a macro won't suffice?

As a non-guru, I would none-the-less say that it isn't so obvious why
you can't use a scheme macro.  

You will need to link in libguile to perl to allow Inline::Guile,
(right?), so you will have all the features of guile.  In your
initialization phase, you just need to call gh_eval_str("...") with
the suggested macro to define += in the scheme world.  You could then
write a C wrapper or just use gh_call/gh_apply from the overloaded
Perl imp of "+=".

Unless I miss something....


reply via email to

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