Skip to content

is // required to return Rational? Alternatively, an interface for rationals #55661

@nsajko

Description

@nsajko

I want to implement // for my own types. The return type would subtype Real and it'd also overload numerator and denominator, but it wouldn't subtype Rational. Would that be allowed?

The motivation is twofold:

  • (Regular) continued fractions seem to be a good choice for encoding rational numbers. It'd be nice if such a type/package could overload // to return the same type, instead of Rational.
  • Rational doesn't generally support type domain numbers, because it requires the numerator and denominator to have the same type. Thus a new, "type domain rational", type would be nice, and // would ideally return type domain numbers given type domain numbers as input.

Metadata

Metadata

Assignees

No one assigned

    Labels

    designDesign of APIs or of the language itselfdocsThis change adds or pertains to documentationrationalsThe Rational type and values thereof

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions