Search code examples
smalltalksqueakpharovisualworks

What is the "best practice" portable way of Symbol using in Smalltalk?


What are the "best practice" rules for using symbols in Smalltalk in a portable way? I use squeak and pharo mainly and I know they both allow 'foo' = #foo and #foo = 'foo' to be true while other Smalltalks don't. I understand Symbols are for identification and shouldn't be used in place of strings. But is it at least safe to assume that a symbol object is a collection that can be sent messages like copyWith: or do:, or must you convert it some kind of Collection first?

Any advice would be appreciated.


Solution

  • The rule we follow with Seaside is not to mix Symbols and Strings. Like this you avoid the problem. Not on all platforms a symbol is a subclass of String, so you have to be careful with #copyWith: or #do:.

    I use symbols only as a cheap token that you compare with other symbols. I wouldn't use symbols for anything else.