Newsgroups: comp.lang.apl Path: utzoo!utgpu!watserv1!maytag!aftermath!water!ljdickey From: ljdickey@water.waterloo.edu (L.J.Dickey) Subject: Compilability (was: Interesting feature of J) Message-ID: <1990Sep28.155915.2424@water.waterloo.edu> Organization: University of Waterloo References: Date: Fri, 28 Sep 90 15:59:15 GMT Lines: 67 In article josh@klaatu.rutgers.edu (J Storrs Hall) writes: > [...] >Assuming my guess is right, that should make for a notably >easier job for an optimizer trying to do structure-sharing; >it makes one suspect a compiler of some kind is planned. Work on a compiler is now underway at Snake Island Research, Toronto. >(On the other hand, the rest of J seems designed to be as >hard as possible to compile!) Contrary to this appearance, the opposite is probably closer to the truth. Here are two versions of a "nub" function. One mentions the arguments explicitly, and the other makes tacit use of the arguments. The point about the second one is that its execution is done without having to re-parse the function body. Is this not "compilation" ? o=. 0 0 $ ' useful bit of nothingness :-)' comment =. {: & o comment ' Explicit nub (function arguments explicitly mentioned).' nub0 =. '( ( i. # y. ) = i.~ y.) # y.' :: '' nub0 +----------------------------+--++ |( ( i. # y. ) = i.~ y.) # y.|::|| +----------------------------+--++ comment ' A tacit nub (function arguments tacitly assumed).' comment ' Notice that both hook and fork phrasal forms are used.' nub1 =. #~ i.&# = i.~ nub1 +-----+-------------------+ |+-+-+|+--------+-+------+| ||#|~|||+--+-+-+|=|+--+-+|| |+-+-+|||i.|&|#|| ||i.|~||| | ||+--+-+-+| |+--+-+|| | |+--------+-+------+| +-----+-------------------+ comment ' Examples:' a =. 'neon napoleon' nub0 a neo apl nub1 a neo apl comment ' Some random rows: ' b =. ( ? 7$4 ) { i. 4 3 b 0 1 2 9 10 11 3 4 5 6 7 8 0 1 2 0 1 2 6 7 8 nub0 b 0 1 2 9 10 11 3 4 5 6 7 8 nub1 b 0 1 2 9 10 11 3 4 5 6 7 8