From: Ian Price <ianprice90@googlemail.com>
To: Bruce Korb <bruce.korb@gmail.com>
Cc: "guile-devel@gnu.org" <guile-devel@gnu.org>
Subject: Re: Guile: What's wrong with this?
Date: Wed, 04 Jan 2012 18:26:00 +0000 [thread overview]
Message-ID: <87k457z5mv.fsf@Kagami.home> (raw)
In-Reply-To: <4F048CBB.9020903@gmail.com> (Bruce Korb's message of "Wed, 04 Jan 2012 09:30:35 -0800")
Bruce Korb <bruce.korb@gmail.com> writes:
> On 01/04/12 08:47, Andy Wingo wrote:
>> I was going to propose a workaround with an option to change
>> vm-i-loader.c:43 and vm-i-loader.c:115 to use a
>> scm_i_mutable_string_literals_p instead of 1, but that really seems like
>> the path to perdition: previously compiled modules would start creating
>> mutable strings where they really shouldn't.
>
> Instead, long-standing, previously written code was invalidated with 1.9,
long-standing, previously written _buggy_ code.
> even if we were not smacked down until 2.0.1.
>
> Just because an obscure-to-those-not-living-and-breathing-Scheme-daily
> document said it was okay doesn't make it okay to those whacked by it.
There's an old saying, "Ignorance of the law is no excuse". If I wrote C
code that doesn't conform to the C standard and depended on
implementation specific behaviour, I have no recourse if it breaks on a
different compiler. Guile explicitly claims to conform to the r5rs (and
partially to the r6rs), both of which make this behaviour undefined, and
srfi 13 explicitly makes this an error. (And FWIW I would not consider
the R5RS obscure to people who have used scheme for even a short while,
nor is it a terrific burden to read at 50 pages)
Now, if you want to argue your position, it'd be better to argue that
guile goes beyond r[56]rs in making these promises with regards to strings.
For instance, substring-fill! as found at
https://www.gnu.org/software/guile/manual/html_node/String-Modification.html
implies that string literals are mutable
— Scheme Procedure: substring-fill! str start end fill
— C Function: scm_substring_fill_x (str, start, end, fill)
Change every character in str between start and end to fill.
(define y "abcdefg")
(substring-fill! y 1 3 #\r)
y
⇒ "arrdefg"
So too does string-upcase!
(https://www.gnu.org/software/guile/manual/html_node/Alphabetic-Case-Mapping.html),
if we assume y is the same binding in both functions
— Scheme Procedure: string-upcase! str [start [end]]
— C Function: scm_substring_upcase_x (str, start, end)
— C Function: scm_string_upcase_x (str)
Destructively upcase every character in str.
(string-upcase! y)
⇒ "ARRDEFG"
y
⇒ "ARRDEFG"
The same goes for string-downcase! and string-capitalize!
I think it would be fair to say that someone could surmise that literal
strings are meant to be mutable from these examples, and, if we do go
down the immutable string literal route these examples would need to be
addressed.
On the other hand, you can argue that string literal immutability is
implied by
— Scheme Procedure: string-for-each-index proc s [start [end]]
— C Function: scm_string_for_each_index (proc, s, start, end)
Call (proc i) for each index i in s, from left to right.
For example, to change characters to alternately upper and lower case,
p
(define str (string-copy "studly"))
(string-for-each-index
(lambda (i)
(string-set! str i
((if (even? i) char-upcase char-downcase)
(string-ref str i))))
str)
str ⇒ "StUdLy"
but on a purely numerical basis, mutability 4 - 0 immutability
> I would think recompiling should not be a great burden, *ESPECIALLY*
At this stage, I think that argument is fair enough, other people's
mileage may vary.
--
Ian Price
"Programming is like pinball. The reward for doing it well is
the opportunity to do it again" - from "The Wizardy Compiled"
next prev parent reply other threads:[~2012-01-04 18:26 UTC|newest]
Thread overview: 117+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-01-03 4:08 What's wrong with this? Bruce Korb
2012-01-03 15:03 ` Mike Gran
2012-01-03 16:26 ` Guile: " Bruce Korb
2012-01-03 16:30 ` Mike Gran
2012-01-03 22:24 ` Ludovic Courtès
2012-01-03 23:15 ` Bruce Korb
2012-01-03 23:33 ` Ludovic Courtès
2012-01-04 0:55 ` Bruce Korb
2012-01-04 3:12 ` Noah Lavine
2012-01-04 17:37 ` bytevector -- was: " Bruce Korb
2012-01-04 21:17 ` Ludovic Courtès
2012-01-04 22:36 ` Bruce Korb
2012-01-05 0:01 ` Ludovic Courtès
2012-01-05 18:36 ` non-reproduction of initial issue -- was: " Bruce Korb
2012-01-05 18:50 ` Mark H Weaver
2012-01-04 12:19 ` Ian Price
2012-01-04 17:16 ` Bruce Korb
2012-01-04 17:21 ` Andy Wingo
2012-01-04 17:39 ` David Kastrup
2012-01-04 21:52 ` Ian Price
2012-01-04 22:18 ` Bruce Korb
2012-01-04 23:22 ` Mike Gran
2012-01-04 23:59 ` Mark H Weaver
2012-01-05 17:22 ` Bruce Korb
2012-01-05 18:13 ` Mark H Weaver
2012-01-05 19:02 ` Mark H Weaver
2012-01-05 20:24 ` David Kastrup
2012-01-05 22:42 ` Mark H Weaver
2012-01-06 1:02 ` Mike Gran
2012-01-06 1:41 ` Mark H Weaver
2012-01-06 2:38 ` Noah Lavine
2012-01-06 13:37 ` Mike Gran
2012-01-06 14:11 ` David Kastrup
2012-01-06 18:13 ` Mark H Weaver
2012-01-06 19:06 ` Bruce Korb
2012-01-06 19:19 ` David Kastrup
2012-01-06 20:03 ` Mark H Weaver
2012-01-07 16:13 ` Mark H Weaver
2012-01-07 17:35 ` mutable interfaces - was: " Bruce Korb
2012-01-07 17:47 ` David Kastrup
2012-01-07 18:30 ` Mark H Weaver
2012-01-07 18:55 ` Mark H Weaver
2012-01-06 22:23 ` Guile BUG: " Bruce Korb
2012-01-06 23:11 ` Mark H Weaver
2012-01-06 23:35 ` Andy Wingo
2012-01-06 23:41 ` Bruce Korb
2012-01-07 15:00 ` Mark H Weaver
2012-01-07 15:27 ` Bruce Korb
2012-01-07 16:38 ` Mark H Weaver
2012-01-07 17:39 ` Bruce Korb
2012-01-09 15:41 ` Mark H Weaver
2012-01-09 17:27 ` Bruce Korb
2012-01-09 18:32 ` Andy Wingo
2012-01-09 19:48 ` Bruce Korb
2012-01-07 15:47 ` David Kastrup
2012-01-07 17:07 ` Mark H Weaver
2012-01-07 14:35 ` Mark H Weaver
2012-01-07 15:20 ` Mike Gran
2012-01-07 22:25 ` Ludovic Courtès
2012-01-10 9:13 ` The empty string and other empty strings Ludovic Courtès
2012-01-10 11:28 ` Mike Gran
2012-01-10 13:03 ` Mark H Weaver
2012-01-10 13:09 ` Mike Gran
2012-01-10 15:41 ` Mark H Weaver
2012-01-10 15:48 ` David Kastrup
2012-01-10 16:15 ` Mark H Weaver
2012-01-12 22:33 ` Ludovic Courtès
2012-01-13 9:27 ` David Kastrup
2012-01-13 16:39 ` Mark H Weaver
2012-01-13 17:36 ` David Kastrup
2012-01-16 8:26 ` Marijn
2012-01-16 8:47 ` David Kastrup
2012-01-20 21:31 ` Andy Wingo
2012-01-10 14:10 ` David Kastrup
2012-01-10 12:21 ` Mike Gran
2012-01-10 12:27 ` Mark H Weaver
2012-01-10 16:34 ` Ludovic Courtès
2012-01-10 17:04 ` David Kastrup
2012-01-06 23:28 ` Guile BUG: What's wrong with this? Bruce Korb
2012-01-07 20:57 ` Guile: " Ian Price
2012-01-08 5:05 ` Mark H Weaver
2012-01-06 9:23 ` David Kastrup
2012-01-05 7:22 ` David Kastrup
2012-01-04 22:46 ` Ludovic Courtès
2012-01-04 3:04 ` Mike Gran
2012-01-04 9:35 ` nalaginrut
2012-01-04 9:41 ` David Kastrup
2012-01-04 21:07 ` Ludovic Courtès
2012-01-04 10:03 ` Mark H Weaver
2012-01-04 14:29 ` Mike Gran
2012-01-04 14:45 ` David Kastrup
2012-01-04 16:47 ` Andy Wingo
2012-01-04 17:14 ` David Kastrup
2012-01-04 17:32 ` Andy Wingo
2012-01-04 17:49 ` David Kastrup
2012-01-04 18:09 ` Andy Wingo
2012-01-04 17:30 ` Bruce Korb
2012-01-04 17:44 ` David Kastrup
2012-01-04 18:26 ` Ian Price [this message]
2012-01-04 18:48 ` Mark H Weaver
2012-01-04 19:29 ` Bruce Korb
2012-01-04 20:20 ` David Kastrup
2012-01-04 23:19 ` Mark H Weaver
2012-01-04 23:28 ` Bruce Korb
2012-01-07 15:43 ` Fixed string corruption bugs (was Guile: What's wrong with this?) Mark H Weaver
2012-01-07 16:19 ` Fixed string corruption bugs Andy Wingo
2012-01-04 18:31 ` Guile: What's wrong with this? Mark H Weaver
2012-01-04 18:43 ` Andy Wingo
2012-01-04 19:29 ` Mark H Weaver
2012-01-04 19:43 ` Andy Wingo
2012-01-04 20:08 ` Bruce Korb
2012-01-04 20:14 ` David Kastrup
2012-01-04 20:56 ` Andy Wingo
2012-01-04 21:30 ` Bruce Korb
2012-01-04 17:19 ` Mark H Weaver
2012-01-05 4:24 ` Mark H Weaver
2012-01-04 22:37 ` Ludovic Courtès
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/guile/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87k457z5mv.fsf@Kagami.home \
--to=ianprice90@googlemail.com \
--cc=bruce.korb@gmail.com \
--cc=guile-devel@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).