From a8da72937ff4d04e8d39531773cc05e676b2be1c Mon Sep 17 00:00:00 2001
From: Mark H Weaver m...@netris.org
Date: Wed, 4 Jan 2012 17:59:27 -0500
Subject: [PATCH] Fix bugs related to mutation-sharing substrings
* libguile/strings.c (scm_i_is_narrow_string, scm_i_try_narrow_string,
Bruce Korb bk...@gnu.org writes:
Fail early and fail hard. Yes. But after all these discussions, I
now doubt I have too many places where I am expecting to change a
static value.
That's good news! :)
Most of the strings that I wind up altering are created with a
scm_from_locale_string() C
On 01/07/12 08:13, Mark H Weaver wrote:
Most of the strings that I wind up altering are created with a
scm_from_locale_string() C function call.
BTW, beware that scm_from_locale_string() is only appropriate for
strings that came from the user (e.g. command-line arguments, reading
from a port,
Bruce Korb bk...@gnu.org writes:
On 01/07/12 08:13, Mark H Weaver wrote:
Most of the strings that I wind up altering are created with a
scm_from_locale_string() C function call.
BTW, beware that scm_from_locale_string() is only appropriate for
strings that came from the user (e.g.
Bruce Korb bk...@gnu.org writes:
On 01/07/12 08:13, Mark H Weaver wrote:
Most of the strings that I wind up altering are created with a
scm_from_locale_string() C function call.
BTW, beware that scm_from_locale_string() is only appropriate for
strings that came from the user (e.g.
Replying to myself...
Again, I stress that this has nothing to do with Guile. All software,
if it wishes to be properly internationalized, needs to think about
where a string came from. In general, your program's source code (and
thus the C string literals it contains) will have a different
Mark H Weaver m...@netris.org writes:
As I understand it, in the Scheme standards (at least before R6RS's
immutable pairs) the rationale behind marking literal constants as
immutable is solely to avoid needlessly making copies of those literals,
while flagging accidental attempts to modify
From: Mark H Weaver m...@netris.org
It is curious that action of 'copy' really means the
action of 'create a copy with different properties'.
Shouldn't (string-copy a) create another immutable string?
Why would you want to copy an immutable string?
Likewise, shouldn't (substring
Mike Gran spk...@yahoo.com writes:
There is an obvious syntax to construct a string immutable
object: namely to have it appear as a literal in the source code.
There thus isn't a need for a constructor function.
Huh? There are _lots_ of strings which are better computed than spelled
out.
Mike Gran spk...@yahoo.com writes:
The word 'string' in Scheme is overloaded to mean both string
immutables and string mutables. Since a string immutable
can't be modified to be a mutable, they really are different
object types. String mutables appear to still exist in the
latest draft of
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
Bruce Korb bk...@gnu.org 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
Bruce Korb bk...@gnu.org writes:
So because it might be the case that one reference might want to
see changes made via another reference then the whole concept is
trashed? all or nothing? Anyway, such a concept should be kept
very simple: functions that modify their argument make copies of
Bruce Korb bk...@gnu.org writes:
On 01/04/12 16:01, Ludovic Courtès wrote:
BTW, were you able to find a stripped-down example that reproduces the
‘string-upcase’ problem?
Here's the stripped down example, but it does not reproduce the problem. :(
I didn't copy into it my variation on
Bruce Korb bk...@gnu.org writes:
On 01/04/12 15:59, Mark H Weaver wrote:
Implementing copy-on-write transparently without the user explicitly
making a copy (that is postponed) is _impossible_. The problem is that
although we could make a new copy of the string, we have no way to know
which
Bruce Korb bk...@gnu.org writes:
Anyway, such a concept should be kept
very simple: functions that modify their argument make copies of
any input argument that is read only. Any other SCM's lying about
that refer to the unmodified object continue referring to that
same unmodified object.
`define' merely makes a new reference to an existing object. If you
want a copy, you must explicitly ask for one (though this could be
hidden by custom syntax). It would not be desirable for the language to
make copies automatically as part of the core `define' syntax. For one
thing,
Mike Gran spk...@yahoo.com writes:
It is curious that action of 'copy' really means the
action of 'create a copy with different properties'.
Shouldn't (string-copy a) create another immutable string?
Why would you want to copy an immutable string?
Likewise, shouldn't (substring abc 1)
Hello all,
I must admit that I do not know much about why R5RS says that literals
are constant, but I think there is a misunderstanding.
Bruce does not want `define' to always copy its result. I think what
he wants is for literals embedded in source code to be mutable. This
would, of course,
Mike Gran spk...@yahoo.com writes:
In many systems it is desirable for constants (i.e. the values of literal
expressions) to reside in read-only-memory. To express this, it is
convenient to imagine that every object that denotes locations is
associated with a flag telling whether
Bruce Korb bruce.k...@gmail.com writes:
2. it is completely, utterly wrong to mutilate the
Guile library into such a contortion that it
interprets this:
(define y hello)
to be a request to create an immutable string anyway.
It very, very plainly says, make 'y' and
From: Mark H Weaver m...@netris.org
No, `define' does not copy an object, it merely makes a new reference to
an existing object. This is also true in C for that matter, so this is
behavior is quite mainstream. For example, the following program dies
with SIGSEGV on most modern systems,
Mike Gran spk...@yahoo.com writes:
If you follow that logic, then Guile is left without any shorthand
to create and initialize a mutable string other than
(define y (substring hello 0))
or
(define y (string-copy hello))
Sure. Guile does not have shorthands for _mutable_ literals for
On Wed 04 Jan 2012 12:16, Bruce Korb bk...@gnu.org writes:
We could add a compiler option to turn string literals into (string-copy
FOO). Perhaps that's the thing to do.
No, because your clients have no control over how Guile gets built.
We _do_ have control over startup code, however:
I
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
Bruce Korb bk...@gnu.org writes:
On 01/04/12 04:19, Ian Price wrote:
... As for mutable strings, I consider them
a mistake to begin with,...
Let's step back and consider the whole point of Guile in the first place.
My understanding is that one primary purpose is to be a facilitation
Bruce Korb bruce.k...@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
Andy Wingo wi...@pobox.com writes:
On Wed 04 Jan 2012 12:14, David Kastrup d...@gnu.org writes:
Andy Wingo wi...@pobox.com writes:
We could add a compiler option to turn string literals into
(string-copy FOO). Perhaps that's the thing to do.
What for? It would mean that a literal would
Andy Wingo wi...@pobox.com writes:
David Kastrup d...@gnu.org 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
On 01/04/12 11:43, Andy Wingo wrote:
The correct behavior is the status quo. We are considering adding a
hack to produce different behavior for compatibility purposes. We don't
have to worry about correctness in that case, only compatibility. IMO
anyway :)
It would be a nice added benefit
Bruce Korb bruce.k...@gmail.com writes:
On 01/04/12 11:43, Andy Wingo wrote:
The correct behavior is the status quo. We are considering adding a
hack to produce different behavior for compatibility purposes. We don't
have to worry about correctness in that case, only compatibility. IMO
Bruce Korb bruce.k...@gmail.com writes:
Who knows where I learned the idiom. I learned the minimal amount of
Guile needed for my purposes a dozen years ago. My actual problem
stems from this:
Backtrace:
In ice-9/boot-9.scm:
170: 3 [catch #t #catch-closure 8b75a0 ...]
In unknown file:
Bruce Korb bk...@gnu.org writes:
On 01/04/12 04:19, Ian Price wrote:
... As for mutable strings, I consider them
a mistake to begin with,...
Let's step back and consider the whole point of Guile in the first place.
This was not intended as an answer to this question, nor to be
Bruce Korb bk...@gnu.org writes:
You have to go to some extra trouble to be certain that a string
value that you have assigned to an SCM is not read only.
If you're going to mutate a string, you'd better be safe and make a copy
before mutating it, unless you know very clearly where it came
Bruce Korb bk...@gnu.org writes:
On 01/04/12 13:52, Ian Price wrote:
So my main question is:
Which is the higher priority, language purity or ease of use?
That is a loaded question, as it presupposes ease of use is always the
same thing as impurity e.g. ...
Absolutely not. Making
Hi Bruce,
And happy new year!
Bruce Korb bruce.k...@gmail.com skribis:
Thank you for the explanation. However:
On 01/03/12 07:03, Mike Gran wrote:
It worked until I upgraded to openSuSE 12.1.
$ guile --version
guile (GNU Guile) 2.0.2
.
(set! tmp-text (get act-text))
On 01/03/12 14:24, Ludovic Courtès wrote:
2. it is completely, utterly wrong to mutilate the
Guile library into such a contortion that it
interprets this:
(define y hello)
to be a request to create an immutable string anyway.
It very, very plainly says, make 'y' and
In many systems it is desirable for constants (i.e. the values of literal
expressions) to reside in read-only-memory. To express this, it is
convenient to imagine that every object that denotes locations is
associated with a flag telling whether that object is mutable or immutable.
Hello,
Then it turned out that the string functions would now clear the
high order bit on strings, so they are no longer byte arrays and
there is no replacement but to roll my own. I stopped supporting
byte arrays. A noticable nuisance.
This is just a side note to the main discussion, but
39 matches
Mail list logo