Cascading ?

Klaus D. Witzel klaus.witzel at cobss.com
Thu Aug 17 11:28:17 UTC 2006


This is one of the best examples of a) lack of *language* support; b)  
quick&dirty solution using blocks; c) refactoring; sequence that I've ever  
seen :)

Thank you for posting this one, Damien & Lukas.

/Klaus

On Thu, 17 Aug 2006 13:14:35 +0200, Lukas Renggli wrote:

>> > 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
>





More information about the Squeak-dev mailing list