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

Short init fixed array syntax confusion with propagation of error. #22849

Open
2 tasks
jorgeluismireles opened this issue Nov 13, 2024 · 0 comments
Open
2 tasks
Labels
Feature Request This issue is made to request a feature.

Comments

@jorgeluismireles
Copy link

jorgeluismireles commented Nov 13, 2024

Describe the feature

The compact way to initialize a fixed array is like a regular one but adding a !. I wrote a test using the form, but now weeks later I confuse the ! thinking I did a propagation of a Result error. Is easy to forget that here ! is not related to Results and takes time to realize this even in your own code.

Use Case

From the docs https://docs.vlang.io/v-types.html#fixed-size-arrays one way to change an ordinary array to a fixed one is simply adding a ! to it:

fnums2 := [1,10,110]! // short init syntax that does the same (the syntax will probably change)

When you have this line in your code surrounded by other lines propagating errors, you confuse things.

Proposed Solution

Maybe change this:

fnums2 := [1,10,110]!

into something like this:

fnums2 := [1,10,110].to_fixed_size()

Other Information

No response

Acknowledgements

  • I may be able to implement this feature request
  • This feature might incur a breaking change

Version used

V 0.4.8 62bdf99

Environment details (OS name and version, etc.)

Tested in playground.

Huly®: V_0.6-21294

Note

You can use the 👍 reaction to increase the issue's priority for developers.

Please note that only the 👍 reaction to the issue itself counts as a vote.
Other reactions and those to comments will not be taken into account.

@jorgeluismireles jorgeluismireles added the Feature Request This issue is made to request a feature. label Nov 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Feature Request This issue is made to request a feature.
Projects
None yet
Development

No branches or pull requests

1 participant