lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


new syntax for pure function (v2) - https://www.lua.org/work/doc/manual.html#9
...
funcbody ::= ‘(’ [parlist] ‘)’ [pure] block end
...

[build.sh]
#!/bin/sh

wget -c https://www.lua.org/work/lua-5.4.0-alpha.tar.gz
wget https://raw.githubusercontent.com/kov-serg/lua-aux/master/pure54.patch
tar xf lua-5.4.0-alpha.tar.gz
cd lua-5.4.0-alpha
patch -p 1 < ../pure54.patch
make linux-readline
cp src/{lua,luac} ..
cd ..

[test-pure.lua]
x="global"
local y="upvalue"

function fn(G,z) pure
  local a
  G.print(z)
  G.print(G.x)
  function a() G.print(y) end -- error: no access to 'y'
end

fn(_G,"arg")

пн, 15 июл. 2019 г. в 19:46, Sergey Kovalev <kovserg33@gmail.com>:
>
> I patched lua 5.4. it has new syntax for pure functions.