You're assuming that strings are specifically for holding sentences, which
is not the case. That's one possible use case, but certainly not the only
one. If you want to do this sort of thing, using a mutable array of words
seems much more appropriate anyway. You can easily wrap this in a Sentence
type and have it print itself nicely. But again, I would argue that if you
change some words in a sentence, you don't have the same sentence with
different words, you just have a different sentence. Sentences are not
containers.


On Fri, Mar 21, 2014 at 5:31 PM, cnbiz850 <cnbiz...@gmail.com> wrote:

> Well in that example, you can always replace "scientist" with "scholar".
>  But if I want to say "Am I also a scholar?" after thinking of saying "I am
> a scientist". Sure that can be handled also without much difficulty.  So
> perhaps you can say "whether the string is mutable or not has no serious
> practical consequences", but I want to amend it as "whether the string is
> mutable or not is a conceptual difference".
>
>
> On 03/22/2014 05:21 AM, Milan Bouchet-Valat wrote:
>
>> Le samedi 22 mars 2014 à 05:08 +0800, cnbiz850 a écrit :
>>
>>> Well, from this perspective, it makes sense why those strings should not
>>> be mutable.
>>>
>>> But from other perspectives, making strings immutable contradicts with
>>> how natural languages are used.  For instance, after I said "I am a
>>> professor", I want to say "I am a scientist", or perhaps I change my
>>> mind and say "I am a scholar".
>>>
>> But when it comes to concretely changing "I am a scientist" to "I am a
>> scholar", you'll do this anyway:
>> replace("I am a scientist", "scientist", "scholar")
>>
>> I really doubt you'll find plausible use cases where you'd prefer to
>> mutate the string. And guess what, a construct like this couldn't work:
>> str = "I am a scientist"
>> str[8:16] = "scholar"
>>
>> because the replacement string is too short. Woops...
>>
>>
>> So the question of whether the string is mutable or not has no serious
>> practical consequences.
>>
>>
>> Regards
>>
>
>

Reply via email to