Hacker News new | past | comments | ask | show | jobs | submit login

If primitives fail, they raise a signal. There is also a primitive for unconditionally raising a signal. Most flavors of K have a primitive called "error trap" which captures signals emitted by a function application, should they occur:

      f:{11 22 33 x}
      .[f;,1;:]
    0 22
      .[f;,4;:]
    (1;"index")
If a signal is not trapped, K pauses execution and opens the debugger, where a user may interactively inspect the environment, evaluate code, and resume:

      f 4
    index error
    {11 22 33 x}
     ^
    >  x
    4
    >
Overall not that different from try...catch in a garden-variety interpreted language with a REPL.



Thanks! That's fairly straightforward and, I guess, avoids having to pass a closure.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: