> On Nov 27, 2017, at 10:03 AM, Andrew Dabrowski <[email protected]> wrote:
> 
> Is J supposed to be a pure functional language, like Haskell? Outside of that 
> narrow category functions like this are common, and hard to get around for io 
> - input functions are like this.
> 

I thought I’d look into this specific example and found an interesting page on 
the Wiki about the problem of reading user input interactively:

http://code.jsoftware.com/wiki/User:Ric_Sherlock/Temp/InteractivePrompt 
<http://code.jsoftware.com/wiki/User:Ric_Sherlock/Temp/InteractivePrompt>

All of the examples I see relating to I/O wind up requiring an argument:

 - The foreign conjunction itself needs some parameters to figure out which 
function it is returning
 - (1!:1) needs an argument of either file name or file descriptor
 - The prompt function defined on that wiki page needs an argument for what 
prompt to display

I suspect that this is another case where it seems to us newbies like it would 
be a big problem, but in practice it really isn’t. I note that the addon 
installation procedure tells you to call the function with an empty string 
argument. Every language has to make some decisions about how to handle 
functions and those decisions always have seemingly-obvious downsides. Usually 
they are compensated for by other upsides, but the upsides aren’t always 
totally obvious. Ruby, for instance, seems to improve on Python by not 
requiring parentheses on nullary functions. But you pay for that later when you 
can’t pass a function by reference (you must instead wrap it in a block). 
Oftentimes increasing the complexity of a language’s function system has 
downstream consequences, like worsening performance or complicating 
metaprogramming. TANSTAAFL.

-- 
Daniel Lyons




----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to