[Seaside] Using closures to create continuations
avi.bryant at gmail.com
Fri Mar 25 16:02:08 CET 2005
> On Mar 25, 2005, at 4:29 AM, Andrei N.Sobchuck wrote:
> > Java and C# 2.0 supports closures.
> > Is it possible to make seaside-like framework
> > using only closures?
> > What if instead of #call: will be used #call:onAnswer:
> > with a closure as second argument?
> > Is there any pitfalls?
Certainly #call:onAnswer: would work, but it would suffer from the
usual problem of continuation-passing-style: it's "viral", in that
every method that sends a message like that has to use the same
confirm: aString onAnswer: aBlock
self call: (WAConfirmationDialog message: aString) onAnswer: aBlock
self confirm: 'Do you really want to delete that?' onAnswer:
ifTrue: [self reallyDelete. aBlock value]
ifFalse: [aBlock value]]
And so on. Not to mention that in Java the above example would be
about 50 lines long and have 17 casts because anonymous inner classes
are so verbose.
So, I don't think that's really a viable solution, at least not
without code transformation (look for a paper subtitled "Growing GUIs
on Trees" for an example of that).
I do think implementing a Seaside-like framework in Java or C# (along
with full back button support) would be an interesting challenge, and
I think I could come up with some ways to preserve most of the feel of
using Seaside without requiring bytecode hacking or code
transformation - but I don't really have time to pursue them further
unless I decide to write an article about it (unlikely) or someone is
serious enough about wanting such a framework to contract with me to
design it (even more unlikely?).
More information about the Seaside