Lua `next` is a function that takes two arguments: a table and a key and
returns the another key (or nil). Unlike an iterator, it holds no
context. It is guaranteed that you will iterate over all keys if you
repeatedly call next as follows
k = next(t)
while k ~= nil do
k = next(t, k)
end
On Thu, Dec 24, 2020 at 4:08 PM Arnaud Delobelle wrote:
> The order is undefined but stable (provided you don't insert new values), and
> accessible via the `next` function. Here is an example:
Quoting from the provided link:
next (table [, index])
Allows a program to traverse all field
Dnia 2020-12-24, o godz. 06:19:53
Arnaud Delobelle napisaĆ(a):
> I did have a look at hash/maphash, but I didn't think it was the right
> shaped API for what I am doing.
Do not be afraid to just "steal" runtime implementation and tinker with it to
get at desired properties.
https://github.co
I think theoretically, you might be able to optimize it away (at least in
the overwhelming majority of use-cases) by storing a couple of
`*reflect.MapIter` for the last used tables in the context of the VM and
then check, when `next` is called, if the key passed is the one it's
currently at. But I
On Thursday, 24 December 2020 at 14:31:22 UTC Jan Mercl wrote:
> On Thu, Dec 24, 2020 at 3:12 PM Arnaud Delobelle
> wrote:
> > That's interesting, thanks. Although I don't think it fits my use case
> because I need something stronger than an iterator: a function that given a
> table and a k
On Thu, Dec 24, 2020 at 3:12 PM Arnaud Delobelle wrote:
> That's interesting, thanks. Although I don't think it fits my use case
> because I need something stronger than an iterator: a function that given a
> table and a key returns the next key in the table (as this is a public API
> that Lua
I did have a look at hash/maphash, but I didn't think it was the right
shaped API for what I am doing. In short, I would have to contrive to
provide words to the package as byte slices, which then would turn them
back into words under the hood. That feels like a superfluous round trip,
given
(I am replying inline to make the context of my comment clear, although it
seems common practice to top-post in this forum - is there any guidance
about this?)
Arnaud
On Thursday, 24 December 2020 at 10:31:54 UTC kortschak wrote:
> You can also use the internal map implementation and make us
On Thu, Dec 24, 2020 at 11:19 AM Arnaud Delobelle wrote:
> Does that sound like a sensible approach? I.e. is it safe enough to use
> the go:linkname directive, and do those seem like the right functions to
> call to obtain a good hash?
>
It is probably better to use hash/maphash, if you can.
ht
You can also use the internal map implementation and make us of the
runtime's map iterator. This is relatively straightforward at the cost
of vigilance for changes in the runtime.
Here is an example (note that yo need a .S file as well to get the
go:linkname magic to work).
https://github.com/gonu
Hi there!
In my continued efforts to improve the performance of my Go Lua
implementation [1], I have reached a bottleneck which causes me a quandary.
Lua has a data structure which is called 'table', which is essentially a
hashmap. So far I have implemented it as a Go map, which works OK.
Ho
11 matches
Mail list logo