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

All Ks have basic module level lexical scoping, which does not deliver all the benefits of lexical scoping, but has none of the pitfalls of dynamic scoping either.

K2/K3 did have (a version of nested) lexical scoping - an inner function would close over the values at the time definition was encountered ; you can still simulate this in later Ks by passing what you need to close over and immediately projecting over existing values, e.g.

     make_adder:{[n] {[n,x] n+x}[n;]}
Which defines an inner two-parameter function, and then projects it over the outer n parameter (this is how K2 implemented it IIUC). But that doesn't let you modify names in an upper scope, so is not really comparable to Lisp's lexical scoping or Lua's upvars and Python's nonlocals or whatever they are called these days.

Andrey Zholos' kuc[0] dialect has a JIT and real closures, you might find that interesting, though it hasn't seen an update in a while.

> probably the best engineered piece of software I've ever come across.

As you can probably tell, I'm a K fan and evangelist myself. Yet personally I cringe at some of the kludges. I love K. It's awesome, it's amazing, but I wouldn't use the "best engineered" label myself; "Best set of tradeoffs" would probably be my description (which is a distinction without difference to some, I recognize - those who define engineering as the art and craft of the tradeoff).

[0] http://althenia.net/kuc




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

Search: