|
From: Slava P. <sl...@fa...> - 2007-07-17 20:08:47
|
Hi Eduardo,
Most tuple constructors do the following things only:
- Set the delegate
- Set slot values from the stack
- Set slot values to some default value
Perhaps this can be incorporated into the TUPLE: form, then we won't
need most C:'s at all?
On a completely unrelated note, I saw an interesting feature in the
latest PowerMOPS release. PowerMOPS uses the Neon object system which
is also found in Win32Forth.
They added a 'cascading send' syntax which looks like this:
someMessage: { obj1 obj2 obj3 }
Which is the same as
someMessage: obj1
someMessage: obj2
someMessage: obj3
Slava
On 16-Jul-07, at 5:58 PM, Eduardo Cavazos wrote:
> 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
> Fac...@li...
> https://lists.sourceforge.net/lists/listinfo/factor-talk
|