Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

immutable strings #3544

Closed
vicuna opened this issue Mar 17, 2005 · 1 comment
Closed

immutable strings #3544

vicuna opened this issue Mar 17, 2005 · 1 comment
Assignees

Comments

@vicuna
Copy link

vicuna commented Mar 17, 2005

Original bug ID: 3544
Reporter: administrator
Assigned to: @gasche
Status: closed (set by @xavierleroy on 2016-12-07T10:29:42Z)
Resolution: fixed
Priority: normal
Severity: feature
Fixed in version: 4.02.0
Category: ~DO NOT USE (was: OCaml general)

Bug description

Full_Name: Oliver Bandel
Version: 3.08.0
OS: Mac OS-X
Submission from: dialin-145-254-064-192.arcor-ip.net (145.254.64.192)

Feature Wish:

keyword "immutable" for saying OCaml that a string
is an immutable string, so changing it will be
disallowed.

As in a record it is possible to say that a value
is "mutable" (instead of immutable), so for strings
(but hopefully not only in records) it would be nice
to say "immutable" to get an immutable string.

(but if only possible (or consistent) to have such an
additional keyword in records (like "mutable" is there possible)
than having this possibility only inside of records ie better than
do not have that possibility at all.

but if one could say

let immutable x = "Hello World!"

and a

x.[0] <- 'x'

would result in an error message ("x is immutable")
than this would be very nice. :)

Best Regards to the OCamnl Team,
Oliver Bandel

@vicuna
Copy link
Author

vicuna commented Jun 27, 2016

Comment author: @gasche

Since 4.02 (August 2014), the option -safe-string makes string immutable, and there is a new "bytes" type (and a Bytes module in the standard library) for mutable sequences of bytes. Hopefully -safe-string will be made the default in some future version.

It was a good suggestion, but a few years too soon! (I think there was no technical change that made it possible since, it's more that it took a while to realize that it was enough of a pain to start the transition work.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants