: a ( foo -- ) ... ;

: b ( foo -- ) ... ;

: c ( foo -- ) ... ;

If you have words like those and they mutate the foo in some way, consider 
defining them with effects like so:

: a ( foo -- foo ) ... ;

: b ( foo -- foo ) ... ;

: c ( foo -- foo ) ... ;

I think these are "pipe" stack effects because...

<foo> a b c 

That is much nicer than

<foo> dup a dup b dup c

This goes against the established convention in the Factor code base.

If you have setters like these:

: set-x ( foo val -- ) ... ;

: set-y ( foo val -- ) ... ;

: set-z ( foo val -- ) ... ;

Consider these instead:

: set-x ( foo val ... val ) ... ;

: set-y ( foo val ... val ) ... ;

: set-z ( foo val ... val ) ... ;

Because

<foo> 10 set-x 20 set-y 30 set-z

is nicer than

<foo> 10 dupd set-x 20 dupd set-y 30 dupd set-z

Or

30 20 10 <foo> [ set-x ] keep [ set-y ] keep [ set-z ] keep

if they have stack effects like the tuple setters do.

Note that the "nice" examples approach the appearance of Smalltalk message 
sending.

These conventions aren't always applicable, but they work well sometimes.

A case where these would work well is in libs/x/widgets.factor as well as any 
place that defines a widget.

( object delegate -- object )
over set-delegate dup add-to-window-table { mask... } over select-input

This would look nicer with these stack effects:

: set-delegate ( object delegate -- object )

: add-to-window-table ( win -- win )

: select-input ( win mask -- win )

The new expression:

( object delegate -- object )
set-delegate add-to-window-table { mask } select-input

Ed

-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Factor-talk mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/factor-talk

Reply via email to