[Newbies] getters, setters, attr?

Ramon Leon ramon.leon at allresnet.com
Fri Sep 8 15:25:40 UTC 2006

> My (naive) understanding is that somehow this DSL-like style 
> does not appear to have become popular in the Smalltalk 
> world. Is that true?

That's because this style relies on the fact that Ruby programs are text, in
a file, that get's run to create a live environment.  During this run phase,
those call's expand into getters and setters, similar to Lisp macro's.  By
contrast, Smalltalk is always running, you aren't editing text files, you're
editing the live objects directly, essentially the expanded form in
Ruby/Lisp terms.  So this style doesn't really suit Smalltalk.

Smalltalkers would handle dynamic getters and setters by hacking
doesNotUnderstand: and checking a local dictionary for the prop, like
ActiveRecord does, something like...

doesNotUnderstand: aMessage 
    ^self properties at: aMessage selector
        ifAbsent: [super doesNotUnderstand: aMessage]

More information about the Beginners mailing list