A provocative naming idea for "setter" methods

Rastislav Kassak kasou.sk at gmail.com
Fri Sep 23 04:12:37 PDT 2005


Even more provocative idea:

Brian, you are familiar with this blog post
http://www.cincomsmalltalk.com/userblogs/mls/blogView?showComments=true&title=Language+Evolution&entry=3295244449
I've found it today. One of the discussed inprovements in Smalltalk
was automatic creation of instance variables.
You has opposed against that idea as there is trouble with message not
understand exception vs. automatic slot creation.
What do you think about it when we are going to have different syntax
for setter methods? Could it be possible to automaticaly create slot
only if unknown setter method has been invoked? Simply exception
handler will call #addSlot:valued:.

This reminds me some another newbie question.
I will again show example in Ruby. I'm no Ruby zealot, just beginner,
bud I really like some concepts.
Lazy cached evaluation (maybe it has some better name :)) is really
concise in Ruby. Just define getter method this way:
def someProperty
  @someProperty ||= evaluateSomeProperty
end
Fisrt time, it is called, @someProperty (instance variable) evaluates
to Nil, as there is no such variable defined. Therefore ||= operator
start evaluation of expression on right side, and stores result in
@someProperty and returns it.
Next time this getter method is called, @someProperty is already
defined and contains previously evaluated data, so right expresion
doesn't need to be evaluated second time.

This pattern is quite common, at least we use it in our projects.
What's the best way to make this work in Slate? Is there (could be)
some @addLazySlot:[#name]valued:[evaluation block]?
I think it is very helpful and maybe some top level implementation is
quite easy.

What do you think?




More information about the Slate mailing list