 
 : new-grid ( children class -- grid )
     new-gadget
-        swap >>grid
-        dup grid>> concat add-gadgets ; inline
+        swap [ >>grid ] [ concat add-gadgets ] bi ; inline
 
 : <grid> ( children -- grid )
     grid new-grid ;

    dupd add-gaps dim-sum v+ ;

M: grid pref-dim*
    [ gap>> ] [ compute-grid ] bi
    [ gap-sum ] bi-curry@ bi (pair-up) ;

: do-grid ( dims grid quot -- )
    [ grid>> ] dip '[ _ 2each ] 2each ; inline

    ] if ;

: grid-layout ( grid horiz vert -- )
    [ position-grid ] [ resize-grid ] 3bi ;

M: grid layout* dup compute-grid grid-layout ;

M: grid children-on ( rect gadget -- seq )
    dup children>> empty? [ 2drop f ] [
        { 0 1 } swap grid>>
        [ 0 <column> fast-children-on ] keep
        <slice> concat
    ] if ;

M: grid gadget-text*
    grid>>
