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

API stability support #429

Open
lerno opened this issue Apr 13, 2022 · 4 comments
Open

API stability support #429

lerno opened this issue Apr 13, 2022 · 4 comments
Assignees
Labels
Missing Feature Feature that is required for the language

Comments

@lerno
Copy link
Collaborator

lerno commented Apr 13, 2022

API stability – dynamic libraries (esp OS ones) being able to be both backwards and forwards compatible is an important consideration.

Some things that potentially break the API:

  1. Function signature changes and availability
  2. Changes to struct/union size or alignment
  3. Struct/union internal member ordering and availability
  4. Enum values

Note that C3 is stable under error changes.

@lerno
Copy link
Collaborator Author

lerno commented Apr 13, 2022

Mitigating 1:

  • Multiple functions for the same function
  • Hiding function availability behind macros
  • ObjC style dynamic dispatch
  • ObjC style runtime availability requests

Mitigating 2:

  • Structs only available by pointer

Mitigating 3:

  • Structs only available by pointer
  • Opaque pointer
  • "accessor" style access of members

Mitigating 4:

  • Enum aliases (e.g. FOO = 3, BAR = FOO)
  • Each enum directly defined rather than implicitly
  • Using constants rather than enums

@lerno
Copy link
Collaborator Author

lerno commented Apr 15, 2022

Feature:

fn void foo() @dynamic;

Can be checked if it is available, and called if it is:

fn void test()
{
   if (foo.available) foo();
}

@lerno
Copy link
Collaborator Author

lerno commented Apr 15, 2022

Roughly this is what it could have been in C:

extern int fooNewFunction(void) __attribute__((dynamic));
int test()
{
   if (!__exists(fooNewFunction)) return -1;
   fooNewFunction();
}

Under the covers this is added to the client code:

int fooNewFunction(void) { panic(); } __attribute__((noinline) __attribute__((weak));
bool __fooNewFunctionExists __attribute__((weak)) = false ;

@lerno
Copy link
Collaborator Author

lerno commented Jun 13, 2023

Implemented dynamic calls.

@lerno lerno added the Missing Feature Feature that is required for the language label Jun 13, 2023
@lerno lerno self-assigned this Jun 13, 2023
@lerno lerno added this to the First release (v1.0) milestone Sep 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Missing Feature Feature that is required for the language
Projects
None yet
Development

No branches or pull requests

1 participant