lua-users home
lua-l archive

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


A couple concerns on initial review of microlight [1]...

(1) The names ml.extend, ml.inject, and ml.delete relate only loosely
to purpose.  I don't get the sense from the names that "delete" (as in
ml.delete) and "remove" (as in table.remove) are very similar in
behavior apart removing a *range* of values v.s. a *single* value.
The name "extend" might sound like class inheritance or
JQuery.extend().  ml.extend can be written in terms of ml.inject, so
there is overlap, and ml.inject could be presented as an analogue of
table.insert for multiple elements, except for the `overwrite`
argument in `ml.inject(dest,index,src,overwrite)`, which makes the
function behave more like a memcpy/bitblt than an insert.  I'm kind-of
expecting a set of related functions like

  table.insert(list, [pos,] value)   <-->   ml.inject(t, [pos,], t2)
  table.remove(list [, pos])         <-->  ml.remove(t [, pos1 [, pos2]])
  lua_copy                               <--> ml.copy (t1, pos1, t2, pos2, len)

except the ml.copy might be too trivial and uncommon for microlight,
whereas ml.inject/ml.remove at least are O(N^2) in their naive
implementation.  remove may even be merged into inject, as in the
versatile Perl splice [2].

(2) Assuming tstring is for debugging not serialization, we probably
want to escape unreadable chars.  Try

  ml.tstring(string.char(unpack(ml.range(0,255))))

(3) I see some functions in microlight of common utility
(escape/expand/readfile/exists/tstring/indexof/range/invert/collect/...and
probably class).  Others I'm not so sure about.  Others seem missing
like memoize, findbin [5], trim [8], and writefile [3] or could be
more complete [3].  Others like split, TMTOWTDI.  I planned to at some
point announce my own set of very small focused libraries for core
things [3-7].

[1] github.com/stevedonovan/Microlight
[2] http://perldoc.perl.org/functions/splice.html
[3] [https://github.com/davidm/lua-file-slurp lua-file-slurp /
file_slurp] - Easily read/write entire files or pipes from/to a string
[4] [https://github.com/davidm/lua-require-any lua-require-any /
requireany] - require any one of the listed modules
[5] [https://github.com/davidm/lua-find-bin lua-find-bin / findbin] -
Locate directory of original perl script
[6] [https://github.com/davidm/lua-lib lua-lib / lib] - Simple
insertion of directories in package search paths
[7] [https://github.com/davidm/lua-compat-env lua-compat-env /
compat_env] - Lua 5.1/5.2 environment compatibility functions
(load/loadfile/getfenv/setfenv)
[8] http://lua-users.org/wiki/StringTrim