tag:blogger.com,1999:blog-5135517.post3147209312597270285..comments2023-11-05T03:54:44.710-08:00Comments on Making it stick.: SymbolsPatrick Loganhttp://www.blogger.com/profile/02088461489050417591noreply@blogger.comBlogger2125tag:blogger.com,1999:blog-5135517.post-35897807944294642992008-08-01T12:07:00.000-07:002008-08-01T12:07:00.000-07:00In Smalltalk a symbol is #foo.In Lisp a symbol is ...In Smalltalk a symbol is #foo.<BR/><BR/>In Lisp a symbol is 'foo.<BR/><BR/>They evaluate to themselves, i.e the result of...<BR/><BR/>(eval 'foo) is foo.<BR/><BR/>The advantage is you just use symbols, you don't have to create predefined sets of symbols, as you do with enums. Most of the time this is sufficient.<BR/><BR/>When you do want to ensure some symbol is in some predefined set, you just create a Set of them in Smalltalk, or a list of them in Lisp.<BR/><BR/>If you want to associate a value like an integer with a symbol, in Smalltalk you create a Dictionary that maps from symbol to integer. In Lisp you create either a hash or an association list from symbol to integer.Patrick Loganhttps://www.blogger.com/profile/02088461489050417591noreply@blogger.comtag:blogger.com,1999:blog-5135517.post-61247443611484419982008-08-01T10:36:00.000-07:002008-08-01T10:36:00.000-07:00The screen cast only showed that they are interned...The screen cast only showed that they are interned strings. How are they typically used in Smalltalk? I don't really see the connection between them and enums - enums restrict client code to a fixed set of values whereas interned strings have an unrestricted value space.Pete Kirkhamhttps://www.blogger.com/profile/17321624014729731964noreply@blogger.com