-
-
Notifications
You must be signed in to change notification settings - Fork 171
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
Check for consistency of fixed-point precision in operations #1456
Comments
I strongly disagree with this. It would require the parser to inspect the lazy-evaluated RPN expression, and care about the structure of those expressions. It's a problem without a definite stopping point for a solution, because expressions can nest and expand indefinitely. Should we warn about This is basically a request for RGBASM to have actual data types. Not just "numbers" and "strings", but "integer" and "fixpoint", and probably "constant" and "variable" as well. Perhaps you can design a GB assembly language from scratch to have typed values, and manage to have them be more useful than annoying, but I don't think we can or should tack them on to the language we have. |
I've done |
I thought this could be implemented without too much hassle by making numbers in RGBASM a Unless that implementation strategy has obvious holes, I think it's beneficial because it doesn't add any concept of data types beyond what we already have, while adding diagnostics that we'd normally get only from type checking. |
I don't see any principled way to draw the line there, though. If we alert the user in this instance, why not warn them about I'd much rather draw the line where it currently is, at "numbers are numbers, we provide lots of syntaxes meant for different circumstances, pick the ones that work for you". |
I don't see a principled way either, it's just that I've found it somewhat tedious to have to keep thinking about that info as I've been manipulating fixed-points (e.g. to check the correctness of the correctness checker below ↓), and would've appreciated the tooling to “have my back” to catch mistakes more easily. assert (HIGH(NB_TILE_ROWS_KEPT_LIVE * 8.0) - 1) & HIGH(wMapTiles << 1) == 0 ; As you can see, these two don't overlap. (And note that the first one is entirely contiguous.)
That same file contains an instance of |
I also think that just having a concept of "numbers know their own precision" strongly invites further changes that are at odds with how we've made the language so far. For example, if you do And hey, if numbers are carrying metadata around anyway, why limit ourselves to definition time? If I do |
If you want a static checker, that belongs in a separate tool, not in RGBASM's default configuration. It's an assembler, not Rust. |
(Can an assembly language be more like Rust? I'd like to see one, that could be cool! But RGBASM isn't.) |
There is no reason why you can't make a static checker. You can probably even move part of the 1.0 code into a library and use that as a starting point. More tooling is always a net positive, as people can easily choose if the extra tool fits their needs or not. The issue is when that extra tooling stops being extra tooling and becomes part of the language — then the tool is no longer a bonus feature and it becomes a shackle for those who don't need it. |
(Maybe it's something to reconsider with the Rust rewrite, when we can more easily factor the lexer+parser out into a reusable crate for both the assembler and checker. (And even things like optimize. |
That's arguably true of many warnings-as-lints that we have, such as
Took me a while, but I found it!
I do plan to have at least an AST export, being basically a prerequisite to a LSP. But that's way far out. |
Why do you think these warnings have caused so much trouble? |
I have been repeatedly helped by |
The person wanting more static checkers being helped by static checkers should surprise exactly nobody. You'll have to look at people other than you (and people with coding practices similar to yours) if you want to see people being hindered by static checkers. I personally ran into |
I'm aware of your style, but that makes one example on each side of the balance, so AFAICT no definite sway. I lack more data points to make an informed decision—and, in the absence of that, can you blame me for putting in effort to push the tool in a direction that I am more comfortable with? I don't like breaking out that argument, but I haven't seen people PRing default warning flags demotion, or discussing the usefulness of existing warnings with examples (text and/or screenshots, we're not picky); so please forgive me if I sound a little miffed. |
I didn't make a PR for the As I said, the happy medium that makes both sides of the debate happy is to separate the checks into other tools, so people can integrate the tools/checks they want without being forced into them. I'm not saying those tools can't exist. Just don't shove them down users' throats! |
My data point doesn't shift the balance either, because I'm somewhere in the middle. :P I appreciate the safety net of But I do specifically set |
(Sidenote: I've personally written EDIT: I lied, it was |
As someone who might have to read or edit that code, I very much appreciate the explicit |
Considering that the tool that the warning originates from is irrelevant, it seems to me that what you're really asking is for the warning to become opt-in instead of opt-out. (The only difference is that it's either opt-in by running In that context, I don't see why the warning cannot be implemented at all, and the bikeshedding then shifts to “what's a good default”, “what are good preset levels”. |
For that matter, I've hit a |
And I have never dealt with negative numbers in the precise range where |
Goal: print a warning when doing any of these
1.0 + 1
1.0 * 2.0
MUL(1.0q8, 2.0q8, 16)
q8
and/or, 16
are omitted (with the appropriateOPT Q
setting, of course).1.0q8 + 2.0q16
We may want that warning to have levels, since e.g. someone may be intentionally multiplying fixed-point numbers together and correctly dealing with the resulting precision change.
Bikeshed points:
-Wall
, assigned to-Wextra
?(Originally brought up in #1455 (comment))
The text was updated successfully, but these errors were encountered: