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

Deprecation policies and BLOCKSDS_STRICT #167

Open
asiekierka opened this issue Jun 16, 2024 · 4 comments
Open

Deprecation policies and BLOCKSDS_STRICT #167

asiekierka opened this issue Jun 16, 2024 · 4 comments
Labels
enhancement New feature or request

Comments

@asiekierka
Copy link
Contributor

asiekierka commented Jun 16, 2024

Currently, deprecation in BlocksDS is done in one of three ways:

  • using __attribute__((deprecated)) to mark types, variables and functions as deprecated,
  • using registers_alt.h, a remnant from early libnds days, for unifying and cleaning up register names,
  • removing the type, variable or function outright. That's no deprecation!

In addition, a lot of larger refactors are prevented by the goal to allow legacy codebases to migrate to BlocksDS with a minimum of fuss. While we'd like to be able to replace functions with more intuitive ones in some areas, this would require us to either remove the old functions (breaking this goal) or keep around both (confusing to the end user and allowing them to still rely on the legacy functions).

The JavaScript ecosystem, facing a not too dissimilar problem, has use strict as a way to forcibly disable some of the language's greatest warts. I propose a similar mechanism for BlocksDS:

  • a new define, BLOCKSDS_STRICT is added, which is set by default (in the build script!) to the version of BlocksDS being released; for example, a ROM template in BlocksDS 1.3.0 would set -DBLOCKSDS_STRICT=10300.
  • new deprecations and removed functions are gated by #if BLOCKSDS_STRICT < 10300 macros - this means that a 1.3.0 BlocksDS user creating a new program will not have access to them, but a legacy BlocksDS program will, for the time being.
  • such deprecations and removed functions are removed from Doxygen - one can build an earlier version of the documentation from an earlier version of BlocksDS to see the documentation of legacy functionality, while new users will not be onboarded to it.

This allows breaking new code without breaking old code for as long as we want to; in addition, it provides a more user-friendly upgrade path: someone upgrading from 1.2.0 to 2.0.0, say, could bump BLOCKSDS_STRICT by individual versions, only fixing a few incompatibilities at a time and testing if their homebrew program broke on any of the steps. This, then, makes the migration process less daunting.

An alternate approach, which has fewer benefits but may also prove to be less logistically complex, is making a libnds2 alternative library and freezing libnds as is except for minor bugfixes - essentially, creating new libraries as a way to do API breaks. However, I fear that this will just lead us to a situation where we're discussing a libnds3 next year - IMO, a libnds2 would be best made after we run out of things to BLOCKSDS_STRICT-ify.

@asiekierka
Copy link
Contributor Author

If we're actually moving forward with this, do let me know - I'll prepare a PR to introduce BLOCKSDS_STRICT as soon as possible (as described above: for 1.3.0, just as an #ifdef on top of existing deprecations).

@AntonioND
Copy link
Member

Sure, you can go ahead.

@asiekierka
Copy link
Contributor Author

#172
blocksds/libnds#109

@asiekierka
Copy link
Contributor Author

The relevant PRs have been put on hold. Other proposals for tackling "a cleaner libnds" have been proposed, including "separating out libsysnds with the lower-level components of libnds, and making libnds itself something more akin to a middleware library, with libsysnds containing the drivers/hardware things/threading primitives/etc".

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants