From APL Wiki
Revision as of 05:48, 25 September 2020 by Adám Brudzewsky (talk | contribs) (→‎IBM)
Jump to navigation Jump to search

Maintaining readability of APL can take a special effort. It is easy to write very dense code, and the mathematical look of APL can encourage usage of single-letter names. Traditionally, APLers use the term pornography to describe code that is hard to read, or uses unusual constructs. Code golf often results in pornographic code.


Gilman & Rose

In APL – an Interactive Approach, the authors the authors describe the following code, which computes the correlation coefficient, as “almost pornographic”:



The APL2 Idiom list includes the following entry:

X'line1',0Y'line2' ⍝ Pornography. Combining two lines into one.

This was a common technique before Left was added to the language:

X'line1' Y'line2'

The Diamond statement separator () provides an alternative means of inlining multiple statements:

Y'line2' X'line1'

Note that in all these cases, Y is assigned first.

Morten Kromberg

Morten Kromberg asked one of his colleagues to “Please avoid this kind of pornography:”


Avoiding the unusual modified assignment (using as function the 2-train ⎕NS) makes for a much more readable version would be:

nsns container.⎕NS

This makes it clearer that the name ns is reassigned to a new namespace inside the container namespace, with the new namespace taking the original value of ns as name.