[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Help-smalltalk] iliad and blocks
From: |
Paolo Bonzini |
Subject: |
Re: [Help-smalltalk] iliad and blocks |
Date: |
Mon, 22 Jun 2009 14:48:49 +0200 |
>> Joachim builds a PageTemplate widget, and I'm not sure I like the idea
>> of returning blocks from the methods there (like #mainContent).
>
> Why don't you like it? I think blocks are expressive and less verbose
> here.
They *are* good as a shortcut, especially since you cannot afford an
extra argument to the view messages (like #indexOn: -- that would be
ugly!).
I just don't think that using #value: as "the" protocol for rendering
is clean, because it makes it harder to return some other object in a
polymorphic way (for example a widget itself). If everything has
to implement #value: sooner or later you run into conflicts, or into
something that expects more protocol from BlockClosure.
It just leads to hacks like the infamous Symbol>>value: method. If it
was me, I would not even call #value: from
#select:/#reject:/#collect:. I would use two methods, one for
#select:/#reject: and one for #collect:, and then implement those on
Symbol, Regex, and whatever else. This would allow things like:
'paolo' select: #($a $e $i $o $u $y) -> 'aoo'
#('paolo' 'bar' 'baz') collect: '(.a)[oz]' -> #('pa' nil 'ba')
#('paolo' 'bar' 'baz') select: 'a..' asRegex -> #('paolo')
(Of course, finding good names for the methods would be another thing.
That's why the above idea is not in GNU Smalltalk yet...).
Paolo
- [Help-smalltalk] iliad and blocks, Paolo Bonzini, 2009/06/22
- Re: [Help-smalltalk] iliad and blocks, Joachim Jaeckel, 2009/06/22
- Message not available
- Re: [Help-smalltalk] iliad and blocks,
Paolo Bonzini <=
- Message not available
- Re: [Help-smalltalk] iliad and blocks, Paolo Bonzini, 2009/06/22
- Re: [Help-smalltalk] iliad and blocks, Nicolas Petton, 2009/06/22
- Re: [Help-smalltalk] iliad and blocks, Paolo Bonzini, 2009/06/22
- Re: [Help-smalltalk] iliad and blocks, Nicolas Petton, 2009/06/22
- Re: [Help-smalltalk] iliad and blocks, Janko Mivšek, 2009/06/22
- Re: [Help-smalltalk] iliad and blocks, Lukas Renggli, 2009/06/22
- [Help-smalltalk] Re: iliad and blocks, Paolo Bonzini, 2009/06/22