Slava,
Consider these conventions:
TUPLE: point x y z ;
* The default constructor is named <point*>
* There is no 'C:' syntax. The programmer manually defines a 'nice'
constructor in terms of the default constructor.
* set-delegate effect is ( instance delegate -- instance )
* Slot writer effect is ( instance value -- instance )
I did a survey of constructor implementation, via:
\ set-delegate usage [ see ] each
I'm still investigating, but every one I considered was simplified by these
conventions.
While you were on vacation, I was working on alternative versions of
combinators. In each case, there was a 'focal' word which tied things
together and tended to do no shuffling. In designing Factor code, I'm now
thinking in terms of 'focal words' and 'non focal words'. I think
set-delegate and tuple slot writers are obviously 'non focal words' and they
should bear the burden of shuffling the stack for the common case. On the
other hand, non-default constructors are focal words and can be made simpler
by the above conventions.
The design culture so far has been to make words that don't leave things on
the stack 'unnecessarily'. We craft each word as functions in the old world;
use the parameters, perform the work, and only return values in question, if
any. I think it's time to break this habit.
Going with the point example above, it may also be helpful to have a 'null
constructor' defined where each slot is 'f':
: <point~> ( -- point )
Ed
-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
Factor-talk mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/factor-talk