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

Listing some undocumented interfaces found in base #9

Open
LilithHafner opened this issue Aug 4, 2023 · 3 comments
Open

Listing some undocumented interfaces found in base #9

LilithHafner opened this issue Aug 4, 2023 · 3 comments

Comments

@LilithHafner
Copy link

The most prominent interfaces defined in base are listed in the documentation. Here are some others:

Rounding

Define
MyType <: Real
Base.round(::MyType, ::RoundingMode)

Get
round(::Type{T}, ::MyType, ::RoundingMode)
round(::Type{T}, ::MyType)
floor(::Type{T}, ::MyType)
ceil(::Type{T}, ::MyType)
trunc(::Type{T}, ::MyType)
round(::MyType)
floor(::MyType)
ceil(::MyType)
trunc(::MyType)

Sorting

Define
Base.isless(::MyType, ::MyType)

Get
issorted(::AbstractVector{MyType})
sort(::AbstractVector{MyType}; kw...)
sort!(::AbstractVector{MyType}; kw...)
sortperm(::AbstractVector{MyType}; kw...)
sortperm!(::AbstractVector{<:Integer}, ::AbstractVector{MyType}; kw...)
partialsort(::AbstractVector{MyType}; kw...)
partialsort!(::AbstractVector{MyType}; kw...)
partialsortperm(::AbstractVector{MyType}; kw...)
partialsortperm!(::AbstractVector{<:Integer}, ::AbstractVector{MyType}; kw...)

@Seelengrab
Copy link
Owner

Seelengrab commented Aug 4, 2023

That's a very good list! I have the "you get these methods" part of interfaces implemented on a branch, but it's not yet merged into main. Still needs some tests!

I've also thought about whether (and how) this package should have these kinds of existing interfaces as part of a checkable set of default interfaces. It's sometimes a bit unclear, because having a fallback definition actually throwing an NotImplementedError would be piracy and cause lots of invalidations.. Still, collecting these implicit interfaces is a good idea.

A similar list can probably be done for the rand family of functions.

@LilithHafner
Copy link
Author

The "you get these methods" list will always be incomplete, but I still think it's good to have.

A similar list can probably be done for the rand family of functions.

Yes, that would be nice to have.

@Seelengrab
Copy link
Owner

Of course - the "you get these methods" list is purely intended as a "we guarantee to support at least these calls", not as an exhaustive list of what technically works. Otherwise it could be automated via reflection.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants