[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: |
Neil Jerram |
Subject: |
Re: Gurus? Care to re-explain the absense of gh_set_x() for me? |
Date: |
14 Jul 2001 22:47:15 +0100 |
User-agent: |
Gnus/5.0808 (Gnus v5.8.8) Emacs/20.7 |
>>>>> "Sam" == Sam Tregar <address@hidden> writes:
Sam> On 13 Jul 2001, Alex Shinn wrote:
>> Hmmm... not sure what the implications of directly changing the
>> SCM struct contents would be, and whether this might break
>> things in Guile.
Sam> This is roughly what I was expecting the non-existent
Sam> gh_set_x() to do - change the value stored in an SCM without
Sam> otherwise disturbing its identity.
For a SCM that directly holds an integer value, this is fundamentally
impossible in Guile. For small integers, the SCM value *is* the
integer value, give or take some flag bits to indicate that we're
talking about small integers.
In other words, if the SCM value for the number 3 is 0x11000003, the
SCM value for the number 13 is 0x1100000d. So you can't "change the
value stored in a SCM without otherwise disturbing its identity".
What you _can_ do is the single-element vector trick. You set your
SCM to a single-element vector -- see gh_make_vector -- and then
access and mutate the value stored in that vector's element using
gh_vector_ref and gh_vector_set_x. (Or you could use a pair, and
access/mutate using gh_car/gh_set_car_x.)
FWIW, the identical trick is often used in Java: where you need to
store a mutable integer as an Object, you do it by creating an int[1].
Neil
- 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?, Thien-Thi Nguyen, 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?, Alex Shinn, 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?, Alex Shinn, 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?, Eric E Moore, 2001/07/13
- Re: Gurus? Care to re-explain the absense of gh_set_x() for me?, Rob Browning, 2001/07/13
- 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?, Rob Browning, 2001/07/16
- Re: Gurus? Care to re-explain the absense of gh_set_x() for me?,
Neil Jerram <=
- 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?, Neil Jerram, 2001/07/16
- 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, 2001/07/13
- Re: Gurus? Care to re-explain the absense of gh_set_x() for me?, Sam Tregar, 2001/07/13