views:

88

answers:

1

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.

+3  A: 

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.

Lukas Renggli
Thank you Lukas for your answer. And thank you also for Pharo, Magritte, Pier, Seaside and all the other great work you do.
julio