lua-users home
lua-l archive

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


steve donovan <steve.j.donovan@gmail.com> writes:
> Just naming 'table' to 'array' might let people into thinking that
> array.insert and array.remove preserve the magic state of
> Non-Holiness that we aspire to in our arrays.  They should be
> separate functions; add an array.issequence predicate and then
> define them to be safe and fail noisily otherwise.

AFAICT, "array.issequence" would be a bit expensive (always requiring
a complete scan over the table, whereas insert/delete may not need one
when operating near the end), and calling it the insert/remove
functions would certainly be kind of un-Lua-ey; if the functionality
is made more clear with different names, I think that's enough.

[If people want to call these (more clearly named) functions with
something they're not sure is a real array/sequence, they can always
do the check themselves.]

The current state is sort of like the joke with the doctor saying
"well don't do that then"; if the table module were called "array" or
"seq", it'd be more like "well don't do that then, didn't you notice
the giant warning label?!"  While some people may sympathize with the
patient in the former case ("Maybe he didn't know..."), it's a bit
more difficult in the latter...

-miles

-- 
Christian, n. One who follows the teachings of Christ so long as they
are not inconsistent with a life of sin.