Got it working, thanks.

2010/1/15 Philipp Brüschweiler <ble...@gmail.com>

> Am Thu, 14 Jan 2010 23:17:04 -0800
> schrieb Jim mack <j...@less2do.com>:
> > 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
>
> Hi Jim
>
> If I understand you correctly, your intent is that fancyprint will be
> the same as non-macro-way, just with dynamically generated code. If so,
> your problem is that you don't generate a quotation as output of the
> macro, specifically the call to cleave gets executed at parse time.
>
> Here's a correct version (with { } clone swap [ .. suffix ] each
> simplified to map):
>
> MACRO: easier ( alist -- )
>    [ first2 '[ _ write  @ present print ] ] map '[ _ cleave ] ;
>
> For fancyprint to work, you have to declare testing-schema inline, make
> a CONSTANT: out of it or directly write the alist into fancyprint.
>
> Cheers
>
>
> ------------------------------------------------------------------------------
> 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
>



-- 
Jim
"I'm for extending the working Medicare program for our seniors all the way
back to contraception, so Americans can concentrate on living their lives
without fear of changing a job, going bankrupt from deductibles or fighting
HMO bureaucracy."
------------------------------------------------------------------------------
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