[#4522] Undefined Errno::EPROTO and the like raises NameError — "Florian Frank" <flori@...>
Hi,
[#4533] giving acces readline to rl_line_buffer — "Cs. Henk" <csaba-ml@...>
Hi!
[#4548] Ruby 1.8.2 array of hash entries functions incorrectly — noreply@...
Bugs item #1613, was opened at 2005-03-09 19:49
[#4561] rb_reg_quote weirdness — Nikolai Weibull <mailing-lists.ruby-core@...>
(Two weirdnesses in one day.)
Hi,
[#4567] Immutable Ropes — Nikolai Weibull <mailing-lists.ruby-core@...>
Note how I didn't write "Immutable Strings" in the subject.
[#4575] Allowing "?" in struct members — "Berger, Daniel" <Daniel.Berger@...>
Hi all,
[#4587] 0**0==1? — Bertram Scharpf <lists@...>
Hi,
[#4595] New block syntax — Daniel Amelang <daniel.amelang@...>
I'm really sorry if this isn't the place to talk about this. I've
Daniel Amelang wrote:
Hi --
On Monday 21 March 2005 16:17, David A. Black wrote:
Hi --
Hey David, I think that we've had some misunderstandings due to
Hi --
On Wednesday 30 March 2005 20:55, David A. Black wrote:
On Sunday 20 March 2005 21:31, Daniel Amelang wrote:
[#4601] Re: New block syntax — "Berger, Daniel" <Daniel.Berger@...>
> -----Original Message-----
[#4611] want_object? - possible? — "Berger, Daniel" <Daniel.Berger@...>
Hi all,
[#4619] Re: want_object? - possible? — Daniel Berger <djberg96@...>
--- nobu.nokada@softhome.net wrote:
Hi --
On 3/24/05, David A. Black <dblack@wobblini.net> wrote:
Hi --
On 4/14/05, David A. Black <dblack@wobblini.net> wrote:
On 14 Apr 2005, at 22:20, Mark Hubbart wrote:
On 4/15/05, Eric Hodel <drbrain@segment7.net> wrote:
[#4622] tempfile.rb — Tilman Sauerbeck <tilman@...>
Hi,
[#4648] about REXML::Encoding — speakillof <speakillof@...>
Hi.
On Thursday 31 March 2005 09:44, speakillof wrote:
Hi.
I've tested, applied, and committed your Encoding patch, Nobu.
Hi,
Re: Immutable Ropes
On Tue, 15 Mar 2005, Nikolai Weibull wrote:
> Another nice property is that as one abstracts away the
> pointer-to-char, ropes can be created lazily from IO or other
> generators of data. As an example, say that we want a String of one
> million a's s = "a" * 1000000 With a Rope, we could have written this
> as: r = Rope.new("a", 1000000) and that could be represented very
> efficiently. A better example is if we would like to search the
> concatenation of two strings for a regular expression. Using only
> Strings, we would have to write this as:
One related project is my old project called MetaRuby. I presented it at
the Europ臺sche Ruby Konferenz 2004 (although I wrote all of the code in
2001).
MetaRuby has a concept of virtual strings, that are (by default) mutable
(and freezable), but it's easy to make examples like the ones you give
with it. Here's example code for MetaRuby, that exhibits the kind of
things you can do with mutable strings that have shared mutable segments.
It wouldn't be too much extra work to add a few more variants like one
that's immutable with copy-on-write, O(1) catenation, etc.
require "Hollow/Array"
require "Hollow/String"
module SubList
# there could/should be a notifier so that when elements are
# inserted before the @i position, that position is incremented, etc.
# this requires an Observable Array, which does not exist yet.
def initialize(list,i,n) @list,@i,@n = list,i,n end
def length; @n; end
def get(i) @list[@i+i] end
def get_seq(i,n) @list[@i+i,n] end
def put(i,v) @list[@i+i]=v end
def put_seq(i,n,v)
raise "can't insert/delete" if v.length!=n
@list[@i+i,n]=v
end
end
class SubArray; include HollowArray, SimpleArrayP, SubList
def self.new(*a) if a.length==0 then "" else super end end
end
class SubString; include HollowString, SimpleStringP, SubList
def self.new(*a) if a.length==0 then "" else super end end
end
class Array; def part(i,n) SubArray.new(self,i,n) end end
class String; def part(i,n) SubString.new(self,i,n) end end
x="machin truc patate"
x.part(7,4).upcase!
p x #==> "machin TRUC patate"
y=x.part(4,5)
p y #==> "in TR"
y.downcase!
p y #==> "in tr"
p x #==> "machin trUC patate"
y.tr! 'a-z','n-za-m'
p x #==> "machva geUC patate"
y[2]="\n"
p x #==> "machva\ngeUC patate"
p y.map {|line| "[#{line.chomp}]" }.join
#==> "[va][ge]"
(However, MetaRuby really should be updated for Ruby 1.8... *I KNOW*)
_____________________________________________________________________
Mathieu Bouchard -=- Montr饌l QC Canada -=- http://artengine.ca/matju