[swift-evolution] [Review] SE-0104: Protocol-oriented integers
plx
plxswift at icloud.com
Fri Jun 24 20:16:51 CDT 2016
+1 but with a few reservations.
# Arithmetic
What *are* the expected semantics of the operators? It seems like you can’t assume much about a generic `Arithmetic` type, e.g. in a generic context I can’t reliably assume even things like these:
- `(x / y) * y == x` (or even “is close to" x)
- `(x + x + … + x) / n == x` (for `x` added together `n` times)
- `((x + y) + z) == (x + (y + z))` (etc.)
- `(x + y) - y == x`(? I think...)
…and so on; am I missing something?
If `Arithmetic` is as lacking in semantics as it seems, then it feels like one of those “bag of syntax” protocols that keep getting mentioned as against the stdlib philosophy.
# More Bit Operations
These don’t have to go into a v1, but I’d like to request seriously considering baking good support for things like popcount first set bit, etc., directly into the appropriate protocol (`FixedWidthInteger`?).
I won’t pretend there are specific generic algorithms simply waiting on their presence or anything…it just seems like a logical extension of the rationalized bit-shifting behavior in the proposal (and at least IMHO things like popcount really ought to have been fundamental operations on par with the shifts and bitwise operations, but that’s an aside).
# Endianness & Byte-Reversal
Endianness seems entirely unaddressed. I assume it’s intentional and, if so, I agree it’s *mostly* best omitted...but I’m curious if there’s already a plan for addressing that at this level or not? Even if just including a function like `func byteReversed() -> Self` (etc.) on a suitable protocol (e.g. `FixedWidthInteger`, or perhaps a new refinement thereof?).
I think that’s it for now. Overall I like it!
> On Jun 22, 2016, at 7:52 PM, Chris Lattner via swift-evolution <swift-evolution at swift.org> wrote:
>
> Hello Swift community,
>
> The review of "SE-0104: Protocol-oriented integers" begins now and runs through June 27. The proposal is available here:
>
> https://github.com/apple/swift-evolution/blob/master/proposals/0104-improved-integers.md
>
> Reviews are an important part of the Swift evolution process. All reviews should be sent to the swift-evolution mailing list at
>
> https://lists.swift.org/mailman/listinfo/swift-evolution
>
> or, if you would like to keep your feedback private, directly to the review manager.
>
> What goes into a review?
>
> The goal of the review process is to improve the proposal under review through constructive criticism and contribute to the direction of Swift. When writing your review, here are some questions you might want to answer in your review:
>
> * What is your evaluation of the proposal?
> * Is the problem being addressed significant enough to warrant a change to Swift?
> * Does this proposal fit well with the feel and direction of Swift?
> * If you have used other languages or libraries with a similar feature, how do you feel that this proposal compares to those?
> * How much effort did you put into your review? A glance, a quick reading, or an in-depth study?
>
> More information about the Swift evolution process is available at
>
> https://github.com/apple/swift-evolution/blob/master/process.md
>
> Thank you,
>
> -Chris Lattner
> Review Manager
>
>
> _______________________________________________
> swift-evolution mailing list
> swift-evolution at swift.org
> https://lists.swift.org/mailman/listinfo/swift-evolution
More information about the swift-evolution
mailing list