ImmutableString.st
author Stefan Vogel <sv@exept.de>
Thu, 20 Aug 2015 17:24:12 +0200
changeset 18704 e1dc90e637b9
parent 18546 23c33cdd1f43
child 18705 843770030c5f
child 20034 2ba574fda7ab
permissions -rw-r--r--
class: ImmutableString added: #becomeSameAs:
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
18546
23c33cdd1f43 class: ImmutableString
Stefan Vogel <sv@exept.de>
parents: 17373
diff changeset
     1
"{ Encoding: utf8 }"
23c33cdd1f43 class: ImmutableString
Stefan Vogel <sv@exept.de>
parents: 17373
diff changeset
     2
3714
62524619bfb7 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     3
"
62524619bfb7 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     4
 COPYRIGHT (c) 1998 by eXept Software AG
12538
e6bf8c42e1d4 Moved to libbasic from libcomp - change package name
Stefan Vogel <sv@exept.de>
parents: 12491
diff changeset
     5
	      All Rights Reserved
3714
62524619bfb7 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     6
62524619bfb7 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     7
 This software is furnished under a license and may be used
62524619bfb7 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     8
 only in accordance with the terms of that license and with the
62524619bfb7 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     9
 inclusion of the above copyright notice.   This software may not
62524619bfb7 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    10
 be provided or otherwise made available to, or used by, any
62524619bfb7 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    11
 other person.  No title to or ownership of the software is
62524619bfb7 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    12
 hereby transferred.
62524619bfb7 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    13
"
12538
e6bf8c42e1d4 Moved to libbasic from libcomp - change package name
Stefan Vogel <sv@exept.de>
parents: 12491
diff changeset
    14
"{ Package: 'stx:libbasic' }"
8807
606a4ec5b693 #notifyStoreError raise error proceedable.
Stefan Vogel <sv@exept.de>
parents: 3714
diff changeset
    15
17373
2dcc19464bd0 class: ImmutableString
Stefan Vogel <sv@exept.de>
parents: 16824
diff changeset
    16
"{ NameSpace: Smalltalk }"
2dcc19464bd0 class: ImmutableString
Stefan Vogel <sv@exept.de>
parents: 16824
diff changeset
    17
8807
606a4ec5b693 #notifyStoreError raise error proceedable.
Stefan Vogel <sv@exept.de>
parents: 3714
diff changeset
    18
String variableByteSubclass:#ImmutableString
3714
62524619bfb7 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    19
	instanceVariableNames:''
62524619bfb7 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    20
	classVariableNames:''
62524619bfb7 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    21
	poolDictionaries:''
62524619bfb7 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    22
	category:'System-Compiler-Support'
62524619bfb7 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    23
!
62524619bfb7 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    24
62524619bfb7 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    25
!ImmutableString class methodsFor:'documentation'!
62524619bfb7 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    26
62524619bfb7 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    27
copyright
62524619bfb7 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    28
"
62524619bfb7 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    29
 COPYRIGHT (c) 1998 by eXept Software AG
12538
e6bf8c42e1d4 Moved to libbasic from libcomp - change package name
Stefan Vogel <sv@exept.de>
parents: 12491
diff changeset
    30
	      All Rights Reserved
3714
62524619bfb7 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    31
62524619bfb7 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    32
 This software is furnished under a license and may be used
62524619bfb7 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    33
 only in accordance with the terms of that license and with the
62524619bfb7 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    34
 inclusion of the above copyright notice.   This software may not
62524619bfb7 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    35
 be provided or otherwise made available to, or used by, any
62524619bfb7 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    36
 other person.  No title to or ownership of the software is
62524619bfb7 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    37
 hereby transferred.
62524619bfb7 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    38
"
62524619bfb7 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    39
62524619bfb7 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    40
!
62524619bfb7 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    41
62524619bfb7 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    42
documentation
62524619bfb7 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    43
"
62524619bfb7 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    44
    By default, string literals in smalltalk are mutable objects. That
62524619bfb7 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    45
    may lead to some subtle (and hard to find errors), if some method passes
62524619bfb7 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    46
    a string constant as argument to someone else, who changes the
12538
e6bf8c42e1d4 Moved to libbasic from libcomp - change package name
Stefan Vogel <sv@exept.de>
parents: 12491
diff changeset
    47
    string using at:put: like messages. Since the string object is kept in
3714
62524619bfb7 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    48
    the first methods literals, the string constant has now been changed without
12464
c0a970ba9175 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 12457
diff changeset
    49
    having the method's sourcecode reflect this. Thus, the method will
3714
62524619bfb7 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    50
    behave differently from what its source may make you think.
62524619bfb7 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    51
62524619bfb7 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    52
    To help finding this kind of 'feature/bug', the compiler can be
62524619bfb7 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    53
    configured to create instances of this ImmutableString instead of Strings
12464
c0a970ba9175 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 12457
diff changeset
    54
    for literals. Instances of ImmutableString catch storing accesses and
3714
62524619bfb7 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    55
    enter the debugger. Although useful, this feature is disabled by default
12538
e6bf8c42e1d4 Moved to libbasic from libcomp - change package name
Stefan Vogel <sv@exept.de>
parents: 12491
diff changeset
    56
    for compatibility to other smalltalk implementations.
3714
62524619bfb7 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    57
    (Also, if turned on, this makes inspecting string literals entered in
62524619bfb7 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    58
     a workspace somewhat strange: you cannot modify it any longer).
62524619bfb7 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    59
62524619bfb7 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    60
    Turn the ImmutableString feature on by setting the Parsers class variable
62524619bfb7 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    61
    'StringsAreImmutable' to true or use the new launchers settings menu.
62524619bfb7 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    62
18546
23c33cdd1f43 class: ImmutableString
Stefan Vogel <sv@exept.de>
parents: 17373
diff changeset
    63
    This class should be used only by the compiler.
12471
c6260f85e725 added: #copyright
Claus Gittinger <cg@exept.de>
parents: 12464
diff changeset
    64
c6260f85e725 added: #copyright
Claus Gittinger <cg@exept.de>
parents: 12464
diff changeset
    65
    ATTENTION:
14222
876ba773f5d2 changed: #documentation
Stefan Vogel <sv@exept.de>
parents: 14115
diff changeset
    66
        there may be still code around which checks for explicit class being String
876ba773f5d2 changed: #documentation
Stefan Vogel <sv@exept.de>
parents: 14115
diff changeset
    67
        (both in Smalltalk and in primitive code). All code like foo 'class == String'
876ba773f5d2 changed: #documentation
Stefan Vogel <sv@exept.de>
parents: 14115
diff changeset
    68
        or '__isString()' will not work with ImmutableStrings. Use '__isStringLike()' instead.
876ba773f5d2 changed: #documentation
Stefan Vogel <sv@exept.de>
parents: 14115
diff changeset
    69
        A somewhat better approach would be to either add a flag to the object (mutability)
876ba773f5d2 changed: #documentation
Stefan Vogel <sv@exept.de>
parents: 14115
diff changeset
    70
        and check this dynamically (expensive) or to place immutable objects into a readonly
876ba773f5d2 changed: #documentation
Stefan Vogel <sv@exept.de>
parents: 14115
diff changeset
    71
        memory segment (the good solution). We will eventually implement the second in the future...
12471
c6260f85e725 added: #copyright
Claus Gittinger <cg@exept.de>
parents: 12464
diff changeset
    72
3714
62524619bfb7 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    73
    [see also:]
14222
876ba773f5d2 changed: #documentation
Stefan Vogel <sv@exept.de>
parents: 14115
diff changeset
    74
        ImmutableArray
876ba773f5d2 changed: #documentation
Stefan Vogel <sv@exept.de>
parents: 14115
diff changeset
    75
        Parser Scanner
3714
62524619bfb7 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    76
62524619bfb7 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    77
    [author:]
14222
876ba773f5d2 changed: #documentation
Stefan Vogel <sv@exept.de>
parents: 14115
diff changeset
    78
        Claus Gittinger
3714
62524619bfb7 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    79
"
62524619bfb7 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    80
! !
62524619bfb7 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    81
17373
2dcc19464bd0 class: ImmutableString
Stefan Vogel <sv@exept.de>
parents: 16824
diff changeset
    82
!ImmutableString class methodsFor:'queries'!
2dcc19464bd0 class: ImmutableString
Stefan Vogel <sv@exept.de>
parents: 16824
diff changeset
    83
2dcc19464bd0 class: ImmutableString
Stefan Vogel <sv@exept.de>
parents: 16824
diff changeset
    84
mutableClass
2dcc19464bd0 class: ImmutableString
Stefan Vogel <sv@exept.de>
parents: 16824
diff changeset
    85
    "answer an equivalent mustable class"
2dcc19464bd0 class: ImmutableString
Stefan Vogel <sv@exept.de>
parents: 16824
diff changeset
    86
2dcc19464bd0 class: ImmutableString
Stefan Vogel <sv@exept.de>
parents: 16824
diff changeset
    87
    ^ String
2dcc19464bd0 class: ImmutableString
Stefan Vogel <sv@exept.de>
parents: 16824
diff changeset
    88
! !
2dcc19464bd0 class: ImmutableString
Stefan Vogel <sv@exept.de>
parents: 16824
diff changeset
    89
2dcc19464bd0 class: ImmutableString
Stefan Vogel <sv@exept.de>
parents: 16824
diff changeset
    90
!ImmutableString class methodsFor:'testing'!
2dcc19464bd0 class: ImmutableString
Stefan Vogel <sv@exept.de>
parents: 16824
diff changeset
    91
2dcc19464bd0 class: ImmutableString
Stefan Vogel <sv@exept.de>
parents: 16824
diff changeset
    92
hasImmutableInstances
2dcc19464bd0 class: ImmutableString
Stefan Vogel <sv@exept.de>
parents: 16824
diff changeset
    93
    ^ true
2dcc19464bd0 class: ImmutableString
Stefan Vogel <sv@exept.de>
parents: 16824
diff changeset
    94
! !
2dcc19464bd0 class: ImmutableString
Stefan Vogel <sv@exept.de>
parents: 16824
diff changeset
    95
3714
62524619bfb7 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    96
!ImmutableString methodsFor:'accessing'!
62524619bfb7 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    97
12538
e6bf8c42e1d4 Moved to libbasic from libcomp - change package name
Stefan Vogel <sv@exept.de>
parents: 12491
diff changeset
    98
at:index put:value
3714
62524619bfb7 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    99
    "Trigger an error if an immutable string is stored into.
62524619bfb7 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   100
     The store will be performed (for compatibility reasons) if you continue
62524619bfb7 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   101
     in the debugger."
12538
e6bf8c42e1d4 Moved to libbasic from libcomp - change package name
Stefan Vogel <sv@exept.de>
parents: 12491
diff changeset
   102
12491
d74b78dd478a Raise NoModificationError
Stefan Vogel <sv@exept.de>
parents: 12471
diff changeset
   103
    self noModificationError.
3714
62524619bfb7 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   104
    ^ super at:index put:value
62524619bfb7 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   105
62524619bfb7 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   106
    "Created: / 3.8.1998 / 14:45:14 / cg"
12457
7094a6561516 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9412
diff changeset
   107
!
7094a6561516 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9412
diff changeset
   108
12538
e6bf8c42e1d4 Moved to libbasic from libcomp - change package name
Stefan Vogel <sv@exept.de>
parents: 12491
diff changeset
   109
basicAt:index put:value
12457
7094a6561516 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9412
diff changeset
   110
    "Trigger an error if an immutable string is stored into.
7094a6561516 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9412
diff changeset
   111
     The store will be performed (for compatibility reasons) if you continue
7094a6561516 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9412
diff changeset
   112
     in the debugger."
12538
e6bf8c42e1d4 Moved to libbasic from libcomp - change package name
Stefan Vogel <sv@exept.de>
parents: 12491
diff changeset
   113
12491
d74b78dd478a Raise NoModificationError
Stefan Vogel <sv@exept.de>
parents: 12471
diff changeset
   114
    self noModificationError.
12457
7094a6561516 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9412
diff changeset
   115
    ^ super basicAt:index put:value
7094a6561516 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9412
diff changeset
   116
! !
7094a6561516 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9412
diff changeset
   117
7094a6561516 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9412
diff changeset
   118
!ImmutableString methodsFor:'converting'!
7094a6561516 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9412
diff changeset
   119
7094a6561516 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9412
diff changeset
   120
asImmutableString
7094a6561516 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9412
diff changeset
   121
    ^ self
16824
d609e592fd2f added asMutableCollection
Claus Gittinger <cg@exept.de>
parents: 16400
diff changeset
   122
!
d609e592fd2f added asMutableCollection
Claus Gittinger <cg@exept.de>
parents: 16400
diff changeset
   123
d609e592fd2f added asMutableCollection
Claus Gittinger <cg@exept.de>
parents: 16400
diff changeset
   124
asMutableCollection
d609e592fd2f added asMutableCollection
Claus Gittinger <cg@exept.de>
parents: 16400
diff changeset
   125
    "return a writable copy of myself"
d609e592fd2f added asMutableCollection
Claus Gittinger <cg@exept.de>
parents: 16400
diff changeset
   126
d609e592fd2f added asMutableCollection
Claus Gittinger <cg@exept.de>
parents: 16400
diff changeset
   127
    ^ self copy changeClassTo:String
3714
62524619bfb7 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   128
! !
62524619bfb7 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   129
62524619bfb7 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   130
!ImmutableString methodsFor:'copying'!
62524619bfb7 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   131
62524619bfb7 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   132
postCopy
12457
7094a6561516 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9412
diff changeset
   133
    "when copied, make me a real (mutable) String"
7094a6561516 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9412
diff changeset
   134
7094a6561516 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9412
diff changeset
   135
    self changeClassTo:String.
7094a6561516 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9412
diff changeset
   136
7094a6561516 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9412
diff changeset
   137
    "Created: / 3.8.1998 / 14:46:45 / cg"
7094a6561516 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9412
diff changeset
   138
!
7094a6561516 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9412
diff changeset
   139
7094a6561516 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9412
diff changeset
   140
postDeepCopy
3714
62524619bfb7 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   141
    "when copied, make it me a real (mutable) String"
62524619bfb7 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   142
62524619bfb7 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   143
    self changeClassTo:String.
62524619bfb7 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   144
12457
7094a6561516 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9412
diff changeset
   145
    "
7094a6561516 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9412
diff changeset
   146
     'foobar' asImmutableString copy          class
7094a6561516 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9412
diff changeset
   147
     'foobar' asImmutableString shallowCopy   class
7094a6561516 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9412
diff changeset
   148
     'foobar' asImmutableString deepCopy      class
7094a6561516 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9412
diff changeset
   149
    "
3714
62524619bfb7 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   150
!
62524619bfb7 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   151
62524619bfb7 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   152
shallowCopy
62524619bfb7 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   153
    "when copying, return a real (mutable) String"
62524619bfb7 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   154
62524619bfb7 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   155
    |sz|
62524619bfb7 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   156
62524619bfb7 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   157
    sz := self size.
62524619bfb7 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   158
    ^ (String new:sz) replaceFrom:1 to:sz with:self startingAt:1
62524619bfb7 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   159
14115
8599762e8a45 comment/format in: #shallowCopy
Stefan Vogel <sv@exept.de>
parents: 14025
diff changeset
   160
    "
8599762e8a45 comment/format in: #shallowCopy
Stefan Vogel <sv@exept.de>
parents: 14025
diff changeset
   161
     'hello world' asImmutableString shallowCopy
8599762e8a45 comment/format in: #shallowCopy
Stefan Vogel <sv@exept.de>
parents: 14025
diff changeset
   162
    "
8599762e8a45 comment/format in: #shallowCopy
Stefan Vogel <sv@exept.de>
parents: 14025
diff changeset
   163
3714
62524619bfb7 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   164
    "Created: / 3.8.1998 / 14:47:00 / cg"
62524619bfb7 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   165
! !
62524619bfb7 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   166
62524619bfb7 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   167
!ImmutableString methodsFor:'private'!
62524619bfb7 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   168
62524619bfb7 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   169
species
62524619bfb7 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   170
    "Copies should be mutable"
62524619bfb7 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   171
62524619bfb7 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   172
    ^ String
62524619bfb7 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   173
62524619bfb7 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   174
    "Created: / 3.8.1998 / 14:47:58 / cg"
16400
6c38fd2957bc class: ImmutableString
Claus Gittinger <cg@exept.de>
parents: 14386
diff changeset
   175
!
6c38fd2957bc class: ImmutableString
Claus Gittinger <cg@exept.de>
parents: 14386
diff changeset
   176
6c38fd2957bc class: ImmutableString
Claus Gittinger <cg@exept.de>
parents: 14386
diff changeset
   177
speciesForCopy
6c38fd2957bc class: ImmutableString
Claus Gittinger <cg@exept.de>
parents: 14386
diff changeset
   178
    "Copies should be mutable"
6c38fd2957bc class: ImmutableString
Claus Gittinger <cg@exept.de>
parents: 14386
diff changeset
   179
6c38fd2957bc class: ImmutableString
Claus Gittinger <cg@exept.de>
parents: 14386
diff changeset
   180
    ^ String
6c38fd2957bc class: ImmutableString
Claus Gittinger <cg@exept.de>
parents: 14386
diff changeset
   181
6c38fd2957bc class: ImmutableString
Claus Gittinger <cg@exept.de>
parents: 14386
diff changeset
   182
    "Created: / 3.8.1998 / 14:47:58 / cg"
3714
62524619bfb7 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   183
! !
62524619bfb7 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   184
14386
27b494f48340 isImmutable
Claus Gittinger <cg@exept.de>
parents: 14222
diff changeset
   185
!ImmutableString methodsFor:'queries'!
27b494f48340 isImmutable
Claus Gittinger <cg@exept.de>
parents: 14222
diff changeset
   186
27b494f48340 isImmutable
Claus Gittinger <cg@exept.de>
parents: 14222
diff changeset
   187
isImmutable
27b494f48340 isImmutable
Claus Gittinger <cg@exept.de>
parents: 14222
diff changeset
   188
    ^ true
27b494f48340 isImmutable
Claus Gittinger <cg@exept.de>
parents: 14222
diff changeset
   189
! !
27b494f48340 isImmutable
Claus Gittinger <cg@exept.de>
parents: 14222
diff changeset
   190
3714
62524619bfb7 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   191
!ImmutableString methodsFor:'specials'!
62524619bfb7 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   192
12538
e6bf8c42e1d4 Moved to libbasic from libcomp - change package name
Stefan Vogel <sv@exept.de>
parents: 12491
diff changeset
   193
become:anotherObject
3714
62524619bfb7 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   194
    "trigger an error if I should become something else
62524619bfb7 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   195
     (this would be an even more tricky manipulation)"
12538
e6bf8c42e1d4 Moved to libbasic from libcomp - change package name
Stefan Vogel <sv@exept.de>
parents: 12491
diff changeset
   196
12491
d74b78dd478a Raise NoModificationError
Stefan Vogel <sv@exept.de>
parents: 12471
diff changeset
   197
    self noModificationError.
3714
62524619bfb7 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   198
    ^ super become:anotherObject
62524619bfb7 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   199
62524619bfb7 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   200
    "Created: / 3.8.1998 / 14:48:29 / cg"
62524619bfb7 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   201
!
62524619bfb7 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   202
62524619bfb7 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   203
becomeNil
62524619bfb7 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   204
    "trigger an error if I should become nil
62524619bfb7 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   205
     (this would be an even more tricky manipulation)"
12538
e6bf8c42e1d4 Moved to libbasic from libcomp - change package name
Stefan Vogel <sv@exept.de>
parents: 12491
diff changeset
   206
12491
d74b78dd478a Raise NoModificationError
Stefan Vogel <sv@exept.de>
parents: 12471
diff changeset
   207
    self noModificationError.
3714
62524619bfb7 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   208
    ^ super becomeNil
62524619bfb7 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   209
62524619bfb7 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   210
    "Created: / 3.8.1998 / 14:48:37 / cg"
18704
e1dc90e637b9 class: ImmutableString
Stefan Vogel <sv@exept.de>
parents: 18546
diff changeset
   211
!
e1dc90e637b9 class: ImmutableString
Stefan Vogel <sv@exept.de>
parents: 18546
diff changeset
   212
e1dc90e637b9 class: ImmutableString
Stefan Vogel <sv@exept.de>
parents: 18546
diff changeset
   213
becomeSameAs:anotherObject
e1dc90e637b9 class: ImmutableString
Stefan Vogel <sv@exept.de>
parents: 18546
diff changeset
   214
    "trigger an error if I should become something else
e1dc90e637b9 class: ImmutableString
Stefan Vogel <sv@exept.de>
parents: 18546
diff changeset
   215
     (this would be an even more tricky manipulation)"
e1dc90e637b9 class: ImmutableString
Stefan Vogel <sv@exept.de>
parents: 18546
diff changeset
   216
e1dc90e637b9 class: ImmutableString
Stefan Vogel <sv@exept.de>
parents: 18546
diff changeset
   217
    self noModificationError.
e1dc90e637b9 class: ImmutableString
Stefan Vogel <sv@exept.de>
parents: 18546
diff changeset
   218
    ^ super becomeSameAs:anotherObject
3714
62524619bfb7 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   219
! !
62524619bfb7 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   220
62524619bfb7 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   221
!ImmutableString class methodsFor:'documentation'!
62524619bfb7 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   222
62524619bfb7 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   223
version
18546
23c33cdd1f43 class: ImmutableString
Stefan Vogel <sv@exept.de>
parents: 17373
diff changeset
   224
    ^ '$Header$'
12457
7094a6561516 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9412
diff changeset
   225
!
7094a6561516 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9412
diff changeset
   226
7094a6561516 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9412
diff changeset
   227
version_CVS
18546
23c33cdd1f43 class: ImmutableString
Stefan Vogel <sv@exept.de>
parents: 17373
diff changeset
   228
    ^ '$Header$'
3714
62524619bfb7 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   229
! !
16400
6c38fd2957bc class: ImmutableString
Claus Gittinger <cg@exept.de>
parents: 14386
diff changeset
   230