[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: |
Matthias Koeppe |
Subject: |
Re: Gurus? Care to re-explain the absense of gh_set_x() for me? |
Date: |
Fri, 13 Jul 2001 17:01:27 +0200 |
User-agent: |
Gnus/5.090004 (Oort Gnus v0.04) Emacs/20.6 |
Sam Tregar <address@hidden> 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?
Have I understood you correctly: You have Perl variables, $foo and
$bar say, each of which hold one SCM object. For instance, $foo holds
an SCM representing the integer 1, and $bar holds an SCM representing
2. Now you do $foo += $bar, and you expect $foo to hold a SCM
representing the integer 3?
Again, there is no Scheme function (+= FOO BAR) which could accomplish
that because you pass the *value* FOO, and integer (and other
immediate) values cannot be mutated. You need to pass the *location*
of FOO in some way. I seem to have understood that FOO and BAR aren't
actually Scheme variables (whether local or global) but "boxes" with
SCM content that reside on the Perl side; so my original macro
suggestion doesn't help. You should simply reify your boxes on the
Scheme side and provide functions like (BOX-REF BOX) and (BOX-SET! BOX
VALUE) in order to access them.
--
Matthias Köppe -- http://www.math.uni-magdeburg.de/~mkoeppe
- Re: Gurus? Care to re-explain the absense of gh_set_x() for me?, (continued)
- Re: Gurus? Care to re-explain the absense of gh_set_x() for me?, Miroslav Silovic, 2001/07/15
- Re: Gurus? Care to re-explain the absense of gh_set_x() for me?, Matthias Koeppe, 2001/07/13
- Re: Gurus? Care to re-explain the absense of gh_set_x() for me?, Sam Tregar, 2001/07/13
- Re: Gurus? Care to re-explain the absense of gh_set_x() for me?, Brett Viren, 2001/07/13
- Re: Gurus? Care to re-explain the absense of gh_set_x() for me?, Sam Tregar, 2001/07/13
- Re: Gurus? Care to re-explain the absense of gh_set_x() for me?, tom, 2001/07/13
- Re: Gurus? Care to re-explain the absense of gh_set_x() for me?,
Matthias Koeppe <=
- Re: Gurus? Care to re-explain the absense of gh_set_x() for me?, Sam Tregar, 2001/07/13
- Re: Gurus? Care to re-explain the absense of gh_set_x() for me?, Matthias Koeppe, 2001/07/13
- Re: Gurus? Care to re-explain the absense of gh_set_x() for me?, Sam Tregar, 2001/07/13
- Re: Gurus? Care to re-explain the absense of gh_set_x() for me?, Klaus Schilling, 2001/07/13
- Re: Gurus? Care to re-explain the absense of gh_set_x() for me?, Alex Shinn, 2001/07/13
- Re: Gurus? Care to re-explain the absense of gh_set_x() for me?, rm, 2001/07/14
- Re: Gurus? Care to re-explain the absense of gh_set_x() for me?, Alex Shinn, 2001/07/14
- Re: Gurus? Care to re-explain the absense of gh_set_x() for me?, Thomas Bushnell, BSG, 2001/07/13
- Re: Gurus? Care to re-explain the absense of gh_set_x() for me?, Thien-Thi Nguyen, 2001/07/14
- Re: Gurus? Care to re-explain the absense of gh_set_x() for me?, Martin Grabmueller, 2001/07/14