8000 Immutability of table parameters in question · Issue #548 · NLua/NLua · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Immutability of table parameters in question #548

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

Open
phillk6751 opened this issue Feb 3, 2025 · 1 comment
Open

Immutability of table parameters in question #548

phillk6751 opened this issue Feb 3, 2025 · 1 comment

Comments

@phillk6751
Copy link

When attempting to modify a parameter by itself works perfectly, however when that parameter is a table, attempting to change the value in that table the value becomes null. I have some examples below:

All are called using this C# code:

object args = new { barcode = "1234567890" };
var resultstr = lua.LuaCall("immutabletest4", args);

Test 1: Here the resultstr is null (Error case!)

function immutabletest(args)
	args.barcode = '1234'
	return args.barcode
end

Test 2: Here resultstr gets the value "1234567890", as it should

function immutabletest2(args)
	barcode = args.barcode or nil
	return barcode
end

Test 3: Here resultstr gets the value "1234567890", as it should

function immutabletest3(args)
	return args.barcode
end

Test 4: Here resultstr gets the value "1234", as it should. I was testing immutability of parameters, and they aren't.

function immutabletest4(barcode)
	barcode = '1234'
	return barcode
end
@phillk6751
Copy link
Author

So, it appears this may be a slight confusion. It appears that if the original .NET object is immutable, then the parameter is immutable. If I create a class with a property "barcode", the Example #1 works correctly. I still think this may be a bug, as it's immutability is only known outside the context of the script.

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
2DD5

No branches or pull requests

1 participant
0