gbdev / gbdev/rgbds

Avoid using whitespace as an interpolation modifier

Open
#2,065 0 comments 0 reactions 0 assignees View on GitHub
breaking rgbasm
Dominant language
C++
Stars
1.6k
Forks
193
Avg merge
22h 17m
Merged PRs (30d)
26

Description

We currently support two number-sign modifiers in interpolation/format specs: `+` or ` ` ("If specified, prints this character in front of non-negative numbers"), same as C/C++ `printf`.

I think it's poor design for a few reasons, and thus I'd like it to be replaced with an underscore since that's visually similar enough.

- Visually, it looks wrong—since we feeble humans (and maybe LLMs also? lol) are used to processing whitespace-separated blocks of characters, an interpolation containing a space character would look visually jarring.
- I think it's reasonable to expect that external tooling attempting to parse RGBASM (in, yes, more limited ways, à la pret's `scan_includes`) would be doing the moral equivalent of `line.split()`, and possibly performing further processing on the resulting tokens (e.g. `splice()` on macro args or interpolations), and get tripped up by an interpolation straddling two such tokens. (...true, this argument does fall apart in the presence of strings.)

I acknowledge the rationale behind the choice of ` `: it's exactly the character that's being emitted, and there's precedent in that C accepts it as `printf` format specifiers. I think that `_` is visually similar enough, and I do not think that C is a good reference to follow as far as language design goes :P

Still, I would like to suggest deprecating ` ` in favour of `_`. I'm open to this being decided against if we end up preferring not to, though :)

Contributor guide

Open the contributing guide

Research direction

Start by locating the interpolation/format-spec handling and any tests for the existing `+` and whitespace modifiers. Determine whether whitespace should be deprecated in favor of `_`, including the compatibility behavior and any diagnostics. Done means the project has a decided modifier policy and matching implementation and tests.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
compilers
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.