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

Proposal - Enforce Unambiguity #1677

Open
sa-tasche opened this issue Dec 13, 2024 · 1 comment
Open

Proposal - Enforce Unambiguity #1677

sa-tasche opened this issue Dec 13, 2024 · 1 comment
Assignees
Labels
Discussion needed This feature needs discussion to iron out details Enhancement Request New feature or request

Comments

@sa-tasche
Copy link

Enforce Unambiguity

Unambiguity1 makes it easier to understand a programming language.

Therefore, all macros / functions that work differently than expected (as those without a prefix) must be marked with a prefix; and for those that do not require a prefix, it must be forbidden.

This makes it easier to understand when a prefix is required and makes it easier to remember functions and macros (and their names), as there is no need to think about whether this function/macro was or must be defined with or without a prefix.

Footnotes

  1. Fix discrepancies in std modules #1662

@lerno
Copy link
Collaborator

lerno commented Dec 13, 2024

  1. Only macros may have the @ prefix
  2. It's mandatory if it behaves in a "non-function" way.
  3. It's permitted to add @ for macros that are safe. This is to allow macros to be highlighted as potentially "dangerous" even though it is satisfying the "function-like" behaviour. One such reason is if the macro is intended for constant folding and only uses a type:
macro usz alignof($Type)
{
  return $Type.alignof;
}

In this case, the code is guaranteed to constant fold, and this might be unexpected, so @alignof is better for the user, although not mandatory. I think I have one (1) macro like that in the stdlib.

@lerno lerno added Enhancement Request New feature or request Discussion needed This feature needs discussion to iron out details labels Dec 13, 2024
@lerno lerno self-assigned this Dec 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Discussion needed This feature needs discussion to iron out details Enhancement Request New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants