[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: "unsettag"!
- From: Reuben Thomas <rrt@...>
- Date: Fri, 4 Jan 2002 15:05:57 +0000 (GMT)
> This is one of the many reasons I have proposed an iterator tag method for
> Lua.
> It's hard to read between the lines to figure out what you're actually
> trying
> to do, but I am guessing that you wanted to do something like:
>
> newtable = {}
> for k, v in table do
> newtable[k] = v
> end
Indeed, and then I want to say
settag(newtable, tag(table))
> but you can't because the iteration doesn't work on your table-objects.
> (At least, that is a problem I run into occasionally.)
My problem was simply that the above settag is illegal if the table is a
vanilla one. How do you make (in Lua) a table type on which foreach
doesn't work?
> I'm putting together a little library with stuff like this in it, as a
> sort of tutorial on tag-methods. If you're interested, I could e-mail
> you a draft.
Yes, that'd be interesting.
> -- set up keys
> return settag(self, %mytag)
This is precisely the idiom I find confusing. What does the function
return: the table or the tag? Of course, it's fine once you know...
--
http://sc3d.org/rrt/ | art, n. romanticized mundanity