require(AssetId) should return Module as it's second return value

Tuples are useful because you can omit values that are unused. We have tuples because parameters and arguments are tuples. They are also useful because to omit values, it is not necessary to use the expensive packing and unpacking procedures.

No idea why the error exists, I guess they thought it would be more like vanilla lua? I can’t think of any limitation on why modules wouldn’t be able to return tuples.

Even if ROBLOX allowed modules to return multiple values you’d have to change every module you’re using in that place. They don’t already return multiple values. When you go into to change them to make them return multiple values, how difficult is it going to be to change this:

return something to return {something, something2, something3} as opposed to return something, something2, something3 ? Returning as a tuple would definitely be cleaner, but I don’t see how returning them as a table will require anywhere near the amount of work you’re implying it will.

You’re going to have to do a lot of things in programming that are against your coding style. Get used to it. Even if ROBLOX modifies modules so that they can return tuples, you’re going to come across a similar situation in the future. Also, your coding style not liking something isn’t a use case for a feature.

The difference is that the modules can be changed, but every other script using them will not need to be changed. The extra arguments on the end can just be ignored by scripts that don’t want to use them, something that cannot be done with tables.

So far, I’ve not ran up against anything against my coding style in a very very long time. And coding style is pretty important. That’s besides the point though, things like efficiency, clarity, usability, and flexibility are things that would all be gained from having Tuples as module returns.

Style is basically just a combination of those things. So when I say style, I mean “efficiency, clarity, usability, and flexibility”

In the module itself you could set its name and parent such that you could do

script.Name = "ModuleScript"
script.Parent = workspace
local table, module = require(assetId), workspace.ModuleScript

But I don’t really see what the problem is with returning it.

Assumed _G isn’t an option.

1 Like