"I have a mind like a steel... uh... thingy." Patrick Logan's weblog.

Search This Blog

Thursday, July 31, 2008


Funny how with all the complicated foo around closure in Java, the
language does not yet even have a convenient notation for symbols.
(Note: enums are not convenient.)



Pete Kirkham said...

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.

Patrick Logan said...

In Smalltalk a symbol is #foo.

In Lisp a symbol is 'foo.

They evaluate to themselves, i.e the result of...

(eval 'foo) is foo.

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.

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.

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.

Blog Archive

About Me

Portland, Oregon, United States
I'm usually writing from my favorite location on the planet, the pacific northwest of the u.s. I write for myself only and unless otherwise specified my posts here should not be taken as representing an official position of my employer. Contact me at my gee mail account, username patrickdlogan.