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

Fix discrepancies in std modules #1662

Open
sa-tasche opened this issue Dec 6, 2024 · 4 comments
Open

Fix discrepancies in std modules #1662

sa-tasche opened this issue Dec 6, 2024 · 4 comments
Labels
Additional info please Further information is requested Discussion needed This feature needs discussion to iron out details Stdlib Standard library issue

Comments

@sa-tasche
Copy link

Examples

  • std::core::types
    • is_same($TypeA, $TypeB) vs @has_same(#a, #b, ...)
    • to: @is_same($TypeA, $TypeB)
    • is_equatable_type($Type) vs @equatable_value(#value) (where is_equatable_value is @deprecated)
      • to: @equatable_type($Type) @const
  • elsewhere
    • fault ConversionResult vs fault BacktraceFault vs fault AllocationFailure vs fault NumberConversion
      • to: fault *Failure? or something else?
      • fault NumberConversion is descriptive which I prefer. So, not any fault should be renamed; if descriptive.

For functions prefixed with @ (like @equatable_type) there should be a rule when @ must be set.
I think if all parameters are prefixed with $ or #, and only then, they should be prefixed with @.
So Something($TypeA, $TypeB) but not with SomethingElse(any p, $Type) (I think that's not allowed anyway).

There should also be a rule for what must be after an fault-type. (Failure or nothing).
Result is not meaningful enough for me, because a result can be an error, but does not have to be.

@lerno
Copy link
Collaborator

lerno commented Dec 6, 2024

@ is required for macros if the argument is lazily evaluated (like #a), or captures by reference (&a) or must be a compile time constant ($i), and if the macro takes a trailing body. This is to highlight that it has non-function like behaviour.

As for is_same and @has_same those names are deliberately chosen to match the module prefix:
types::is_same(...) and values::@has_same(...). I am somewhat unhappy with the plural module name: type::is_same(...) and probably value::@is_same_type(...) would be an improvement.

Regarding the faults, some care has to be take so that they are unique, as they are intended to be used stand-alone without prefix. Cutting them down in size is desirable though. "Result" is usually correct as it is describing an alternative result to the "normal" result and works to differentiate the name. But I definitely would appreciate suggestions.

@lerno lerno added Additional info please Further information is requested Discussion needed This feature needs discussion to iron out details Stdlib Standard library issue labels Dec 11, 2024
@sa-tasche
Copy link
Author

Ok, but why are there functions prefixed with "@" and "$"-aguments and functions with such arguments but without "@"?

@lerno
Copy link
Collaborator

lerno commented Dec 12, 2024

$Type arguments are fine without @ otherwise you should not see those.

@sa-tasche
Copy link
Author

OK. Now we're back to my first post: inconsistency.
If the ‘@’ is optional, why add it at all?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Additional info please Further information is requested Discussion needed This feature needs discussion to iron out details Stdlib Standard library issue
Projects
None yet
Development

No branches or pull requests

2 participants