When initially writing up the FAQ entry, I had this same quandry: how to
directly answer Graham's challenge while disagreeing with (some of) its
premises. The specific premise I disagreed with was that a function with
hidden inputs - a function which when given the same input at different
times can produce different outputs - could be called "functional" in the
sense of a mathematical function.
It was my understanding that "functional programming languages" strive to
hew as closely to the mathematical definition of a "function" as possible,
in order to ensure certain types of reasoning about programs were always
valid. In particular, the concepts of referential transparency, algebraic
manipulation, and ultimately equational reasoning. I believed that to
support these concepts, one must take surjectivity of functions as an axiom.
I was also aware that closures, projections, and monads (in the Haskell
sense) were hot topics in the functional programming community, and that was
sufficient evidence for me to conclude my understanding was incomplete, and
that my postulate on the incompatibility of FP and closures was shaky.
Hence my dilemma: how to respond to Graham's challenge, while denying his
(implied) premise that languages require closures to be "powerful". The
solution I came up with was to answer Graham's challenge directly ("here's
how you write an accumulator generator in J"), and address the implied
insult in a op-ed piece as an epilogue. I intended the body of the response
to be in the voice of an anonymous narrator and carry the weight of the "J's
official position" on the topic, and the op-ed piece to clearly state it was
my personal opinion.
If you check out the history of the page, you'll see I waffled on this a
bit, there was a span where I removed the op-ed completely, thinking I had
to be wrong about FP + closures because everyone else was talking about how
they were compatible. But in the end I decided to restore it (watered down
with parenthetical qualifiers) and just let the community editing process
correct any of my misconceptions. The last version that was "mostly Dan" is
[1] . The edits after that took a much stronger position on "FP is
incompatible with closures", directly in the body of the response, which may
have been what inspired the current debate.
Though this changed my original idea (separate the solution from the
question of whether a language needs closures to be "powerful"), I didn't
revert the changes because that defeats the purpose of having a
collaboratively edited Wiki, as well as my specific goal in inviting others
to contribute to that page. Maybe this same approach can help resolve the
current debate.
If the current page doesn't reflect the community consensus, or someone's
specific position, please feel free to change it. It's not "my page".
We'll probably converge on a better result, faster, by collaborating on the
Wiki than by going back-and-forth via email on the Forums. If we can't come
to terms on certain ideas, we can separate them from the direct response to
Graham's challenge and discuss them in a separate section.
-Dan
[1] Revision 33 of Guides/Lexical_Closure:
http://www.jsoftware.com/jwiki/Guides/Lexical%20Closure?action=recall&rev=33
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm