-
-
Notifications
You must be signed in to change notification settings - Fork 248
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Complement 0-indexed functions with 1-indexed #3622
Comments
How about adding both getExitStubs1 and getExitStubs0 so we can give fair warning and make getExitStubs work as expected at some point? That way Mudlet could become more idiomatic and intuitive in the end. |
I get what you're saying, but that would break existing scripts for what is relatively speaking a trivial issue, not a good tradeoff. It's nice that someone can pick up some code from a forum from a couple of years ago, drop it in, and have it work. |
If we could only magically influence all the code that's been put out there... :) |
I remember something like rust-lang's fix command... (or was golang fix) where it would magically fix things. |
--the following possible functions have 0-indexed
function getRoomsByPosition()
function getExitStubs() --Obviously..
function getAreaRooms() edit: |
Well, how about we announce that eventually we will have a Of course it will then provide an opportunity to smash the backwards compatibility so we need to get it into the Lua API A.S.A.P. so that packages and scripts can start to defend themselves against such a breaking change. We might even consider doing that concurrent with a change to
Needless to say such a change will be massive and would need to also be concurant with a Major Mudlet version release but I would not expect that to be before Mudlet 6.0 at the earliest. OTOH It would then be possible to switch to a later Lua version. |
Is it possible to resolve it along the lines of making table[0] and table[#table] the same reference? So code that used table[0] and ipairs works without issue? |
Could there be a method using metatable _index? I don't fully comprehend metatables. |
Brief summary of issue / Description of requested feature:
We've got a few functions in TLuaInterpreter.cpp from an early design which index starting from 0 - which isn't idiomatic Lua and unintuitive. Need to add 1-indexed complements to them, like https://wiki.mudlet.org/w/Manual:Mapper_Functions#getExitStubs1.
Steps to reproduce the issue / Reasons for adding feature:
More intuitive API.
Error output / Expected result of feature
Any function that returns an indexed table starting at 0 should also have a complementary function that starts indexing at 1.
Extra information, such as Mudlet version, operating system and ideas for how to solve / implement:
4.6.2
The text was updated successfully, but these errors were encountered: