While quotations are sequences, in order for the stack-checker to infer the proper effect for combinators, you can't call append on two quotations, you must call compose instead. Likewise with suffix/prefix, you should call curry.

For what I undertood and learned, "quotations" and "sequences" are equal when used as data, but quotations acted very differenct when used as codes.

"quotations" like anonymous function in function paradigm, are executable, so, in factor philosophy, they must be checked for stack effects when complied, that requirement ruled out the simple usage of sequence operation words on them.

But I wondered if simple usage of append is feasible in Syntax definition, that means there is no strong requirement of stack effect check when parsing and building the lexer?

Thanks.
To put it all together, look at a parse-time example, SYNTAX: definition:

IN: syntax
SYNTAX: SYNTAX: scan-new-word parse-definition define-syntax ;

: parse-definition ( -- quot ) \ ; parse-until >quotation ;

: define-syntax ( word quot -- )
    [ drop ] [ define ] 2bi t "parsing" set-word-prop ;

What's happening here is that, at parse-time, you create a new word, parse its definition until the semi-colon, and then convert that into a quotation. So all your suffix! and append! are really creating an array of code at parse-time and then, since converting between sequence types makes sense, you convert that array to a quotation. Since this happens at parse-time, it's safe to do this--you do not need compose/prepose and curry. Finally, setting the "parsing" property tells the parser that your new SYNTAX: is a parsing word.

I hope this helps, and please ask any followup questions!

Doug


    
------------------------------------------------------------------------------
    Download BIRT iHub F-Type - The Free Enterprise-Grade BIRT Server
    from Actuate! Instantly Supercharge Your Business Reports and
    Dashboards
    with Interactivity, Sharing, Native Excel Exports, App Integration
    & more
    Get technology previously reserved for billion-dollar
    corporations, FREE
    http://pubads.g.doubleclick.net/gampad/clk?id=164703151&iu=/4140/ostg.clktrk
    _______________________________________________
    Factor-talk mailing list
    Factor-talk@lists.sourceforge.net
    <mailto:Factor-talk@lists.sourceforge.net>
    https://lists.sourceforge.net/lists/listinfo/factor-talk



------------------------------------------------------------------------------
Download BIRT iHub F-Type - The Free Enterprise-Grade BIRT Server
from Actuate! Instantly Supercharge Your Business Reports and Dashboards
with Interactivity, Sharing, Native Excel Exports, App Integration & more
Get technology previously reserved for billion-dollar corporations, FREE
http://pubads.g.doubleclick.net/gampad/clk?id=164703151&iu=/4140/ostg.clktrk


_______________________________________________
Factor-talk mailing list
Factor-talk@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/factor-talk

------------------------------------------------------------------------------
Download BIRT iHub F-Type - The Free Enterprise-Grade BIRT Server
from Actuate! Instantly Supercharge Your Business Reports and Dashboards
with Interactivity, Sharing, Native Excel Exports, App Integration & more
Get technology previously reserved for billion-dollar corporations, FREE
http://pubads.g.doubleclick.net/gampad/clk?id=164703151&iu=/4140/ostg.clktrk
_______________________________________________
Factor-talk mailing list
Factor-talk@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/factor-talk

Reply via email to