Make `BinaryInteger._binaryLogarithm()` public API

I am currently implementing a min-max heap (to back a priority queue), and this function would be useful in determining if a given index falls into a min layer or max layer. Yes, I could copy the implementation of FixedWidthInteger._binaryLogarithm() into my code (and I have basically already implemented the same thing), but maybe it's time to have a discussion about removing the prefix on this function and making it public API instead.

Thoughts?

3 Likes

Seems it can be exposed as part of public API.

"Yes, I could copy the implementation of FixedWidthInteger._binaryLogarithm() into my code" – why should you copy it? The following code is valid:

let binaryLogarithm = Int(0)._binaryLogarithm()

The problem is that currently it is marked with underscore and therefore unofficial.
So, lets make it official.

why should you copy it? The following code is valid:

Yeah, fair. I mostly wanted to insulate myself from the change if it gets promoted to official public API.

There hasn't been much engagement on this; I think I'm going to work on putting together an official evolution proposal.

1 Like
Terms of Service

Privacy Policy

Cookie Policy