[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Guile: What's wrong with this?
From: |
Mark H Weaver |
Subject: |
Re: Guile: What's wrong with this? |
Date: |
Wed, 04 Jan 2012 14:29:25 -0500 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/24.0.92 (gnu/linux) |
Andy Wingo <address@hidden> writes:
>> David Kastrup <address@hidden> writes:
>>> What for? It would mean that a literal would not be eq? to itself, a
>>> nightmare for memoization purposes.
>>
>> I agree that it should not be the default behavior, but I don't see the
>> harm in allowing users to compile their own code this way.
>
> Well, we can fix this too: we can make
>
> "foo"
>
> transform to
>
> (copy-once UNIQUE-GENSYM str)
>
> with
>
> (define (copy-once key str)
> (or (hashq-ref mutable-string-literals key)
> (let ((value (string-copy str)))
> (hashq-set! mutable-string-literals key value)
> value)))
Although this is a closer emulation of the previous (broken) behavior,
IMHO this would be less desirable than simply doing (string-copy "foo")
on every evaluation of "foo", which seems to be what Bruce (and probably
others) expected "foo" to do.
For example, based on the mental model that Bruce apparently had when he
wrote his code, he might have written something like this:
(define (hello-world-with-one-char-changed i c)
(define str "Hello world")
(string-set! str i c)
str)
Your UNIQUE-GENSYM hack emulates the previous behavior that makes the
above procedure buggy. Simply changing "hello" to (string-copy "hello")
would make the procedure work, and I believe conforms better to what
Bruce expects.
Of course, I'm only talking about what I think should be done when the
compiler option is changed to non-default behavior. I strongly believe
that the _default_ behavior should stay as it is now.
Mark
- Re: Guile: What's wrong with this?, (continued)
- Re: Guile: What's wrong with this?, Ian Price, 2012/01/04
- Re: Guile: What's wrong with this?, Mark H Weaver, 2012/01/04
- Re: Guile: What's wrong with this?, Bruce Korb, 2012/01/04
- Re: Guile: What's wrong with this?, David Kastrup, 2012/01/04
- Re: Guile: What's wrong with this?, Mark H Weaver, 2012/01/04
- Re: Guile: What's wrong with this?, Bruce Korb, 2012/01/04
- Re: Fixed string corruption bugs (was Guile: What's wrong with this?), Mark H Weaver, 2012/01/07
- Re: Fixed string corruption bugs, Andy Wingo, 2012/01/07
- Re: Guile: What's wrong with this?, Mark H Weaver, 2012/01/04
- Re: Guile: What's wrong with this?, Andy Wingo, 2012/01/04
- Re: Guile: What's wrong with this?,
Mark H Weaver <=
- Re: Guile: What's wrong with this?, Andy Wingo, 2012/01/04
- Re: Guile: What's wrong with this?, Bruce Korb, 2012/01/04
- Re: Guile: What's wrong with this?, David Kastrup, 2012/01/04
- Re: Guile: What's wrong with this?, Andy Wingo, 2012/01/04
- Re: Guile: What's wrong with this?, Bruce Korb, 2012/01/04
- Re: Guile: What's wrong with this?, Mark H Weaver, 2012/01/04
- Re: Guile: What's wrong with this?, Mark H Weaver, 2012/01/04
- Re: Guile: What's wrong with this?, Ludovic Courtès, 2012/01/04