演算子(みたいなもの)
当たり前すぎて、今まで注意してみたことがなかった。
| a b | a := 20. b := 6. Transcript show: 'arithmetic operator -------'; cr; show: (a + b) printString; cr; "和" show: (a - b) printString; cr; "差" show: (a * b) printString; cr; "積" show: (a / b) printString; cr; "Integer的ななにか or Fraction" show: (a // b) printString; cr; "商" show: (a \\ b) printString; cr; "剰余" show: (a @ b) printString; cr; "Point" show: (a -> b) printString; cr; "Association" cr. a := 1. b := 1. Transcript show: 'comparing operator (number) -------'; cr; show: (a = b) printString; cr; show: (a == b) printString; cr; show: (a ~= b) printString; cr; show: (a ~~ b) printString; cr; cr. a := 'abc'. b := 'abc'. Transcript show: 'comparing operator (string) -------'; cr; show: (a = b) printString; cr; show: (a == b) printString; cr; show: (a ~= b) printString; cr; show: (a ~~ b) printString; cr; cr.
他にも、算術演算子で#\\\なんてのもあった。
割り算とか剰余とかがもっとややこしかったように思ったけど、それはHaskellの話だっけか。
文字列の#==が、SqueakとVisualWorksでは結果が異なる。というか、Squeakでtrueが返ってくるのはなんでか。
| a aLiteral aShallow aDeep | a := 'abcde'. aLiteral := 'abcde'. aShallow := a shallowCopy. aDeep := a deepCopy. "VW => #dcopy" Transcript clear; show: a identityHash printString; cr; show: aLiteral identityHash printString; cr; show: aShallow identityHash printString; cr; show: aDeep identityHash printString; cr; show: (a == aLiteral) printString; cr; show: (a == aShallow) printString; cr; show: (a == aDeep) printString; cr; cr. a := #abcdefg. aLiteral := #abcdefg. aShallow := a shallowCopy. aDeep := a deepCopy. "VW => #dcopy" Transcript show: '-----------------------------------'; cr; show: a identityHash printString; cr; show: aLiteral identityHash printString; cr; show: aShallow identityHash printString; cr; show: aDeep identityHash printString; cr; show: (a == aLiteral) printString; cr; show: (a == aShallow) printString; cr; show: (a == aDeep) printString; cr; cr.
リテラルが同一だった場合の動作が予想外な感じ。