Project

General

Profile

Actions

Feature #7738

closed

Deprecate Set#+ as an alias of Set#|, use it for symmetric difference. Introduce Hash#| for Hash#reverse_merge in Rails.

Added by alexeymuranov (Alexey Muranov) almost 12 years ago. Updated over 11 years ago.

Status:
Rejected
Target version:
[ruby-core:51619]

Description

=begin
I am almost sure this will be rejected, but i want to try anyway. My goal is to propose a more efficient and consistent use of binary operator symbols for some classes, in this case for (({Set})) and (({Hash})).

I propose to deprecate (({Set#+})) as an alias of (({Set#|})), and use (({Set#+})) later for the ((symmetric difference)) of sets. I think that operator symbols like (({+})) and (({|})) are too precious to alias one another.

Currently (({Set#+})) is probably the only use of (({#+})) for an operation which is not ((injective)) in each of the arguments: for sets (({a})), (({b})), (({c})), the equality

a + b == a + c

does not currently imply

b == c

The natural binary operation on sets that is injective in each argument is the ((symmetric difference)), it corresponds to the bitwise XOR. I have also noticed that the "(({+}))" for sets is used in "Lectures on ergodic theory " by P. Halmos to denote the symmetric difference.

I also suggest for to define (({Hash#|})) as Hash#reverse_merge in Rails, in my opinion this would correspond nicely to (({Set#|})).
=end

Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0