Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > RE: Mutable strings

Reply
Thread Tools

RE: Mutable strings

 
 
SBrunning@trisystems.co.uk
Guest
Posts: n/a
 
      09-22-2003
> From: Alex Martelli [SMTP:(E-Mail Removed)]
> Hans-Joachim Widmaier wrote:
>
> > I don't think strings are immutable because they ought to be that way
> > (e.g. some CS guru teaches that "mutable strings are the root of all
> > evil"). They're immutable because they allow them to be used as
> > dictionary keys. And it was found that this doesn't affect the
> > usefulness of the language too much.

>
> Wrong. Consider Java, even back from the very first version: it had
> no dictionaries on which string might be keys, yet it still decided
> to make its strings immutable. This should make it obvious that the
> interest of using keys as dict keys cannot possibly be the sole
> motivation for the decision to make strings immutable in a language.
> Rather, the deeper motivation is connected to wanting strings to be
> ATOMIC, ELEMENTARY types, just like numbers; and to lots of useful
> practical returns of that choice. All you lose is the "ability" to
> "confuse" (type-pun) between strings and arrays of bytes in many
> situations, but that's an ability best lost in many cases. It's not
> an issue of "evil" -- a close-to-the-hardware low-level language
> like C has excellent reasons to choose a different, close-to-HW
> semantics -- but in a higher-level language I think Python's and
> Java's choice to have strings immutable works better than (e.g.)
> Perl's and Ruby's to have them mutable.


I came across a good write up of this principle today -
<http://c2.com/cgi/wiki?ImmutableValue>.

Cheers,
Simon Brunning,
http://www.brunningonline.net/simon/blog/
--LongSig





-----------------------------------------------------------------------
The information in this email is confidential and may be legally privileged.
It is intended solely for the addressee. Access to this email by anyone else
is unauthorised. If you are not the intended recipient, any disclosure,
copying, distribution, or any action taken or omitted to be taken in
reliance on it, is prohibited and may be unlawful. TriSystems Ltd. cannot
accept liability for statements made which are clearly the senders own.

 
Reply With Quote
 
 
 
 
Gordon Airport
Guest
Posts: n/a
 
      09-22-2003
Wow, that's timely!
Good write-up.

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Mutable Strings - Any libraries that offer this? casebash Python 9 07-27-2009 12:36 AM
Strings, Strings and Damned Strings Ben C Programming 14 06-24-2006 05:09 AM
Are JavaScript strings mutable? Water Cooler v2 Javascript 12 04-20-2006 07:50 PM
Mutable strings Mystifier Ruby 19 01-14-2005 10:00 PM
Mutable strings Gordon Airport Python 17 09-25-2003 08:10 PM



Advertisments