Comments (5)
You would want to store such information in the Lua state registry. See getMTCache
in cache.go
for an example of how we currently use the registry.
from gopher-luar.
@bontibon I see you already assigned this to you, but I went ahead and put what I was thinking into code and made a PR. Would love a code review when you have time. Thanks!
from gopher-luar.
Thanks for your thoughts, @bbuck.
I agree that the enforced dual naming for (at least) methods is not great. Struct fields I'm not as concerned about, as they can be explicitly set with the "luar" tag.
Your proposed solution and PR with the luar.Configure
function cannot be added, as it modifies global state. The solution needs to operate on types in a specific *lua.LState
.
A possibility I see is adding a helper to luar.MT
that removes (or prevents) a specific set of methods.
from gopher-luar.
Where would a good place be to store this information on an LState
? I've toyed with a similar feature in my current project for passing around values tied directly to an LState
but I'm not sure how best to store meta information. I started using globals like _SOME_GLOBAL_NAME
on the state but then, for my use case, chose to wrap stats with a data container so that values can't be modified from within scripts run.
Long story short, I'm not super familiar with the internals of Lua (yet) but I'm trying to learn. Where do you think might be the best place to store information like this? I'm totally willing to make the change in my PR.
from gopher-luar.
Thanks for doing this, much more compact than the new concept that I had.
from gopher-luar.
Related Issues (20)
- Properly handing errors? HOT 2
- Error handling with closures? HOT 1
- Automatic conversion of Lua table to Go slice? HOT 4
- Adding custom metamethods to types? HOT 2
- document Lua to Go conversions
- calling go method from lua that returns a slice HOT 5
- methods and pointer vs non-pointer receivers HOT 1
- methods and pointer vs non-pointer receivers, take 2
- How can I use luar to make a const table to lua? HOT 4
- Fix go vet and golint errors
- Failed to import - expects import "layeh.com/gopher-luar" HOT 1
- Test_metatable broken on master? HOT 2
- how to modify Config HOT 2
- I can't call functions of structs that are created via NewType() HOT 7
- What about pointers, like this print( sql:Table (inspection task): count (NIL)) HOT 1
- layeh.com/gopher-luar 404s HOT 1
- Convert LUA types to go HOT 6
- argument of method cannot be set for go function because the type error is not thrown HOT 1
- New types with defaults? HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from gopher-luar.