Provide abstraction for intuitive behavior of "unavailable" variables
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 35/100
Research direction
Start with the referenced Resolve implementation in src/newgrf_spritegroup.cpp around line 234 to understand how unavailable variables affect switch and computed-result evaluation. Then locate the corresponding NML variable and switch handling; done means unavailable cases are caught, first/default behavior is explicit, and the proposed error expression is considered or implemented.
Written by the indexing model from the issue text.
Description
Some VA2 variables are "unavailable" in some contexts, often in the purchase list.
When a variable is "unavailable" it does not provide any default value, but rather "throws an exception".
In the "throw" case, the remaining computations in the current VA2 are aborted/not executed, and the "first" case is choosen. (in case of a computed result, the "default" case is choosen).
NML should not expose this surprising behavior as-it to NML users. Instead NML should explicitly "catch" this case:
- Insert a first case that is unreachable otherwise (e.g. "range 1..0"). (not needed for "computed results")
- Provide a sane default for the "error" case: "return CB_FAILED" seems reasonable.
- Bonus: Add an "error: <expression>" similar to "default: <expression>" to switches, for user-defined error-handling.
For details, see: https://github.com/OpenTTD/OpenTTD/blob/master/src/newgrf_spritegroup.cpp#L234 (DeterministicSpriteGroup::Resolve)
- Dominant language
- Python
- Stars
- 61
- Forks
- 47
- Avg merge
- 8d 14h
- Merged PRs (30d)
- 3
Getting set up
This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from OpenTTD/nml
-
Difficulty 3/5 1-2 days Newbie friendliness 55/100
-
Difficulty 3/5 1-2 days Newbie friendliness 45/100
-
Difficulty 3/5 1-2 days Newbie friendliness 35/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 50/100
-
Difficulty 4/5 3-5 days Newbie friendliness 38/100
Similar issues
-
15-minutes 5-minutes algorithm any-language beginner-friendly c cpp csharp easy go good first issue hacktoberfest help wanted java javascript kotlin python rust swift typescript
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Huerte/algo-solutions-python#254 ·
Maintainers usually reply within 1 day
-
Difficulty 1/5 1-3 hours Newbie friendliness 86/100
MichaelYcJo/SpecSeal#1543 ·
-
size/s
Difficulty 1/5 Under an hour Newbie friendliness 90/100
sipyourdrink-ltd/bernstein#7179 ·
Maintainers usually reply within 1 day
-
good first issue help wanted python up-for-grabs
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
andrewsiah/agentswarm-data-tasks#309 ·
Maintainers usually reply within 1 day
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
Maintainers usually reply within 1 day