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

How to handle deprecated sdl2 functionality? #34

Closed
Free-Pascal-meets-SDL-Website opened this issue Feb 12, 2022 · 3 comments
Closed

How to handle deprecated sdl2 functionality? #34

Free-Pascal-meets-SDL-Website opened this issue Feb 12, 2022 · 3 comments
Labels
discussion Discuss an idea/feature/PR/issue...

Comments

@Free-Pascal-meets-SDL-Website
Copy link
Collaborator

This issue is about a problem I ran into recently and saw also in a pull request recently.

Simple example:
Lets say there are some defines which are translated.

const
  SDL_DEFINE1 = 0;
  SDL_DEFINE2 = 1;
  SDL_DEFINE3 = 2;

In a newer version of the header file one of the defines is missing. Let's say the second define is missing. So the inc-file would be updated to:

const
  SDL_DEFINE1 = 0;
  SDL_DEFINE3 = 2;

However, this raises (at least) two problems.

  1. The define is (obviously) missing if someone is using an older version of sdl2 instead of the particualrly one to which the inc-file got updated.
  2. The second concern is raised particularly because we are not always updating consistently to one particular version AND not all files at the same time: Let's say some files are not updated yet (very old version), some are updated (not the most recent version), some are updated to the latest version of sdl2. If now in the newest version some defines are deleted because they are gone, this may conflict with functions or expectations which are present in very old or older versions as they need or at least expect these defines/functions to be present.

The example above can be extended to structs/records where in newer version fields are missing or change their variable type.

Solution:
Actually, I don't know a simple solution yet. except to have some conditional compilation. Something like:

const
  SDL_DEFINE1 = 0;
  {$IFDEF DEPRECATED_IN_NEWER_SDL2} SDL_DEFINE2 = 1; {$ENDIF}
  SDL_DEFINE3 = 2;

What are better solutions or should this be adressed anyway?

Best regards
Matthias

@suve
Copy link
Collaborator

suve commented Feb 13, 2022

Three solutions come to my mind:

  1. Keep everything as updated as possible. If SDL2 removes something, we remove it as well. Leave it to users to upgrade or downgrade the Pascal units as needed.
  2. Keep old stuff around and just mark it as deprecated.
  3. As you proposed - keep old stuff around, but guarded by some IFDEF block. Add a section to the README to tell users what's going on and how to enable deprecated identifiers.

@Free-Pascal-meets-SDL-Website
Copy link
Collaborator Author

What option do you prefer for our project?

@Free-Pascal-meets-SDL-Website Free-Pascal-meets-SDL-Website added the discussion Discuss an idea/feature/PR/issue... label Jun 20, 2022
@Free-Pascal-meets-SDL-Website
Copy link
Collaborator Author

I made further research on this. I think it is safe to remove the conditional.

See https://stackoverflow.com/questions/27296111/is-possible-to-mark-an-entire-const-block-as-deprecated for reference. There are variables shown to be deprecated in an identical way for Delphi.

Originally posted by @Free-Pascal-meets-SDL-Website in #52 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
discussion Discuss an idea/feature/PR/issue...
Projects
None yet
Development

No branches or pull requests

2 participants