[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Guile: What's wrong with this?
From: |
David Kastrup |
Subject: |
Re: Guile: What's wrong with this? |
Date: |
Fri, 06 Jan 2012 20:19:00 +0100 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/24.0.92 (gnu/linux) |
Bruce Korb <address@hidden> writes:
> On 01/06/12 10:13, Mark H Weaver wrote:
>> Imagine that you were evaluating Scheme by hand on paper. You have your
>> program written on one page, and you have another scratch page used for
>> the data structures that your program creates during evaluation.
>> Suppose your program contains a very large lookup table, written as a
>> literal list. This lookup table is on your program page.
>>
>> Now, suppose....
>
> That is where my mental model diverges!!
The mental model of the computer is what counts.
>> sprintf(buf, "(define %s \"%s\")", "foo", my_str);
>> scm_eval_string(buf);
>> sprintf(buf, "(string-upcase! %s)", "foo")
>> // the string from my_str in "buf" is now scribbled over and completely gone
>> scm_eval_string(buf);
>
> Since I know the program I initially wrote (the define) is now gone,
Why would a define be gone?
> the string must have been copied off somewhere.
I don't think you understand the concept of garbage collection.
_Everything_ in Scheme exists permanently regarding all observable
semantics (well, weak hash tables are a somewhat weird exception).
Definitions, variables, continuations. There is no concept like a stack
of local values that would get erased. Thanks to call/cc, there is not
even a return stack that would get erased. Every object carries its own
lifetime with it. It dies when nobody remembers it, not because of
being in some scope or whatever else.
> I think one's first guess is that it was copied to someplace
> modifiable. However, that would be incorrect. It is copied off to
> writable memory, but marked as read-only for the purposes of Guile.
> Not intuitively obvious.
Also wrong.
--
David Kastrup
- Re: Guile: What's wrong with this?, (continued)
- Re: Guile: What's wrong with this?, Mark H Weaver, 2012/01/05
- Re: Guile: What's wrong with this?, David Kastrup, 2012/01/05
- Re: Guile: What's wrong with this?, Mark H Weaver, 2012/01/05
- Re: Guile: What's wrong with this?, Mike Gran, 2012/01/05
- Re: Guile: What's wrong with this?, Mark H Weaver, 2012/01/05
- Re: Guile: What's wrong with this?, Noah Lavine, 2012/01/05
- Re: Guile: What's wrong with this?, Mike Gran, 2012/01/06
- Re: Guile: What's wrong with this?, David Kastrup, 2012/01/06
- Re: Guile: What's wrong with this?, Mark H Weaver, 2012/01/06
- Re: Guile: What's wrong with this?, Bruce Korb, 2012/01/06
- Re: Guile: What's wrong with this?,
David Kastrup <=
- Re: Guile: What's wrong with this?, Mark H Weaver, 2012/01/06
- Re: Guile: What's wrong with this?, Mark H Weaver, 2012/01/07
- Re: mutable interfaces - was: Guile: What's wrong with this?, Bruce Korb, 2012/01/07
- Re: mutable interfaces - was: Guile: What's wrong with this?, David Kastrup, 2012/01/07
- Re: mutable interfaces - was: Guile: What's wrong with this?, Mark H Weaver, 2012/01/07
- Re: mutable interfaces - was: Guile: What's wrong with this?, Mark H Weaver, 2012/01/07
- Re: Guile BUG: What's wrong with this?, Bruce Korb, 2012/01/06
- Re: Guile BUG: What's wrong with this?, Mark H Weaver, 2012/01/06
- Re: Guile BUG: What's wrong with this?, Andy Wingo, 2012/01/06
- Re: Guile BUG: What's wrong with this?, Bruce Korb, 2012/01/06