[Date Prev] [Date Next] [Thread Prev] [Thread Next] Date Index Thread Index Search archive:
Date:Mon Feb 10 14:59:38 1998 
Subject:Neat infix idiom 
From:Steve Knight 
Volume-ID:980210.01 

Here's a nice Pop11 idiom that may appeal .... (actually I'm
just testing the list but thought I ought to post something
useful)

    define syntax 10 @;
        pop_expr_inst( pop_expr_item );
        pop11_FLUSHED -> pop_expr_inst;
        lvars operator = readitem();
        if operator == termin then
            mishap( 'Unexpected end of input after "@" operator', [] )
        else
            pop11_comp_prec_expr( 171, false ).erase;
            sysCALL( operator )
        endif
    enddefine;

This defines "@" to be a syntax word that 'infixes' the next
token with a predence that is slightly more binding than "and"
and slightly less binding than "matches".  

The elegance of this is best seen in expressions such as 

        f( x ) @conspair L -> L

or 

        L @maplist nonop +(%1%)

and so on.

Enjoy!

Steve