lua-users home
lua-l archive

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

On 4 January 2012 17:46, HyperHacker <> wrote:
Just wondering if there's a compelling reason not to do this. Right
now if you want to load a script and pass some arguments to it, you
have to do:
loadfile('myscript.lua')(a, b, c)
and if you want to handle errors, it gets uglier:
assert(loadfile('myscript.lua'))(a, b, c)

It seems like a simple, useful change would be to allow dofile() to
pass arguments:
dofile('myscript.lua', a, b, c)

Thoughts? Of course this can be done pretty easily within Lua itself,
but I'm not terribly fond of replacing built-in functions like that.
Is there a reason this couldn't be done in a future version of Lua?
Will bad things happen to me if I wrap dofile() in my scripts to do
this? To me it seems to be in the spirit of Lua: a tiny change that
makes our code simpler. But I wonder if there's some detail I've
missed that would make it a bad idea...

Sent from my toaster.

I'm all for it;
The one place I can think of that something will break is if someone calls it dofile around a gsub and the script doesn't like it.


On the other hand this is such a simple and non-consequential change that if this thread goes past around 5 posts I'll have to execute you all for bikeshedding.