Skip to content

Document Number interface #31937

Open
Open
@BeastyBlacksmith

Description

I think it would be good to document what methods needs to be defined for a type to behave as a Number.
Last time I had to do this it took me quite some try and error to get the methods.

I ended up with the following

  • +, -, *, / 3 each ( (T,T), (T,Any), (Any,T) )
  • ==, hash, <
  • promote_rule, convert
  • rem, signed, typemax
  • show, Constructor

That works in my usecase, but I am still unsure if this is "correct" or it its lacking something.
If I got it right, a Number is something that can be used in basic arithmetic, can be compared, and needs some basic rules to be usable in julia.

Maybe Number is too broad and it would need to be further devided.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    designDesign of APIs or of the language itselfdocsThis change adds or pertains to documentation

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions