Skip to content
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

stdArray starts at 1 instead of 0 #47

Open
SZanko opened this issue Dec 7, 2021 · 3 comments
Open

stdArray starts at 1 instead of 0 #47

SZanko opened this issue Dec 7, 2021 · 3 comments
Labels
enhancement New feature or request lib-stdArray

Comments

@SZanko
Copy link

SZanko commented Dec 7, 2021

Description

In the current implementation of the stdArray it starts at 1 instead of 0, however in vba and javascript the array starts at 0 is this a planned design decision or is it designed to be that way?

Example

    Dim arr As stdArray
    Set arr = stdArray.Create(1, 2, 3, 4, 5, 6, 7, 8, 9, 10)
    Debug.Print (arr(0)) 'throws an error
    Debug.Print (arr(1))

Error

Runtime error: 9
Index out of range

Expectation

stdArray starts at 0

@sancarn sancarn added the enhancement New feature or request label Dec 7, 2021
@sancarn
Copy link
Owner

sancarn commented Dec 7, 2021

It is designed to be this way, however happy to add a feature for rebasing the array to start at 0 (or any integer for that matter)

@SZanko
Copy link
Author

SZanko commented Dec 7, 2021

It is fine that the array starts a 1.
However it should be mentioned that it starts at 1 instead of zero I haven't read any info which says that it starts at 1.
Maybe you should mention it somewhere

But it would be nicer if it use 0 as start point for the following reason that it is easier to migrate existing vba code without this lib. However that would break backwards compatibility with existing users of the lib

@sancarn
Copy link
Owner

sancarn commented Dec 7, 2021

However it should be mentioned that it starts at 1 instead of zero I haven't read any info which says that it starts at 1.
Maybe you should mention it somewhere

Yes the documentation for stdArray is currently not written. However it is present in both the tests and the code.

But it would be nicer if it use 0 as start point for the following reason that it is easier to migrate existing vba code without this lib.

Indeed, we can make a global option on stdArray for defaultBase, similar to what we do for stdLambda 's function lookup.

@sancarn sancarn added this to Roadmap Jun 3, 2024
@sancarn sancarn moved this to Feature Request/Unknown requirement in Roadmap Jun 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request lib-stdArray
Projects
Status: Feature Request/Unknown requirement
Development

No branches or pull requests

2 participants