TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Ask HN: Is there a life out of closures?

1 pointsby martyalainover 2 years ago

1 comment

martyalainover 2 years ago
Closures are not a required functionality in a language. I&#x27;m experimenting a homemade language, lambdatalk, <a href="http:&#x2F;&#x2F;lambdaway.free.fr&#x2F;lambdawalks&#x2F;" rel="nofollow">http:&#x2F;&#x2F;lambdaway.free.fr&#x2F;lambdawalks&#x2F;</a> , in which lambdas don&#x27;t create closures but accept partial application. For instance this is how the set [cons, car, cdr] could be defined in SCHEME:<p><pre><code> (def cons (lambda (x y) (lambda (m) (m x y)))) (def car (lambda (z) (z (lambda (x y) x)))) (def cdr (lambda (z) (z (lambda (x y) y)))) (car (cons 12 34)) -&gt; 12 (cdr (cons 12 34)) -&gt; 34 </code></pre> and in lambdatalk:<p><pre><code> {def cons {lambda {:x :y :m} {:m :x :y}}} {def car {lambda {:z} {:z {lambda {:x :y} :x}}}} {def cdr {lambda {:z} {:z {lambda {:x :y} :y}}}} {car {cons 12 34}} -&gt; 12 {cdr {cons 12 34}} -&gt; 34 </code></pre> In SCHEME the outer lambda saves x and y in a closure the inner lambda can access given m. In lambdatalk the lambda saves :x and :y and returns a new lambda waiting for :m. So, even if closure (and lexical scope) are usefull functionalities, there are not a necessity. Without any free variables, out of any lexical scope, functions are true black boxes without any side effect, in a total independance, following a true functional paradigm. Don&#x27;t you think so?