Cascading ?

Lukas Renggli renggli at gmail.com
Thu Aug 17 11:14:35 UTC 2006


> > Because it is ambiguous. How should the compiler know if it should
> > send #readyToContinue to 'test' or the result of 'test
> > storageStrategy'?
>
> It would be interesting to find a language construct which does support
> Damien's expression. Not that I want everybody to write as much cascades
> as possible but, I want to be able to do so.

I think #in: is a good solution for that particular problem. I use it
sometimes with Seaside and script.aculo.us, both frameworks make
extensive use of cascades to build and configure html-tags and
JavaScript objects.

An example: The CSS class 'red' is only added, if a specific condition is met.

html div
     id: 'foo';
     class: 'border';
     in: [ :tag | condition ifTrue: [ tag class: 'red' ] ];
     with: 'contents'

However, as the code doesn't make me feel cosy I added a helper method
to the receiver of the cascade. After the refactoring (yeah, a
refactoring, not an change ... I finally got it, yeah, yeah, ...) it
looks like:

html div
     idd: 'foo';
     class: 'border';
     class: 'red' if: condition;
     with: 'contents'

Such a refactoring can be always applied and is probably better
practice than to start using blocks ...

Lukas

-- 
Lukas Renggli
http://www.lukas-renggli.ch



More information about the Squeak-dev mailing list