Win / Conspiracies
Conspiracies
Sign In
DEFAULT COMMUNITIES All General AskWin Funny Technology Animals Sports Gaming DIY Health Positive Privacy
Reason: None provided.

That's does not mean that they implemented by code generation in runtime. Mostly they implemented as parsing source, finding out all possible variants and precompiling them all. So you get a completely static code with same functionality.

Also, im many laguages, usual unnamed functions are called lambdas for marketing proposes. Lambda is a function that returns a new function when called. In original implementations, this new function did not exist in memory until lambda called, then new code generated and then you could call it. Today, even if it is a language with lambdas (real ones, not nameless functions, like C#) machine code that should be generated on the fly is precompiled during parsing and compilation, and lambda just returns an address of that precompiled function code.

Simple example in abstract language:

lambda F(operation)(x,y)->(x operation y) // define lambda function

add = F(+) // this creates function add(x,y){return x+y} not existed before this call
print add(2,3) // will print 5
sub = F(-) // this create another code sub(x,y){return x-y}
yet_another_function = F(*2+)
// and so on

In modern languages with lambdas you could write such code, but new functions will be generated on the parsing/compilation stage. But unlike original idea, it would not work if argument to F is calculated in some complex manner that parser/compiler could not resolve to all possible variants or received from some external source.

// this will not work in modern languages
operation = read_input()
new_function = F(operation)

As you see, modern languages does not even allow writing a program that just adds new functions to itself during execution, not even talking about modifying itself in runtime. You will have to use very old stuff like clisp or do that in raw assembly language.

212 days ago
1 score
Reason: Original

That's does not mean that they implemented by code generation in runtime. Mostly they implemented as parsing source, finding out all possible variants and precompiling them all. So you get a completely static code with same functionality.

Also, im many laguages, usual unnamed functions are called lambdas for marketing proposes. Lambda is a function that returns a new function when called. In original implementations, this new function did not exist in memory until lambda called, then new code generated and then you could call it. Today, even it is a language with lambdas (real ones, not nameless functions, like C#) that machine code that should be generated on the fly is precompiled during parsing and compilation, and lambda just returns an address of that precompiled code.

Simple example in abstract language:

lambda F(operation)(x,y)->(x operation y) // define lambda function

add = F(+) // this creates function add(x,y){return x+y} not existed before this call
print add(2,3) // will print 5
sub = F(-) // this create another code sub(x,y){return x-y}
yet_another_function = F(*2+)
// and so on

In modern languages with lambdas you could write such code, but new functions will be generated on the parsing/compilation stage. But unlike original idea, it would not work if argument to F is calculated in some complex manner that parser/compiler could not resolve to all possible variants or received from some external source.

// this will not work in modern languages
operation = read_input()
new_function = F(operation)
212 days ago
1 score