[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: Alex Shinn
Subject: Re: Gurus? Care to re-explain the absense of gh_set_x() for me?
Date: 13 Jul 2001 11:29:11 -0400
User-agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.0.103

>>>>> "Sam" == Sam Tregar <address@hidden> writes:

    Sam> On Fri, 13 Jul 2001, Thien-Thi Nguyen wrote:
    >> what's wrong w/:
    >> SCM a; a = scm_sum (a, SCM_INUM (10));

    Sam> If something was pointing to a before the += then it is no
    Sam> longer pointing to a since scm_sum will return a new SCM.
    Sam> Consider a globally bound variable or an item in a list.

If what was pointing to a?  In Perl, you probably just want to point
to the same Perl value, which contains an SCM.  Mutating functions
would then just bind this to a new SCM.

The trick seems to be that you want for a Perl variable to stand for a
Guile variable, and have changes in Perl be reflected in Guile.  But
numbers in Guile are immutable, so even if you had:

  (define foo 5)
  (define bar foo)
  (+= bar 1)

bar would be 6, but foo would still be 5.  So Perl can work with
SCM's, and if you want Perl can define/set values in Guile, but you're
probably trying to do the wrong thing if you want

  $foo += 1;

in Perl to modify an existing Scheme variable.

Alex Shinn <address@hidden>

reply via email to

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