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

[Feature request] Get a charmap string corresponding to a given number #1606

Open
Rangi42 opened this issue Jan 9, 2025 · 1 comment
Open
Labels
enhancement Typically new features; lesser priority than bugs rgbasm This affects RGBASM

Comments

@Rangi42
Copy link
Contributor

Rangi42 commented Jan 9, 2025

ASMotor has this feature as a :C format specifier in its interpolations. For example, "{65:C}" gives "A".

It's been occasionally asked-for in RGBASM over the years; I don't recall the specific use cases (most likely to do with metaprogramming or debugging), and it's not a critical feature, but there are times it would be "nice to have".

The main argument against it, I expect, is that there could be more than one charmap to the same value(s). I think any simple consistent tiebreaking logic would be fine in this case (give the first or last defined one, the least or greatest one in strcmp ordering... whatever's most natural to implement, it's an arbitrary choice). There could be an opt-in -Wambiguous-reverse-charmap warning for such cases.

This is slightly complicated by the fact that charmaps can now exist for multiple values, like charmap "A", 1, 2, 3. It would be consistent to allow converting 1, 2, 3 back into "A". I think the natural way to handle this would be a var-arg function.

  • REVCHAR(65)
  • MAPCHAR(1, 2, 3)
  • CHR(42) (Python-esque)
  • CHARSTR($C3, $A9)
  • ...the name could be bikeshedded
@Rangi42 Rangi42 added enhancement Typically new features; lesser priority than bugs rgbasm This affects RGBASM labels Jan 9, 2025
@aaaaaa123456789
Copy link
Member

I'd say the best tie-breaking criteria would be to pick the last defined character, as it's both controllable by the user and friendly towards derived charmaps.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Typically new features; lesser priority than bugs rgbasm This affects RGBASM
Projects
None yet
Development

No branches or pull requests

2 participants