About asSymbol message , some questions in my mind
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
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
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 ? 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
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
Hi Bing Liang, Thanks for your comments. Fresh eyes provide interesting perspectives on things we take for granted. On Sat, Feb 11, 2017 at 4:41 PM, 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,
Not exactly. It means perform a "message" where there are three types of messages... * unary, like #printString * binary, like #+ * keyword, like #perform: or #subclass:instanceVariableNames:classVariableNames:package: having a colon appended to each keyword
Should we add asKeyword to String, let perform: aString asKeyword
or alternatively per above... perform: aString asMessage
not perform: aString asSymbol ?
In the case that aString contained a space, presumably #asMessage would produce a runtime error in asMessage whereas #asSymbol would produce a runtime error in #perform: I guess there is a minor benefit of failing early but will that make much difference in practice. Do you have a use case where it makes a major difference?
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.
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 common use, so the symbol should be composed of alphabet or number âwithout spaceâ.
Different domains have different common usage. IIUC, Smalltalk's definition of symbol is from the 1970s. Pharo is not overly constrained by Smalltalk traditions, but there must be sufficient gain to balance deviations from consistency with other Smalltalks.
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
Maybe my understanding is wrong.
no problem. Being wrong is a great way to learn ;) cheers -ben
On Sun, Feb 12, 2017 at 12:39 AM, Ben Coman <btc@openinworld.com> wrote:
Hi Bing Liang,
Thanks for your comments. Fresh eyes provide interesting perspectives on things we take for granted.
On Sat, Feb 11, 2017 at 4:41 PM, 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,
Not exactly. It means perform a "message" where there are three types of messages... * unary, like #printString * binary, like #+ * keyword, like #perform: or #subclass:instanceVariableNames:classVariableNames:package: having a colon appended to each keyword
Should we add asKeyword to String, let perform: aString asKeyword
or alternatively per above... perform: aString asMessage
not perform: aString asSymbol ?
In the case that aString contained a space, presumably #asMessage would produce a runtime error in asMessage whereas #asSymbol would produce a runtime error in #perform: I guess there is a minor benefit of failing early but will that make much difference in practice. Do you have a use case where it makes a major difference?
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.
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 common use, so the symbol should be composed of alphabet or number âwithout spaceâ.
Different domains have different common usage. IIUC, Smalltalk's definition of symbol is from the 1970s. Pharo is not overly constrained by Smalltalk traditions, but there must be sufficient gain to balance deviations from consistency with other Smalltalks.
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
Maybe my understanding is wrong.
no problem. Being wrong is a great way to learn ;)
cheers -ben
P.S. Even wikipedia says "Symbols can contain whitespace (and all other characters)" https://en.wikipedia.org/wiki/Symbol_(programming) so it must be okay ;) cheers -ben
Hi Benï¼ Thank you very much, your answer make me clear like water. My question aimed on where, which type errors occur when perform a message. My usecase. when perform: aMessage(with a space), get DNU error , cannot find out by eyes directly. asMessage is better than asSymbol. Cheers Bing At 2017-02-12 00:39:55, "Ben Coman" <btc@openinworld.com> wrote:
Hi Bing Liang,
Thanks for your comments. Fresh eyes provide interesting perspectives on things we take for granted.
On Sat, Feb 11, 2017 at 4:41 PM, 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,
Not exactly. It means perform a "message" where there are three types of messages... * unary, like #printString * binary, like #+ * keyword, like #perform: or #subclass:instanceVariableNames:classVariableNames:package: having a colon appended to each keyword
Should we add asKeyword to String, let perform: aString asKeyword
or alternatively per above... perform: aString asMessage
not perform: aString asSymbol ?
In the case that aString contained a space, presumably #asMessage would produce a runtime error in asMessage whereas #asSymbol would produce a runtime error in #perform: I guess there is a minor benefit of failing early but will that make much difference in practice. Do you have a use case where it makes a major difference?
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.
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 common use, so the symbol should be composed of alphabet or number âwithout spaceâ.
Different domains have different common usage. IIUC, Smalltalk's definition of symbol is from the 1970s. Pharo is not overly constrained by Smalltalk traditions, but there must be sufficient gain to balance deviations from consistency with other Smalltalks.
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
Maybe my understanding is wrong.
no problem. Being wrong is a great way to learn ;)
cheers -ben
On Sun, Feb 12, 2017 at 10:54 AM, lb <liangbing64@126.com> wrote:
Hi Benï¼ Thank you very much, your answer make me clear like water. My question aimed on where, which type errors occur when perform a message. My usecase. when perform: aMessage(with a space), get DNU error , cannot find out by eyes directly.
What is the higher level use case? For example, are you getting input from a user that you evaluate as a command in some kind of Domain Specific Language? In such a case you may be better to validate the command has no spaces closer to the UI?
asMessage is better than asSymbol.
If you don't get community support for this, you can start extending String like this for your own projects and later promote your concrete experience with it. cheers -ben
Cheers Bing
At 2017-02-12 00:39:55, "Ben Coman" <btc@openinworld.com> wrote:
Hi Bing Liang,
Thanks for your comments. Fresh eyes provide interesting perspectives on things we take for granted.
On Sat, Feb 11, 2017 at 4:41 PM, 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,
Not exactly. It means perform a "message" where there are three types of messages... * unary, like #printString * binary, like #+ * keyword, like #perform: or #subclass:instanceVariableNames:classVariableNames:package: having a colon appended to each keyword
Should we add asKeyword to String, let perform: aString asKeyword
or alternatively per above... perform: aString asMessage
not perform: aString asSymbol ?
In the case that aString contained a space, presumably #asMessage would produce a runtime error in asMessage whereas #asSymbol would produce a runtime error in #perform: I guess there is a minor benefit of failing early but will that make much difference in practice. Do you have a use case where it makes a major difference?
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.
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 common use, so the symbol should be composed of alphabet or number âwithout spaceâ.
Different domains have different common usage. IIUC, Smalltalk's definition of symbol is from the 1970s. Pharo is not overly constrained by Smalltalk traditions, but there must be sufficient gain to balance deviations from consistency with other Smalltalks.
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
Maybe my understanding is wrong.
no problem. Being wrong is a great way to learn ;)
cheers -ben
2017-02-11 8:51 GMT+01:00 Sven Van Caekenberghe <sven@stfx.eu>:
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 it could be: Point methodDict at: #'name with space' put: Point>>#x. 2@3 perform: #'name with space' "==> 2" Only problem that we could not use them with normal syntax
On 11 Feb 2017, at 15:18, Denis Kudriashov <dionisiydk@gmail.com> wrote:
2017-02-11 8:51 GMT+01:00 Sven Van Caekenberghe <sven@stfx.eu>: 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 it could be:
Point methodDict at: #'name with space' put: Point>>#x.
2@3 perform: #'name with space' "==> 2"
Only problem that we could not use them with normal syntax
Cool. Or we could use any Unicode character, like icons and emoticons ;-)
Hi, Dnenis Thank you. Your sample gives me some tips on AI , NLP. Cheers Bing å¨ 2017-02-11 22:18:14ï¼"Denis Kudriashov" <dionisiydk@gmail.com> åéï¼ 2017-02-11 8:51 GMT+01:00 Sven Van Caekenberghe <sven@stfx.eu>: 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 it could be: Point methodDict at: #'name with space' put: Point>>#x. 2@3 perform: #'name with space' "==> 2" Only problem that we could not use them with normal syntax
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 I don't know what you mean by "no meaning', they're symbols. Try this in a Playground, it works in Pharo 5" | oc sym filtered| oc := ' one two three $%%&' splitOn: ' '. sym := OrderedCollection new. oc do: [:each | sym add: each asSymbol]. filtered := OrderedCollection new. filtered := sym select: [ :each | each ~= #'' ]. Transcript show: sym printString; cr. Transcript show: filtered printString; cr. On Fri, Feb 10, 2017 at 8:56 PM, 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
Just To You, :-) Symbol , a sign with some meaning in nature language. eg, #% = percent, #$ = dollar. but 2. '$%%&' asSymbol >>>> no meaning symbol as a message should have his meaning. defined in its method. a message should let programmer know what to do. I come from China , My English is poor. Cheers. Bing å¨ 2017-02-13 07:26:05ï¼"john pfersich" <jpfersich@gmail.com> åéï¼ 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 I don't know what you mean by "no meaning', they're symbols. Try this in a Playground, it works in Pharo 5" | oc sym filtered| oc := ' one two three $%%&' splitOn: ' '. sym := OrderedCollection new. oc do: [:each | sym add: each asSymbol]. filtered := OrderedCollection new. filtered := sym select: [ :each | each ~= #'' ]. Transcript show: sym printString; cr. Transcript show: filtered printString; cr. On Fri, Feb 10, 2017 at 8:56 PM, 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
On 13 February 2017 at 13:48, lb <liangbing64@126.com> wrote:
Just To You, :-) Symbol , a sign with some meaning in nature language. eg, #% = percent, #$ = dollar. but 2. '$%%&' asSymbol >>>> no meaning
symbol as a message should have his meaning. defined in its method. a message should let programmer know what to do.
I come from China , My English is poor.
Hmm.. Then why it is so hard for you to comprehend such simple concept? In Chinese you have thousands unique glyphs, that you can use for writing, and each one has own meaning. Sometimes they literally mean something, but sometimes the meaning depends on context. That means that symbols '@#&%@#$' may not have meaning for most uses, while for some other can. This depends on context. Now if you take into account that in English, there's not so many glyphs for letter, so you have to use combination(s) of them to form words, phrases etc.. that could have meaning in specific context, while not have in other.
Cheers.
Bing
å¨ 2017-02-13 07:26:05ï¼"john pfersich" <jpfersich@gmail.com> åéï¼
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
I don't know what you mean by "no meaning', they're symbols. Try this in a Playground, it works in Pharo 5"
| oc sym filtered| oc := ' one two three $%%&' splitOn: ' '. sym := OrderedCollection new. oc do: [:each | sym add: each asSymbol]. filtered := OrderedCollection new. filtered := sym select: [ :each | each ~= #'' ]. Transcript show: sym printString; cr. Transcript show: filtered printString; cr.
On Fri, Feb 10, 2017 at 8:56 PM, 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
-- Best regards, Igor Stasenko.
participants (6)
-
Ben Coman -
Denis Kudriashov -
Igor Stasenko -
john pfersich -
lb -
Sven Van Caekenberghe