Hi Doig the XP for magic literals I found Symbol >> precedence "Answer the receiver's precedence, assuming it is a valid Smalltalk message selector or 0 otherwise. The numbers are 1 for unary, 2 for binary and 3 for keyword selectors." self size = 0 ifTrue: [^ 0]. (self first isLetter or: [ self first = $_ ]) ifFalse: [^ 2]. self last = $: ifTrue: [^ 3]. ^ 1 #'_foo' precedence. "1" #'_+' precedence. "1" #'+' precedence. "2" #'foo' precedence. "1" #'foo:' precedence. "3" #'_foo:' precedence. â3" And I wonder why we are concerned with _ S. -------------------------------------------- Stéphane Ducasse http://stephane.ducasse.free.fr / http://www.pharo.org 03 59 35 87 52 Assistant: Julie Jonas FAX 03 59 57 78 50 TEL 03 59 35 86 16 S. Ducasse - Inria 40, avenue Halley, Parc Scientifique de la Haute Borne, Bât.A, Park Plaza Villeneuve d'Ascq 59650 France
isn't it historical ? it used to mean :=, no? nicolas On Mon, 2020-04-27 at 14:51 +0200, Stéphane Ducasse wrote:
Hi
Doig the XP for magic literals I found
Symbol >> precedence "Answer the receiver's precedence, assuming it is a valid Smalltalk message selector or 0 otherwise. The numbers are 1 for unary, 2 for binary and 3 for keyword selectors."
self size = 0 ifTrue: [^ 0]. (self first isLetter or: [ self first = $_ ]) ifFalse: [^ 2]. self last = $: ifTrue: [^ 3]. ^ 1
#'_foo' precedence. "1" #'_+' precedence. "1" #'+' precedence. "2" #'foo' precedence. "1" #'foo:' precedence. "3" #'_foo:' precedence. â3"
And I wonder why we are concerned with _
S.
-------------------------------------------- Stéphane Ducasse http://stephane.ducasse.free.fr / http://www.pharo.org 03 59 35 87 52 Assistant: Julie Jonas FAX 03 59 57 78 50 TEL 03 59 35 86 16 S. Ducasse - Inria 40, avenue Halley, Parc Scientifique de la Haute Borne, Bât.A, Park Plaza Villeneuve d'Ascq 59650 France
-- Nicolas Anquetil RMod team -- Inria Lille
On 4/27/20 7:51 AM, Stéphane Ducasse wrote:
Hi
Doig the XP for magic literals I found
Symbol >> precedence "Answer the receiver's precedence, assuming it is a valid Smalltalk message selector or 0 otherwise. Â The numbers are 1 for unary, 2 for binary and 3 for keyword selectors."
self size = 0 ifTrue: [^ 0]. (self first isLetter or: [ self first = $_ ]) ifFalse: [^ 2]. self last = $: ifTrue: [^ 3]. ^ 1
#'_foo' precedence. "1" #'_+' precedence. "1" #'+' precedence. "2" #'foo' precedence. "1" #'foo:' precedence. "3" #'_foo:' precedence. â3"
And I wonder why we are concerned with _
Underscores and letters are treated the same by the Smalltalk grammar. Unary, keyword and variables can all begin with letters or underscores. "_" is a valid variable and unary message name. As for your tests, you would get the same results if you replaced $_ with $a -- "#'a+' precedence = 1". John Brant
participants (3)
-
John Brant -
Nicolas Anquetil -
Stéphane Ducasse