Hi.  Can you please help me understand why the final line here results in a
stack underflow?

USING: accessors arrays kernel locals present select8.html classes.tuple
sequences prettyprint fry macros nested-comments combinators ;

TUPLE: testing id firstname lastname age ;
: <testing> ( id fn ln age -- tpl ) testing boa ;
: testdata ( -- tpl ) 1 "jim" "mack" 46 <testing> ;
: testing-schema ( -- seq )
    {   { "First Name " [ firstname>> ] }
        { "Last Name " [ lastname>> ] }
        { "Age " [ age>> ] } } ;

: non-macro-way ( tpl -- )
        {
        [ "First Name " write  firstname>> print ]
        [ "Last Name " write lastname>> print ]
        [ "Age " write  age>> present print ]
        } cleave ;

testdata non-macro-way

! using fry

testdata { } clone
 testing-schema [ first2 '[ _ write  @ present print ] suffix ] each
  cleave

MACRO: easier ( alist -- ) { } clone swap
    [ first2 '[ _ write  @ present print ] suffix ] each cleave ;

: fancyprint ( tpl -- )
        testing-schema easier  ; inline

testdata fancyprint   ! stack underflow
------------------------------------------------------------------------------
Throughout its 18-year history, RSA Conference consistently attracts the
world's best and brightest in the field, creating opportunities for Conference
attendees to learn about information security's most important issues through
interactions with peers, luminaries and emerging and established companies.
http://p.sf.net/sfu/rsaconf-dev2dev
_______________________________________________
Factor-talk mailing list
Factor-talk@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/factor-talk

Reply via email to