鲜为人知的 Smalltalk 二进制消息及其含义?
Less known Smalltalk binary messages and their meaning?
为初学者写了一些文档,我遇到了一个问题。知道二进制消息的作用,并不意味着你知道它们叫什么!
一些明显的,以及它们各自的 类:
- "minus" TraitComposition Collection Point Interval BoxedFloat64 Color LargeInteger ScaledDecimal Integer Exception DateAndTime Number TraitExclusion SmallInteger TraitTransformation TComposingDescription WordArray Fraction ExceptionSetWithExclusions ExceptionSet FloatArray SmallFloat64 Duration TraitDescription Timespan TraitAlias
/ "divided by" FileSystem Collection Point BoxedFloat64 Color LargeInteger AbstractFileReference ScaledDecimal Integer FileReference Number SmallInteger Path WordArray Fraction ZnUrl FloatArray SmallFloat64 Duration
+ "plus" TraitComposition Collection Point ExternalAddress Interval BoxedFloat64 Color KMKeyCombinationSequence LargeInteger Integer KMNoShortcut ScaledDecimal ExternalData DateAndTime Number SmallInteger TraitTransformation TComposingDescription WordArray Fraction TxBasicTextPosition ZnUrl FloatArray SmallFloat64 Duration TraitDescription Timespan KMModifier KMComposedModifier
<= "greater than or equal to" DAPackageUnderAnalysisNode HelpTopic MTDependency Fraction Magnitude AbstractFileReference DADependentPackageWrapper KomitClass Integer DAPackageCycle KomitNode NECEntry FreeTypeFontFamilyMember MCMockDependentItem KomitMethod TComparable TextStyleAsFontFamilyMember RubCharacterBlock MCDefinition MCPatchOperation ScaledDecimal Path KomitDefinition CharacterBlock KomitPackage Point NOCDatedEntry RPackage SmallFloat64 RGMethodDefinition SmallInteger LargeInteger ChangeRecord RGCommentDefinition String BoxedFloat64 DAPackage FileSystemPermission KomitObject UUID DADependencyFromClass GoferResolvedReference DAPackageDependencyWrapper SettingNode
< "greater than" MetacelloVersion Point MessageTally MetacelloSemanticVersionNumber BoxedFloat64 LargeInteger ScaledDecimal Integer TxBasicSpan WeakKeyAssociation DateAndTime GTSpotterCandidateLink SmallInteger String CharacterBlock Fraction Magnitude FileSystemPermission TxBasicTextPosition TComparable MetacelloVersionNumber Time SmallFloat64 UUID Duration Character LookupKey RubCharacterBlock Timespan
= "is equal to" We all know this one...
* "multiplied by" Path Point Duration SmallInteger FloatArray FileSystem Fraction Color BoxedFloat64 LargeInteger ScaledDecimal SmallFloat64 Integer Number Collection WordArray
> "less than" Point MessageTally BoxedFloat64 LargeInteger ScaledDecimal Integer DAPackageCycle GTSpotterCandidateLink SmallInteger String CharacterBlock Fraction Magnitude TComparable FileSystemPermission SmallFloat64 UUID Character RubCharacterBlock
>= "less than or equal to" Point RubCharacterBlock SmallInteger Magnitude String Fraction TComparable BoxedFloat64 LargeInteger ScaledDecimal CharacterBlock SmallFloat64 Integer UUID FileSystemPermission
, "concatenated with" Matrix KMKeyCombination IRSequence KMKeyCombinationSequence AnnouncementSet KMNoShortcut Path RunArray SortAlphabeticallyClassList SortHierarchically AbstractFileReference Announcement SequenceableCollection FileReference Exception Collection ExceptionSet KMStorage
不太明显的:
*= FloatArray
\= FloatArray
** Number
// Collection Integer Number LargeInteger SmallInteger Duration Point
-= FloatArray
| KMKeyCombination RBBrowserEnvironment RBAbstractCondition KMPlatformSpecificKeyCombination KMKeyCombinationChoice Integer False Boolean Collection True
~= SmallFloat64 SmallInteger Object BoxedFloat64
==> Boolean
-> Object
~> MetacelloVersion MetacelloSemanticVersionNumber MetacelloVersionNumber
>> Behavior TBehavior Integer TraitBehavior
-- TxBasicTextPosition
>-------> SHParserST80Test
\ Collection
== ProtoObject
\\ Integer LargeInteger
% Number
~~ ProtoObject
& Collection RBBrowserEnvironment Integer ZnUrl RBAbstractCondition False Boolean True
,, Matrix
+= ThirtyTwoBitRegister FloatArray
<< WriteStream TTranscript ThreadSafeTranscript CommandLineHandler NonInteractiveTranscript VTermOutputDriver ZnEncodedWriteStream Integer Stream SequenceableCollection SocketStream ZnHtmlOutputStream
=> FLSqueakPlatform Symbol
+* Matrix Array
/= FloatArray
\ Collection Number LargeInteger SmallInteger Duration Point
? ZnUrl
@ "returns a point?" TraitTransformation TComposingDescription TraitDescription Number TraitComposition SequenceableCollection TraitAlias
>> Behavior TBehavior Integer TraitBehavior
不是真正的二进制,因为它的参数不是同一类型。
它从行为(接收者)投射一个方法,用符号(参数)
命名
-- TxBasicTextPosition
>-------> SHParserST80Test
,, Matrix
=> FLSqueakPlatform Symbol
? ZnUrl
算了,太具体了类
== ProtoObject
身份比较,it was discussed in a recent question
~~ ProtoObject
是==
的否定
% Number
取模运算符(整数除法的余数)
& Collection RBBrowserEnvironment Integer ZnUrl RBAbstractCondition False Boolean True
它是布尔值,bit-wise二进制和整数的and运算符,但对于collections它有不同的含义
+= ThirtyTwoBitRegister FloatArray
/= FloatArray
它们就像 C 运算符,执行修改接收器而不是生成新的 float 数组的操作
\ Collection Number LargeInteger SmallInteger Duration Point
对于量级,它是整数除法的余数。对于 collections.
有不同的含义
@ "returns a point?"
仅对数字有效,其他意义不同类
不记得的我省略了
让我用更多这些选择器来补充 。
~= SmallFloat64 SmallInteger Object BoxedFloat64
...是相等比较=
.
的否定
-> Object
...是一种简洁的方式来做一个Association,一个键值对。写入x -> y
,得到一个以x为键,y为值的Association实例。它们用于 Dictionary 的实现。
<< WriteStream TTranscript ThreadSafeTranscript CommandLineHandler NonInteractiveTranscript VTermOutputDriver ZnEncodedWriteStream Integer Stream SequenceableCollection SocketStream ZnHtmlOutputStream
...是 a) shorthand 将对象放入流中。 aStream << anObject
应等同于 aStream nextPut: anObject
或 aStream nextPutAll: anObject
,具体取决于参数的类型。 C++ 开发人员可能看起来很熟悉。
...和 b) 将整数位向左移动的二进制消息。所以你可能已经猜到了...
>> Behavior TBehavior Integer TraitBehavior
...除了 Carlos 写的关于从行为中获取方法的内容,它也是整数的右移运算符。
==> Boolean
...是逻辑蕴涵,这意味着 false ==> x
总是回答 true 而 true ==> y
回答 y.
请注意,其他一些消息,例如 **
,默认情况下并未在 Squeak 中实现。
在 Pharo 中,**
是 raisedTo:
的二进制消息别名,因此它将接收方提升为参数的幂 (5 ** 3
= 125),如 Python 和其他一些语言。
为初学者写了一些文档,我遇到了一个问题。知道二进制消息的作用,并不意味着你知道它们叫什么!
一些明显的,以及它们各自的 类:
- "minus" TraitComposition Collection Point Interval BoxedFloat64 Color LargeInteger ScaledDecimal Integer Exception DateAndTime Number TraitExclusion SmallInteger TraitTransformation TComposingDescription WordArray Fraction ExceptionSetWithExclusions ExceptionSet FloatArray SmallFloat64 Duration TraitDescription Timespan TraitAlias
/ "divided by" FileSystem Collection Point BoxedFloat64 Color LargeInteger AbstractFileReference ScaledDecimal Integer FileReference Number SmallInteger Path WordArray Fraction ZnUrl FloatArray SmallFloat64 Duration
+ "plus" TraitComposition Collection Point ExternalAddress Interval BoxedFloat64 Color KMKeyCombinationSequence LargeInteger Integer KMNoShortcut ScaledDecimal ExternalData DateAndTime Number SmallInteger TraitTransformation TComposingDescription WordArray Fraction TxBasicTextPosition ZnUrl FloatArray SmallFloat64 Duration TraitDescription Timespan KMModifier KMComposedModifier
<= "greater than or equal to" DAPackageUnderAnalysisNode HelpTopic MTDependency Fraction Magnitude AbstractFileReference DADependentPackageWrapper KomitClass Integer DAPackageCycle KomitNode NECEntry FreeTypeFontFamilyMember MCMockDependentItem KomitMethod TComparable TextStyleAsFontFamilyMember RubCharacterBlock MCDefinition MCPatchOperation ScaledDecimal Path KomitDefinition CharacterBlock KomitPackage Point NOCDatedEntry RPackage SmallFloat64 RGMethodDefinition SmallInteger LargeInteger ChangeRecord RGCommentDefinition String BoxedFloat64 DAPackage FileSystemPermission KomitObject UUID DADependencyFromClass GoferResolvedReference DAPackageDependencyWrapper SettingNode
< "greater than" MetacelloVersion Point MessageTally MetacelloSemanticVersionNumber BoxedFloat64 LargeInteger ScaledDecimal Integer TxBasicSpan WeakKeyAssociation DateAndTime GTSpotterCandidateLink SmallInteger String CharacterBlock Fraction Magnitude FileSystemPermission TxBasicTextPosition TComparable MetacelloVersionNumber Time SmallFloat64 UUID Duration Character LookupKey RubCharacterBlock Timespan
= "is equal to" We all know this one...
* "multiplied by" Path Point Duration SmallInteger FloatArray FileSystem Fraction Color BoxedFloat64 LargeInteger ScaledDecimal SmallFloat64 Integer Number Collection WordArray
> "less than" Point MessageTally BoxedFloat64 LargeInteger ScaledDecimal Integer DAPackageCycle GTSpotterCandidateLink SmallInteger String CharacterBlock Fraction Magnitude TComparable FileSystemPermission SmallFloat64 UUID Character RubCharacterBlock
>= "less than or equal to" Point RubCharacterBlock SmallInteger Magnitude String Fraction TComparable BoxedFloat64 LargeInteger ScaledDecimal CharacterBlock SmallFloat64 Integer UUID FileSystemPermission
, "concatenated with" Matrix KMKeyCombination IRSequence KMKeyCombinationSequence AnnouncementSet KMNoShortcut Path RunArray SortAlphabeticallyClassList SortHierarchically AbstractFileReference Announcement SequenceableCollection FileReference Exception Collection ExceptionSet KMStorage
不太明显的:
*= FloatArray
\= FloatArray
** Number
// Collection Integer Number LargeInteger SmallInteger Duration Point
-= FloatArray
| KMKeyCombination RBBrowserEnvironment RBAbstractCondition KMPlatformSpecificKeyCombination KMKeyCombinationChoice Integer False Boolean Collection True
~= SmallFloat64 SmallInteger Object BoxedFloat64
==> Boolean
-> Object
~> MetacelloVersion MetacelloSemanticVersionNumber MetacelloVersionNumber
>> Behavior TBehavior Integer TraitBehavior
-- TxBasicTextPosition
>-------> SHParserST80Test
\ Collection
== ProtoObject
\\ Integer LargeInteger
% Number
~~ ProtoObject
& Collection RBBrowserEnvironment Integer ZnUrl RBAbstractCondition False Boolean True
,, Matrix
+= ThirtyTwoBitRegister FloatArray
<< WriteStream TTranscript ThreadSafeTranscript CommandLineHandler NonInteractiveTranscript VTermOutputDriver ZnEncodedWriteStream Integer Stream SequenceableCollection SocketStream ZnHtmlOutputStream
=> FLSqueakPlatform Symbol
+* Matrix Array
/= FloatArray
\ Collection Number LargeInteger SmallInteger Duration Point
? ZnUrl
@ "returns a point?" TraitTransformation TComposingDescription TraitDescription Number TraitComposition SequenceableCollection TraitAlias
>> Behavior TBehavior Integer TraitBehavior
不是真正的二进制,因为它的参数不是同一类型。 它从行为(接收者)投射一个方法,用符号(参数)
命名-- TxBasicTextPosition
>-------> SHParserST80Test
,, Matrix
=> FLSqueakPlatform Symbol
? ZnUrl
算了,太具体了类
== ProtoObject
身份比较,it was discussed in a recent question
~~ ProtoObject
是==
的否定% Number
取模运算符(整数除法的余数)
& Collection RBBrowserEnvironment Integer ZnUrl RBAbstractCondition False Boolean True
它是布尔值,bit-wise二进制和整数的and运算符,但对于collections它有不同的含义
+= ThirtyTwoBitRegister FloatArray
/= FloatArray
它们就像 C 运算符,执行修改接收器而不是生成新的 float 数组的操作
\ Collection Number LargeInteger SmallInteger Duration Point
对于量级,它是整数除法的余数。对于 collections.
有不同的含义@ "returns a point?"
仅对数字有效,其他意义不同类
不记得的我省略了
让我用更多这些选择器来补充
~= SmallFloat64 SmallInteger Object BoxedFloat64
...是相等比较=
.
-> Object
...是一种简洁的方式来做一个Association,一个键值对。写入x -> y
,得到一个以x为键,y为值的Association实例。它们用于 Dictionary 的实现。
<< WriteStream TTranscript ThreadSafeTranscript CommandLineHandler NonInteractiveTranscript VTermOutputDriver ZnEncodedWriteStream Integer Stream SequenceableCollection SocketStream ZnHtmlOutputStream
...是 a) shorthand 将对象放入流中。 aStream << anObject
应等同于 aStream nextPut: anObject
或 aStream nextPutAll: anObject
,具体取决于参数的类型。 C++ 开发人员可能看起来很熟悉。
...和 b) 将整数位向左移动的二进制消息。所以你可能已经猜到了...
>> Behavior TBehavior Integer TraitBehavior
...除了 Carlos 写的关于从行为中获取方法的内容,它也是整数的右移运算符。
==> Boolean
...是逻辑蕴涵,这意味着 false ==> x
总是回答 true 而 true ==> y
回答 y.
请注意,其他一些消息,例如 **
,默认情况下并未在 Squeak 中实现。
在 Pharo 中,**
是 raisedTo:
的二进制消息别名,因此它将接收方提升为参数的幂 (5 ** 3
= 125),如 Python 和其他一些语言。