lua-users home
lua-l archive

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


Hi there,

Just sharing my opinion below...

Quoting Tim Hill (2016-06-28 08:44:12)

> > On Jun 27, 2016, at 9:15 PM, Philipp Janda <siffiejoe@gmx.net> wrote:
> > 
> > Am 28.06.2016 um 05:29 schröbte Tim Hill:
> >
> >> so adding 8 bytes per table (for the length) isn’t much, and might
> >> even be free since most heap allocators round allocations up to
> >> multiples of 16 bytes or more these days anyway.
> >> 
> >> My personal feeling is that we need a first-class explicitly set
> >> length. If this isn’t set for a given table (is nil), then Lua uses
> >> current # behavior, as do things like table.pack().
> > 
> > Mixing `.n` *and* sequence-style `#` will just combine the confusion, ugly corner cases, and undefined behaviors. Functions that take `.n`-style tables should just throw an error if there is no valid `n`.
> 
> I agree, and I would prefer to get rid of “.n” asap, but at the same time how much existing code will break? 

Personally, I would also like the “#t” vs “t.n” confusion gone, as it is
probably Lua's ugliest wart. For a decade I have been avoiding having to use
“.n” in all my code whenever possible, to avoid shooting myself on the foot.
This sometimes has lead to reworking my data structures in ways that arrays
with “nil” values are not needed, or their length is not relevant or needed
for calculations — but that's not always possible.

At this point I do not really mind which solution is adopted, as long as the
matter gets solved. I'll be happier, even when having to rewrite some bits of
code ;-)

Best regards,

--
 ☛ Adrián “2¢” Pérez

Attachment: signature.asc
Description: signature