Bruce & Breeanna Rennie wrote:

> One question I raise for you is how hard (or easy) would it
> be to make the initial value to be a quotation that would be dynamically
> executed at tuple creation time?

Hello,

This would make for simpler constructors in some cases. In some code, you'll 
see that slot initialization is factored out. This could be done away with if 
the tuple declaration allowed for an "initial expression" to be specified. 
One example is the editor gadget. Here's the current tuple, constructor, and 
slot initialization code:

----------------------------------------------------------------------
TUPLE: editor
self
font color caret-color selection-color
caret mark
focused? ;

: <loc> ( -- loc ) { 0 0 } <model> ;

: init-editor-locs ( editor -- )
    <loc> over set-editor-caret
    <loc> swap set-editor-mark ;

: editor-theme ( editor -- )
    black over set-editor-color
    red over set-editor-caret-color
    selection-color over set-editor-selection-color
    monospace-font swap set-editor-font ;

: <editor> ( -- editor )
    <document> <gadget> editor construct-control
    dup dup set-editor-self
    dup init-editor-locs
    dup editor-theme ;
----------------------------------------------------------------------

If the tuple were described as follows:

TUPLE: editor
  self
  { font            [ monospace-font ] }
  { color           [ black ] }
  { caret-color     [ red ] }
  { selection-color [ selection-color ] }
  { caret           [ <loc> ] }
  { mark            [ <loc> ] } ;

The 'init-editor-locs' and 'editor-theme' word wouldn't be needed. In fact, 
they're only used by '<editor>'.

I think it would be good to scan the codebase for more potential applications 
of this feature. If there are enough places where it could be used, maybe 
there'll be a case for it.

Ed

-------------------------------------------------------------------------
Sponsored by: SourceForge.net Community Choice Awards: VOTE NOW!
Studies have shown that voting for your favorite open source project,
along with a healthy diet, reduces your potential for chronic lameness
and boredom. Vote Now at http://www.sourceforge.net/community/cca08
_______________________________________________
Factor-talk mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/factor-talk

Reply via email to