Closed trentgill closed 5 years ago
i think it's really smart to not preload everything into RAM.
but i'm starting to prefer less hidden-magic syntax fixes in the norns scripting system. feeling it's ok to have scripts do more explicit requires
and i see runtime ramifications with auto-loading (ie, first ii command gets lagged/delayed waiting for the lib to preload)
my thinking here is that this hidden-magic is not a syntax fix, but rather a workaround for RAM limitations. the goal was to have the II.<module>
files work as if they are all loaded already. in general we don't use require
anywhere except in the standard lib (crowlib
) itself (well dofile
actually), so in a way i like the idea that crow scripts never deal with external dependencies - everything is just always available.
i take the point that it is kind of a hack though, and for sure there will be some runtime delay for that first command, though perhpas it's negligible IRL? it's already working in PR #69 but i can remove if we decide it's better without it.
by all means go on ahead--- i was simply trying to set priorities, so if not implementing this actually creates just as much (or more) work, it'd be better to get it in there.
i'm less worried about the delay.
the initial version requires the user to 'require' the table for their module to be remote-controlled:
require 'JF'
the design would mean a call to eg:
ii.jf.transpose()
would fail if the above hadn't been required.we fundamentally require this now because their is a hard RAM limit and loading all of the helper for all of the potential i2c clients would use far too much.
instead, we can hide this limitation from the user, making it appear as though all of the tables are always loaded. whenever there is a call to ii.jf.___ and the function is not found, we lookup if the jf table is nil (if it's not, then it suggests a typo), but if it is, we first
require 'JF'
before executing the code.this means that the RAM is only used after the user first uses a function from that subset even though it appears as though all the functions are always available.
//
note: this requires ii..listcommands() to be implemented in C, printing a c-string (from a header file) as the contents. or perhaps this string/array is passed back to lua for printing/matching.