News for hackers. Stuff that matters.
Re:APL compiler targeting a typed array intermediate language by beagle3 on Friday June 24, 2016 @11:47AM (#11970716)
As jxy noted, APL2 actually was used that way in the mainframe days (I actually had the pleasure to use it, and it WAS a pleasure compared to any other facility offered on that system).

However, it's hard to replicate unix userland as K primitives - Unix pipes work well because every participant streams along implicitly; however, one of the subtle and often invisible truths of APL and K programming is that everything sort of assumes the length of every vector/list/axis/dictionary is accessible. It's not something that cannot be removed, it's just something that AFAIK has never been removed -- and the implications of removing it are likely to make APL or K less concise. Streaming in APL and K tends to be explicit.

K and APL are ridiculously useful, and once you've actually grokked the idea, it's hard to look at conventional programming languages (Java, C, C#, even Python) and not feel disgusted at the useless extreme verbosity and fragile building blocks. Some people use them as their shell, and have no issue delegating to "standard" unix userland. In fact, an older version of K IIRC had its "create directory" operation implemented as {system "mkdir ",quote x} or something like that. It might not look that way to an outsider, but extreme pragmatism is strong with the K community.

Re:APL compiler targeting a typed array intermediate language by uudecode on Friday June 24, 2016 @09:52PM (#11974804)
What if someone took c.c, k.h, linenoise.c and linenoise.h and made a tiny k4 REPL for UNIX with commandline history?

Would the k community appreciate this as useful, pragmatic solution?

I am a BSD /emul/linux, /bin/sh, vi-mode, ESC / user. I need searchable commandline history for q)k) and I really do not like rlwrap as a solution.

sources:

http://kx.com/q/c/c/ http://raw.githubusercontent.com/antirez/linenoise/master/li... http://raw.githubusercontent.com/antirez/linenoise/master/li...

Re:APL compiler targeting a typed array intermediate language by jxy on Friday June 24, 2016 @11:38PM (#11975091)
For q/k in particular, you can just write a wrapper in q/k. Nothing stops you from doing

    while[1;0N!. 0:0]
you can save the history in a table and do whatever you want.
Re:APL compiler targeting a typed array intermediate language by uudecode on Saturday June 25, 2016 @04:16PM (#11977804)
"Nothing stops you..."

Except my lack of creativity using k at this point.

Thanks for this.

As a k noob, I wonder: is thinking of solutions using iteration and control structures a bad habit, at least until I have command of the rest of the language?

Currently I'm using recordio to save my sessions; crude, but it works well enough:

  recordio q 2>log
Re:APL compiler targeting a typed array intermediate language by uudecode on Sunday June 26, 2016 @03:13PM (#11982168)
Here's another solution, a little better than rlwrap:

  socat readline,history=file exec:q
Re:APL compiler targeting a typed array intermediate language by colejohnson66 on Friday June 24, 2016 @08:20PM (#11974519)
Any particular reason you can't output the length before the array stream? (I don't know APL, but want to learn it)
Re:APL compiler targeting a typed array intermediate language by jxy on Friday June 24, 2016 @11:43PM (#11975104)
The problem is that unix pipe can be blocked and you can see it as a lazy partial evaluation, so grep a HUGEFILE|head returns when 10 lines are found. In APL the semantics is not builtin, though things like ⍴↑↓ can be lazy, it's the internal optimization, rather than a language specification.