[#44786] [ruby-trunk - Feature #2565] adding hooks for better tracing — "tenderlovemaking (Aaron Patterson)" <aaron@...>
8 messages
2012/05/01
[#44788] Re: [ruby-trunk - Feature #2565] adding hooks for better tracing
— SASADA Koichi <ko1@...>
2012/05/02
(2012/05/02 8:25), tenderlovemaking (Aaron Patterson) wrote:
[#44789] Re: [ruby-trunk - Feature #2565] adding hooks for better tracing
— SASADA Koichi <ko1@...>
2012/05/02
(2012/05/02 8:25), tenderlovemaking (Aaron Patterson) wrote:
[#44911] [ruby-trunk - Bug #6408][Open] DelegateClass#eql? and <=> don't work as expected — "tenderlovemaking (Aaron Patterson)" <aaron@...>
11 messages
2012/05/06
[#44951] [ruby-trunk - Feature #6414][Open] Destructuring Assignment — "edtsech (Edward Tsech)" <edtsech@...>
14 messages
2012/05/08
[#45001] [ruby-trunk - Bug #6425][Open] Psych issue with !!omap — "trans (Thomas Sawyer)" <transfire@...>
5 messages
2012/05/11
[#45009] [ruby-trunk - Bug #6427][Open] ruby ioctl: Error integer 2148012656 too big to convert to `int' — "hadmut (Hadmut Danisch)" <hadmut@...>
5 messages
2012/05/12
[#45014] [Backport93 - Backport #6429][Assigned] Backport r35631 - [mingw] Errno::EBADF in ruby/test_io.rb on ruby_1_9_3 — "luislavena (Luis Lavena)" <luislavena@...>
3 messages
2012/05/12
[#45015] Re: [ruby-changes:23580] luislavena:r35631 (trunk): * test/ruby/test_io.rb (class TestIO): Disable GC during IO tests to — Tanaka Akira <akr@...>
2012/5/13 luislavena <ko1@atdot.net>:
3 messages
2012/05/12
[#45035] [ruby-trunk - Bug #6433][Open] rb_thread_blocking_region(): ubf() function is executed with GVL — ibc (Iñaki Baz Castillo) <ibc@...>
12 messages
2012/05/14
[#45062] [ruby-trunk - Bug #6436][Open] Byte counting incorrect in BufferedIO (net/protocol.rb) — "jcast (Jeremie Castagna)" <jeremie.castagna@...>
6 messages
2012/05/15
[#45073] [PATCH] Ruby's port to NativeClient — Yuki Yugui Sonoda <yugui@...>
Hello Matz and rubyists,
9 messages
2012/05/16
[#45074] Re: [PATCH] Ruby's port to NativeClient
— SASADA Koichi <ko1@...>
2012/05/16
(2012/05/16 12:34), Yuki Yugui Sonoda wrote:
[#45075] Re: [PATCH] Ruby's port to NativeClient
— Yuki Yugui Sonoda <yugui@...>
2012/05/16
On Wed, May 16, 2012 at 12:43 PM, SASADA Koichi <ko1@atdot.net> wrote:
[#45102] ruby-mode maintainer? — Stefan Monnier <monnier@...>
Could the ruby-mode maintainer(s) contact me off-list?
6 messages
2012/05/17
[#45132] [ruby-trunk - Bug #6454][Open] Anonymous classes should delete tmp_classpath on dup — "tenderlovemaking (Aaron Patterson)" <aaron@...>
5 messages
2012/05/18
[#45176] [ruby-trunk - Bug #6476][Open] Proc unrolls an array even without splat — "prijutme4ty (Ilya Vorontsov)" <prijutme4ty@...>
3 messages
2012/05/22
[#45193] [ruby-trunk - Feature #6482][Open] Add URI requested to Net::HTTP request and response objects — "drbrain (Eric Hodel)" <drbrain@...7.net>
16 messages
2012/05/23
[#45268] [ruby-trunk - Feature #6482] Add URI requested to Net::HTTP request and response objects
— "mame (Yusuke Endoh)" <mame@...>
2012/05/26
[#45222] [ruby-trunk - Feature #6492][Open] Inflate all HTTP Content-Encoding: deflate, gzip, x-gzip responses by default — "drbrain (Eric Hodel)" <drbrain@...7.net>
23 messages
2012/05/24
[#45528] Re: [ruby-trunk - Feature #6492][Open] Inflate all HTTP Content-Encoding: deflate, gzip, x-gzip responses by default
— Eric Wong <normalperson@...>
2012/06/09
"drbrain (Eric Hodel)" <drbrain@segment7.net> wrote:
[#45253] [RFC] RubyVM::FrameInfo.caller method — SASADA Koichi <ko1@...>
Hi,
11 messages
2012/05/26
[#45302] Re: [RFC] RubyVM::FrameInfo.caller method
— Dice <tetradice@...>
2012/05/28
Hello.
[#45269] [ruby-trunk - Bug #6501][Open] Documentation for Exception#set_backtrace is incorrect — "djberg96 (Daniel Berger)" <redmine@...>
3 messages
2012/05/26
[#45272] [ruby-trunk - Feature #6503][Open] Support for the NPN extension to TLS/SSL — "igrigorik (Ilya Grigorik)" <ilya@...>
13 messages
2012/05/27
[ruby-core:44858] [ruby-trunk - Feature #6361] Bitwise string operations
From:
"kernigh (George Koehler)" <xkernigh@...>
Date:
2012-05-03 21:04:42 UTC
List:
ruby-core #44858
Issue #6361 has been updated by kernigh (George Koehler).
=begin
A new BinaryString (or Blob) class would entail several changes. For example, Array#pack and IO#read(n) would need to return BinaryString, not String. I prefer to keep String for binary strings.
The main reason, to perform bitwise operations on a String, is to use this String as an array of bits. The purpose of each bitwise operation is to clear or set some bits in this array. For example, a sieve of Erathosthenes might clear a bit in a String to show that a number is not prime.
String has no bitwise operations. So, the code to clear a bit is long, not simple.
sieve = "\xAC(\x8A\xA2("
# 25 is not prime. Clear bit 0x02 of byte 3.
sieve.setbyte(3, sieve.getbyte(3) & ~0x02)
A simpler way, with current Ruby, is to unpack this String into an Array of Integers. The code can then perform bitwise operations with these Integers.
sieve = "\xAC(\x8A\xA2(".unpack("C*")
# 25 is not prime. Clear bit 0x02 of byte 3.
sieve[3] &= ~0x02
The sieve in [1] uses an Array of 16-bit Fixnums. This works because Fixnum has bitwise operations. A sieve at [2] uses an Array of true and false. This also works, though it uses more memory.
[1] https://github.com/ruby/ruby/blob/trunk/lib/prime.rb
[2] http://rosettacode.org/wiki/Sieve_of_Eratosthenes#Ruby
If String would have bitwise operations, a sieve of Eratosthenes might use them. If String#& and String#~ would exist, then they can clear a bit.
sieve = "\xAC(\x8A\xA2("
sieve[3] &= ~"\x02"
With this design, String#& and String#~ never modify the original string. This design forgot that Strings are mutable. String#& must allocate a new string, before String#[]= modifies the original string. A better design might provide destructive methods that use bitwise operations to modify a slice of the original string.
=end
----------------------------------------
Feature #6361: Bitwise string operations
https://bugs.ruby-lang.org/issues/6361#change-26433
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/