lua-users home
lua-l archive

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


> only slows things down a tiny bit. Alternatively, you could say:
>
>   if tag(table) ~= tag({}) then settag(newtable, tag(table))

That's what I do.

> but it would certainly make sense if settag silently did nothing if the tag
> was
> already what you were trying to set it to.

But even if it silently does nothing, it should still reject tag({}) as an
illegal value...

> The same way I illustrated for making tables for which rawget doesn't work,
> I suppose. Why would you want to do that? My interest is in making table
> types for which foreach *does* work -- in accordance with the table type.

Sorry, I was getting confused, I thought you meant you could make tables
for which for loops didn't work.

> Well, which order do the arguments go in? Do you have to look that up every
> time?

Argument order is indeed something I find myself forgetting quite often.
I mostly define functions in the order in which they're useful to curry,
so I'd've defined settag the other way around. Functions like strfind and
gsub I often have to look up. I agree though that given the C convention
(or Smalltalk), you just have to remember that if a function returns one
of its arguments, it's the first one.

-- 
http://sc3d.org/rrt/ | The only person worth beating is yourself