stevedonovan / luar

luar is a Go package for conveniently working with the luago Lua bindings. Arbitrary Go functions can be registered
MIT License
301 stars 55 forks source link

Extend __type metamethod for proxies #29

Closed Ambrevar closed 7 years ago

Ambrevar commented 8 years ago

See: https://github.com/bitwalker/luar/commit/9747fcd0e1bcc9fbb24e6221f5577b2fbf31b3ad This allows for type() to return something more interesting about proxies. The aforementioned commit returns table. I like the idea of making the distinction between real Lua tables and proxy tables. What about returning

Comments?

stevedonovan commented 8 years ago

I would agree that the distinction may be useful. I wonder what the original intention here is - that the patch is to ensure that Lua code does consider proxies to be tables?

Ambrevar commented 8 years ago

Second thoughts...

Further questions:

I would go for simplicity and opt for table<map>.

stevedonovan commented 8 years ago

Simplicity feels like a good thing here. Either it's a proxy or it's already a Lua table.

Ambrevar commented 8 years ago

To point of having a prefix is for Lua program to make the distinction between their host platforms (original Lua, luajit, luar, golua, etc.). Not sure there is any convention there, and not sure that would ever be needed either.

stevedonovan commented 8 years ago

Such scripts can query their own environment,_VERSION etc.

Ambrevar commented 8 years ago

But both golua and luar keep _VERSION unchanged. Which is probably the right thing to do... Any thought on that?

Ambrevar commented 7 years ago

Changing the type function will break backward compatibility though, so I suggest to move this together with the API change #32.

Ambrevar commented 7 years ago

I've pushed the changes to the proxytype branch. Let's wait for what will get decided regarding the API change.

Ambrevar commented 7 years ago

The change has been merged in the v2 branch.