On 11 Feb 2017, at 09:41, lb <liangbing64@126.com> wrote:
Thank you, Sven gradually clear. 1. Symbol as String subclass, only guarantees a symbol object only one in system, use ==; 2. keywords (selector name method name) are spectial symbols, without space or forbided characters; 3. perform: aSymbol, means perform: aKeyword, Should we add asKeyword to String, let perform: aString asKeyword not perform: aString asSymbol ?
Good point, there has been discussion about a Selector class in the past, but I think the conclusion was, more or less, that it was not worth it (too much work/complexity for little gain).
Regards!
Bing Liang
At 2017-02-11 15:51:49, "Sven Van Caekenberghe" <sven@stfx.eu> wrote:
Hi Bing,
Yes, any character is allowed in a Symbol. There is even special syntax that allows such Symbols to be represented literally.
'a b' asSymbol.
=> #'a b'
Although it might be confusing, I don't see any problem.
The concept of 'meaning' is defined by the user, the usage, not by the Symbol itself. A Symbol with a space cannot be a selector (message/method) name, but that does not mean a Symbol with a space could not be useful in some other context.
Regards,
Sven
On 11 Feb 2017, at 05:56, lb <liangbing64@126.com> wrote:
Hi, I know Symbol is subclass of String. Any string object can become symbol object by sending 'asSymbol' message.. I think symbol must has its meaning in comon use, so the symbol should be composed of alphabet or number âwithout spaceâ.
BUT There are not compliant below 1. ' ' asSymbol >>>> no meaning 2. '$%%&' asSymbol >>>> no meaning 3. 'sign' asSymbol = 'sign ' asSymbol >>> false because of space. 3. ' one two three ' asSymbol >>> I think It should become three symbols = #one, #two, #three
Mybe my understanding is wrong.
Bing Liang