[swift-evolution] [Discussion] Rename BitwiseOperations protocol

Max Moiseev moiseev at apple.com
Wed Jul 6 17:56:01 CDT 2016


OptionSets do conform to AlgebraSet but they require raw value type to conform to BitwiseOperations.

Max

> On Jul 6, 2016, at 3:44 PM, Jordan Rose <jordan_rose at apple.com> wrote:
> 
> Option sets use set notation, not bitwise notation, no?
> 
> Jordan
> 
>> On Jul 6, 2016, at 13:28, Max Moiseev via swift-evolution <swift-evolution at swift.org> wrote:
>> 
>> FixedWidthInteger only handles the implementation for the numbers, we should also consider OptionSet.
>> 
>> I think we should keep the protocol in case someone wants to implement their own type other than an integer to be used as a raw value type in the OptionSet.
>> 
>> As for renaming it, how about BitwiseOperand?
>> 
>> protocol BitwiseOperand {
>> func bitwiseOr(_ rhs: Self) -> Self
>> func bitwiseAnd(_ rhs: Self) -> Self
>> // etc ...
>> }
>> 
>> Max
>> 
>>> On Jul 1, 2016, at 5:19 PM, Dave Abrahams via swift-evolution <swift-evolution at swift.org> wrote:
>>> 
>>> 
>>> on Fri Jul 01 2016, Riley Testut <swift-evolution at swift.org> wrote:
>>> 
>>>> Hi all,
>>>> 
>>>> This is probably very minor, but I’m not sure the protocol name
>>>> “BitwiseOperations” fits the Swift API Design Guidelines. Here’s what
>>>> the guidelines have to say about protocol names:
>>>> 
>>>> Protocols that describe what something is should read as nouns (e.g. Collection).
>>>> 
>>>> Protocols that describe a capability should be named using the
>>>> suffixes able, ible, or ing (e.g. Equatable, ProgressReporting).
>>>> 
>>>> From these two, BitwiseOperations appears to be (attempting) to follow
>>>> the first rule, yet “BitwiseOperations” doesn’t really describe what
>>>> the type is, but rather that it can do bitwise operations. The
>>>> documentation itself even describes the protocol as “a type that
>>>> supports standard bitwise arithmetic operators."
>>>> 
>>>> I propose we rename it to “BitwiseOperable”, or something
>>>> similar. Again, a small change, but if this were to ever happen, I
>>>> think Swift 3 is the time.
>>> 
>>> BitwiseOperations should really be retired after
>>> https://github.com/apple/swift-evolution/blob/master/proposals/0104-improved-integers.md
>>> is implemented, and its uses replaced by FixedWidthInteger.
>>> 
>>> -- 
>>> Dave
>>> 
>>> _______________________________________________
>>> swift-evolution mailing list
>>> swift-evolution at swift.org
>>> https://lists.swift.org/mailman/listinfo/swift-evolution
>> 
>> _______________________________________________
>> 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