[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 19:11:07 +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 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.
> Interesting proposal.  It would solve the problem but at a pretty high
> cost in terms of transparency of use.  Ultimately I'd like to have a
> system that makes using Perl and Guile together almost seamless.

I don't think there is a high "cost in terms of transparency" here.
In fact, it would be very non-Schemey (thus non-transparent to Scheme
users) to have variables with an unusual (in this case, Perl-like)

For instance, we have "thread-local variables" (fluids) which are
addressed in much the same way as I suggested for your situation:

If you like, you could also introduce a SRFI-19-style
getter-with-setter like this:

 (define perl-value (getter-with-setter box-ref box-set!))

Then you could do (PERL-VALUE BOX) to get the value and (SET!
(PERL-VALUE BOX) VALUE) to set it.  This also enables the use of
mutating macros like INCREMENT! that work both with normal Scheme
variables and your Perl boxes:

        (define-macro (increment! location)
          `(set! ,location (+ ,location 1)))

        (perl-value x)   => 7
        (increment! (perl-value x))
        (perl-value x)   => 8

(Should I suggest to (DEFINE $ PERL-VALUE) now?  Nah.)

You may also want to have a look at the Guile Emacs project
(  They are posed with pretty much the
same problem as you are; they have to access Emacs Lisp variables from

Matthias Köppe --

reply via email to

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