Issue #6361 has been updated by MartinBosslet (Martin Bosslet).


duerst (Martin Dürst) wrote:
>  
>  Despite the title of this issue, I didn't see any *bit*wise operations 
>  (e.g. bitwise and/or/xor/not) proposed. Were you just taking them for 
>  granted? What about adding these to String, maybe limiting them to 
>  binary/ASCII-8bit?
>  

Sorry for the confusion, you are right, I should have actually written "bytewise"
in the title for my initial proposal.

There is a risk of exaggerating things, but on the other hand I think
a feature like this would simplify implementing low-level binary protocols 
a lot by reducing the amount of bit shuffling which obviously is a common
source of errors, for example I really like what Erlang allows you to do [1].

I'm not against adding the functionality to String, it could just be that 
a separate class might help to separate concerns more clearly. Adding more 
methods to String would would mean more work when duck-typing a String etc.

http://www.erlang.org/documentation/doc-5.6/doc/programming_examples/bit_syntax.html 

----------------------------------------
Feature #6361: Bitwise string operations
https://bugs.ruby-lang.org/issues/6361#change-26469

Author: MartinBosslet (Martin Bosslet)
Status: Feedback
Priority: Normal
Assignee: 
Category: core
Target version: 


I know this has been discussed a lot in the past (and if there's still 
an open issue for this, I apologize, I couldn't find one), for example
in [1]. While it is generally no problem to implement this on the fly,
I still find that built-in support would be a real improvement. There
are quite some use cases in cryptography where this would come in very
handy, but I'm sure there are lots of other areas, too.

While of course I understand the reasons that were given in the previous
threads that ultimately lead to rejection, I still would like to reopen
the discussion as I felt that in every thread so far the consensus was
that having bitwise string operations would indeed be quite valuable. 

[1] http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-core/34586


-- 
http://bugs.ruby-lang.org/