You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I would really like to document dynamic fields, like said above, field generated using the __index function. This would be really helpful when you have a class which has specific fields (so it's not just a table) but also an __index implementation. For example like this:
---@classScene---@dynamicField SceneObject? The object with the given name, if presentlocalscene= { }
--- Finds an object by namefunctionscene.find(name) end--- FInds an object by idfunctionscene.findById(id) endsetmetatable(scene, { __index=function() end }) -- You know what I mean-- Example usagelocalplayer=scene.player
Currently this would cause a warning because player isn't a field of Scene.
You wouldn't need an option to set the name of the field with the @dynamicField (or @dynamic I guess), because that depends on the actual field requested. For the documentation, if you want to go all out you could add something like @name to be inserted into the documentation comment, which would then be replaced by the actual name of the field you access when you hover over it, but I guess that's not so important.
The request in this issue clashes with the request in issue #1298.
if we had a never type (the type with no values) then this one becomes a subset of that one - a readonly field is one whos write type is never, and writeonly one whos read type is never - and never would be a sensible default for the unspecified one if a field is only specified on one side!
Activity
sumneko commentedon Feb 13, 2023
I can support
readonlyfirst.vinipsmaker commentedon Feb 13, 2023
What syntax do you have in mind?
sumneko commentedon Feb 13, 2023
Just add keyword
readonlyRc-Cookie commentedon Feb 22, 2023
I would really like to document dynamic fields, like said above, field generated using the
__indexfunction. This would be really helpful when you have a class which has specific fields (so it's not just a table) but also an__indeximplementation. For example like this:Currently this would cause a warning because
playerisn't a field ofScene.You wouldn't need an option to set the name of the field with the
@dynamicField(or@dynamicI guess), because that depends on the actual field requested. For the documentation, if you want to go all out you could add something like@nameto be inserted into the documentation comment, which would then be replaced by the actual name of the field you access when you hover over it, but I guess that's not so important.vinipsmaker commentedon Feb 22, 2023
Just to document my own use case for dynamic fields, I'm worried about an user caching values:
Rc-Cookie commentedon Feb 22, 2023
Is this supposed to be a comment on my post, or unrelated?
vinipsmaker commentedon Feb 24, 2023
Unrelated. I just wanted to make sure that everybody understands that multiple use cases are on the table.
C3pa commentedon Mar 27, 2023
The request in this issue clashes with the request in issue #1298.
justarandomgeek commentedon Sep 24, 2024
if we had a
nevertype (the type with no values) then this one becomes a subset of that one - a readonly field is one whos write type isnever, and writeonly one whos read type isnever- andneverwould be a sensible default for the unspecified one if a field is only specified on one side!kriasb commentedon Sep 5, 2026
Any update on this?