Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

function in "luaproc.newproc( function f ) " requires luaproc require #13

Open
maxguru opened this issue Jul 2, 2016 · 1 comment
Open

Comments

@maxguru
Copy link

maxguru commented Jul 2, 2016

Works:

local luaproc = require("luaproc")
local x = function()
    local luaproc = require("luaproc")
    print( luaproc.receive( "achannel" ))
end
luaproc.newproc(x)

Doesn't work:

local luaproc = require("luaproc")
local x = function()
    print( luaproc.receive( "achannel" ))
end
luaproc.newproc(x)

On the other hand, this works without require in the newproc block,

local luaproc = require("luaproc")
luaproc.newproc( [[
    print(luaproc.receive("achannel"))
]] )
@nrnrnr
Copy link

nrnrnr commented Apr 2, 2019

My skills are rusty, but I'm pretty sure that the nested function x can capture an upvalue only if the upvalue is a string, boolean, number, or nil. It can't capture a function.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants