About Smalltalk at: .... ifAbsent:/present:

Andreas Raab andreas.raab at gmx.de
Tue Nov 30 13:38:34 UTC 2004


> You know, neither of these is really very satisfying. The first is
> ambiguous. There are any number of reasons why Foo could be nil, and a 
> weak dependency is only one of them. My problem with the second one isn't 
> so much the verbosity, it's that it also says "yes, the caller is well 
> aware that class lookups go through a single global dictionary called 
> Smalltalk." That is, it knows too much about the implementation of the 
> compiler and runtime.
>
> I think it would be nice to have something like this:
>
>     Foo
>         ifPresent: [:foo | foo bar]
> ifAbsent: [self mumble]
>
> This idiom clearly says what it means, "the dependency is a weak one" 
> without saying more than that.

I like it but it's ambigious too if for any reason the value of Foo 
understands the message. The point is that the #ifPresent: message really is 
meta in the sense that it ought to be sent to the variable Foo instead of 
the value Foo.

Cheers,
  - Andreas




More information about the Squeak-dev mailing list