Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

Let/lambda equivalence

Name: Anonymous 2012-08-13 20:54

Most call-by-value languages with anonymous functions have let/lambda equivalence: declarations are exactly the same as function parameters/arguments.
((lambda (i j) (* i j)) 3 4)
(let ((i 3) (j 4)) (* i j))


((INT i, j)INT: i * j)(3, 4)
(INT i = 3, j = 4; i * j)


(fn (i, j) => i * j)(3, 4)
let val (i, j) = (3, 4) in i * j end


A related rule is that any expression can be wrapped in a lambda without changing its meaning (besides grouping the expression). Notice how it is the expressions within the lambda bodies that create the scope in which the variables are bound and not the lambdas themselves.
((lambda () (let ((i 3) (j 4)) (* i j))))
INT: (INT i = 3, j = 4; i * j)
(fn () => let val (i, j) = (3, 4) in i * j end)()


One popular language does not follow these rules. Can you guess what it is? It's a language where certain constructs need to be wrapped in functions which are called immediately. It's supposedly ``Scheme-inspired'' but it's statement-based and uses a return keyword. The upcoming version will add a new type of function and variable that does follow these rules, at the expense of having two sets of rules and bloating the language beyond C++.
Give up? It's JavaScript.

Name: Anonymous 2012-09-18 21:33

>>19
Stack traces are just a trivial example of what can be done with the caller property. You can pull functions from anywhere in the call stack and call them. You can modify the arguments object in any of the functions in the call stack. You can check the call stack for functions named in camelCase. The possibilities are endless.

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List