Skip to content

Simplify Varargs API #988

Open
Open
@chitoyuu

Description

@chitoyuu

While #886 was an interesting addition to the library, some of its decisions are dubious in necessity:

  • The addition of gdnative::export::IndexBounds, whose functionalities largely duplicate the standard std::ops::RangeBounds trait.
  • The use of TryFrom for tuple impls, which as opposed to the existing FromVarargs:
    • Can only report a single error, instead of all the errors.
    • Does not have the same composability (FromVarargs types can be chained for common argument sets).
    • Is unused anywhere else.
  • Introduction of a new VarargsError type, that:
    • Does not work with the existing gdnative::export::ArgumentError type, but duplicates its functionality instead.
    • Lacks the ability to be reported with a Site.
    • Is unused anywhere else, anyway.
  • Addition of APIs that needlessly expose internals, and can complicate future changes.
    • Method arguments are meant to be accessed sequentially, required ones followed by optional ones. FromVariant conversions are meant to be done only once, because otherwise it's just unnecessary inefficiency. Accessing Varargs in any other way is most certainly a user error, and should not be enabled by the API design.
    • That Varargs is internally a slice should have remained an implementation detail, because there exist reasons why we might want to change that later, like in case we uncovered a source of UB during the conversion.

We probably want to re-consider how much of these are actually useful to the end user, and deprecate/remove things that are mostly cruft.

Metadata

Metadata

Assignees

No one assigned

    Labels

    breaking-changeIssues and PRs that are breaking to fix/merge.c: exportComponent: export (mod export, derive)quality-of-lifeNo new functionality, but improves ergonomics/internals

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions