epatrizio / ola

OCaml Lua Interpreter
The Unlicense
1 stars 1 forks source link

Bug closure concept implementation #18

Closed epatrizio closed 4 months ago

epatrizio commented 11 months ago

Here is the classic example :

function add(x)
  return function(n)
    return x + n
  end
end
local add2 = add(2)
print(add2)          -- Type = add2 is a function
print(add2(40))   -- Result expected = 42

error launched : attempt to perform arithmetic on a nil value x is not defined. x should be equal to 2 !

https://en.wikipedia.org/wiki/Closure_(computer_programming)

epatrizio commented 10 months ago

Stateful iterators cannot be implemented : https://github.com/epatrizio/ola/pull/19/commits/1c94e77521bcd12e7be49ca5a01dc02896bc01e5

epatrizio commented 9 months ago

https://github.com/epatrizio/ola/blob/main/test/import_1/zCombinator.lua This classic example could not be activate

epatrizio commented 4 months ago

Check specific test: https://github.com/epatrizio/ola/blob/main/test/closure.lua