lua-users home
lua-l archive

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




On Thu, Jun 7, 2018 at 12:49 AM, pocomane <pocomane_7a@pocomane.com> wrote:
On Thu, Jun 7, 2018 at 7:34 AM Egor Skriptunoff
<egor.skriptunoff@gmail.com> wrote:
> Every Lua table must store 8-byte integer "high water mark" (biggest non-zero positive integer key assigned).
> User can read it with function table.hwm(t)

I also think this, or something like this, should be the way to go.
For me this could become the final lua solution. Somehow similar
proposal was in http://lua-users.org/lists/lua-l/2018-03/msg00395.html
.


Glad someone else has had the same notion!

I don't care for this

#tab = nil 

Resetting # to the default behavior.  That should actually set the return value to nil.

It's already a little odd[*] having something be an assignment on the left side and 
effectively a function call on the right.  Having the implementation silently change the
assignment to something else would be surprising. 

[*] Not so odd in Lua, where we can use __newindex to do this as well.
 

I really would like to hear by the lua team why this kind of solution
was discarded (I am quite sure they already examined it).


I'm also interested.

This seems like the main con:

#tab = "ahoy matey!" 

Should this line be a runtime error? Or should it propagate until the user sees
(number expected, got string)?

I say the latter, but it seems to me that there are runtimes implications of this question
which might interfere with being efficient in the general, already-supported case.