Symbol.st
changeset 267 54bcd20b369d
parent 252 cf6eef7703ad
child 268 e69e68148505
equal deleted inserted replaced
266:f4a7a506a995 267:54bcd20b369d
    19 
    19 
    20 Symbol comment:'
    20 Symbol comment:'
    21 COPYRIGHT (c) 1988 by Claus Gittinger
    21 COPYRIGHT (c) 1988 by Claus Gittinger
    22 	      All Rights Reserved
    22 	      All Rights Reserved
    23 
    23 
    24 $Header: /cvs/stx/stx/libbasic/Symbol.st,v 1.15 1995-02-15 10:25:05 claus Exp $
    24 $Header: /cvs/stx/stx/libbasic/Symbol.st,v 1.16 1995-02-18 01:22:37 claus Exp $
    25 '!
    25 '!
    26 
    26 
    27 !Symbol class methodsFor:'documentation'!
    27 !Symbol class methodsFor:'documentation'!
    28 
    28 
    29 copyright
    29 copyright
    40 "
    40 "
    41 !
    41 !
    42 
    42 
    43 version
    43 version
    44 "
    44 "
    45 $Header: /cvs/stx/stx/libbasic/Symbol.st,v 1.15 1995-02-15 10:25:05 claus Exp $
    45 $Header: /cvs/stx/stx/libbasic/Symbol.st,v 1.16 1995-02-18 01:22:37 claus Exp $
    46 "
    46 "
    47 !
    47 !
    48 
    48 
    49 documentation
    49 documentation
    50 "
    50 "
    95      Notice: this fails, if you try to intern an instance of a subclass, AND
    95      Notice: this fails, if you try to intern an instance of a subclass, AND
    96      a symbol with the same name already exists. In this case, the original
    96      a symbol with the same name already exists. In this case, the original
    97      symbol is returned. To use it for enum-type symbols, make certain, that the
    97      symbol is returned. To use it for enum-type symbols, make certain, that the
    98      names are unique (for example by including the classes name as a prefix-string)."
    98      names are unique (for example by including the classes name as a prefix-string)."
    99 
    99 
   100     |newSym len|
   100     |sym len|
   101 
   101 
   102     aString knownAsSymbol ifTrue:[
   102     sym := aString asSymbolIfInterned.
   103 	^ aString asSymbol
   103     sym notNil ifTrue:[
       
   104 	^ sym
   104     ].
   105     ].
   105 
   106 
   106     "
   107     "
   107      create a new uninterned instance first
   108      create a new uninterned instance first
   108     "
   109     "
   109     len := aString size.
   110     len := aString size.
   110     newSym := super basicNew:len.
   111     sym := super basicNew:len.
   111     newSym replaceFrom:1 to:len with:aString.
   112     sym replaceFrom:1 to:len with:aString.
   112 
   113 
   113     "now, intern it"
   114     "now, intern it"
   114 %{
   115 %{
   115     extern OBJ _INTERNSYMBOL();
   116     extern OBJ _INTERNSYMBOL();
   116 
   117 
   117     newSym = _INTERNSYMBOL(newSym, (OBJ *)0, __context);
   118     sym = _INTERNSYMBOL(sym, (OBJ *)0, __context);
   118 %}.
   119 %}.
   119     ^ newSym
   120     ^ sym
   120 !
   121 !
   121 
   122 
   122 internCharacter:aCharacter
   123 internCharacter:aCharacter
   123     "return a unique symbol with printname taken from the Character-argument"
   124     "return a unique symbol with printname taken from the Character-argument"
   124 
   125