lua-users home
lua-l archive

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




On Thursday, November 6, 2014, Dirk Laurie <dirk.laurie@gmail.com> wrote:
2014-11-05 19:09 GMT+02:00 Andrew Starks <andrew.starks@trms.com>:
> local fun, err = (the_code_chunk_as_string, 'b', _ENV)
> -->bad argument #3 to 'load' (string expected, got table)
> local fun, err = (the_code_chunk_as_string, nil, 'b', _ENV)
> -->function, nil
>
> Due to my last mistake, I was able to figure this one out.

Sadly, no.

> However, it's still weird a bit weird and only after thinking about
> it (a lot), do I see why: _ENV might be a string,

If _ENV is not a table, it is an error.

`load` is clean. Look at the nested brackets for its arguments.

ld [, source [, mode [, env]]]

That means one of:

ld
ld,source
ld,source,mode
ld,source,mode,env
Unlike debug.traceback:

[thread,] [message [, level]]

which means one of:

<nothing>
message
message,level
thread
thread,message
thread,message,level


Yup. I obviously need to slow down when I'm reading to solve an immediate problem, and read more like I'm studying. 

Well, if there is anything useful at all here, I'd say that the argument name "source" was probably why my brain went sideways, and had skipped past the special purpose of that argument. It is still not immediately clear to me, but I'll play around with it before asking questions. 

Thank you again for your patient explanation. It more than makes up for your occasional bouts of crankiness :)

-Andrew