[squeak-dev] Re: The Trunk: Kernel-eem.474.mcz
andreas.raab at gmx.de
Fri Jul 23 05:39:23 UTC 2010
On 7/22/2010 10:24 PM, Eliot Miranda wrote:
> What's "wrong", or at least not as nice, is the variable and its
> declaration. The [expr] once form is entirely self-contained whereas
> the SomeResource ifNil: [self initializeResource] is accompanied with a
> variable declaration somewhere else. I also like (but haven't seen
> used) the notion of having variations on once such as onceInEverySession
> which can again provide the necessary void-on-startup hook without any
> explicit registering in a start-up list.
I think your example wasn't very well chosen. Resource initialization is
something where I very much prefer the explicit initialization approach
offered by ^VarName ifNil:[...] because resources are often also
something where you need to track and invalidate them and having a
random method hold onto something that you need to track down from
elsewhere is just unnecessarily harder than having an explicit variable
that you can assign to.
However, I do take Travis' point about compile time expressions. Here
the whole point is that you really want the expression to be reevaluated
when the defining code changes which is not easily done the above (it's
possible but bothersome).
> I do take your point about it being a hack, but its a neat hack.
More information about the Squeak-dev