[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: What's wrong with this?
From: |
Mike Gran |
Subject: |
Re: What's wrong with this? |
Date: |
Tue, 3 Jan 2012 07:03:49 -0800 (PST) |
> From: Bruce Korb <address@hidden>
> My "(get ...)" function always returns a string.
> This result was assigned to "tmp-text" and the
> "(string-upcase ...)" is complaining that the input is
> read only. Well, it isn't, so the real complaint
> is being hidden by the "string is read-only" message.
>
> It worked until I "upgraded" to openSuSE 12.1.
>
>> $ guile --version
>> guile (GNU Guile) 2.0.2
>> .....
>
> What is really wrong, please?
>
>>
>> (set! tmp-text (get "act-text"))
>> (set! TMP-text (string-upcase tmp-text))
>> (string-append
>> (if (exist? "no") "no-" "yes-")
>> (get "act-type"))
>
There does seem to be some strangeness w.r.t. read-only
strings going on.
On Guile 1.8.8 if you create a string this way, it is
not read-only.
guile> (define y "hello")
guile> (string-set! y 0 #\x)
guile> y
"xello"
On Guile 2.0.3, if you create a string the same way, it
is read-only for some reason.
scheme@(guile-user)> (define y "hello")
scheme@(guile-user)> (string-set! y 0 #\x)
ERROR: In procedure string-set!:
ERROR: string is read-only: "hello"
%string-dump can be used to confirm this
scheme@(guile-user)> (%string-dump y)
$4 = ((string . "hello") (start . 0) (length . 5)
(shared . #f) (read-only . #t) (stringbuf-chars . "hello")
(stringbuf-length . 5) (stringbuf-shared . #f) (stringbuf-wide . #f))
But if you create a string with 'string' it isn't read only
scheme@(guile-user)> (define y (string #\h #\e #\l #\l #\o))
scheme@(guile-user)> (string-set! y 0 #\x)
scheme@(guile-user)> y
$7 = "xello"
-Mike
- What's wrong with this?, Bruce Korb, 2012/01/02
- Re: What's wrong with this?,
Mike Gran <=
- Re: Guile: What's wrong with this?, Bruce Korb, 2012/01/03
- Re: Guile: What's wrong with this?, Mike Gran, 2012/01/03
- Re: Guile: What's wrong with this?, Ludovic Courtès, 2012/01/03
- Re: Guile: What's wrong with this?, Bruce Korb, 2012/01/03
- Re: Guile: What's wrong with this?, Ludovic Courtès, 2012/01/03
- Re: Guile: What's wrong with this?, Bruce Korb, 2012/01/03
- Re: Guile: What's wrong with this?, Noah Lavine, 2012/01/03
- Re: bytevector -- was: Guile: What's wrong with this?, Bruce Korb, 2012/01/04
- Re: Guile: What's wrong with this?, Ludovic Courtès, 2012/01/04
- Re: Guile: What's wrong with this?, Bruce Korb, 2012/01/04