[Date Prev] [Date Next] [Thread Prev] [Thread Next] Date Index Thread Index Search archive:
Date:Mon Dec 22 14:13:51 1992 
Subject:Re: POP syntax 
From:Steve Knight 
Volume-ID:921223.02 

Continuing Ian Rogers transliteration from C-syntax to POP-syntax ...

Robin Popplestone's original, with correction and standard whitespace and
indentation :-

    maplist( x, f ) { 
        null( x ) ? [] : f( hd( x ) ) :: maplist( tl( x ), f )
    }

And here's Ian Rogers POP version, modified to use -null- (because that's
an error in Robin's code) _but_ using the dot notation for elegance.

    define maplist( x, f ); 
        x.null and [] or x.hd.f :: maplist( x.tl, f ) 
    enddefine;

Not surprisingly, when we lay out the code correctly, we find that the
POP code is more concise and visually simpler.  This situation is 
reversed when we add in the obligatory "lvars" declarations, alas.
Here's the kicker ...

    define maplist( x, f ); 
        lvars x, f;                                   ;;; pointless.
        x.null and [] or x.hd.f :: maplist( x.tl, f )
    enddefine;

These extra declarations are pointless clutter forced upon the reader
by historical changes within POP-11.  Unfortunately, the reader _must_
read these declarations and understand their meaning, since any
change leads to a massive change in semantics.  (In fact, the first two
versions of maplist given here are completely wrong because of the 
omitted declarations.  The arguments default to "vars" and therefore
wrongly mask other top-level declarations of -x- and -f- during the
invocations of the procedure -f-.)

To my mind, Ian has produced a nice little demonstration -- by comparison
with another programming language -- why obligatory declarations are 
harmful to POPs syntax.  The obvious solution that has been suggested to
me very frequently (as Pop9x coordinator) is to make the default
declaration "lvars".  And I see this as very sensible.  

Steve