On Tue, 12 Feb 2002, Jeff 'japhy' Pinyan wrote: > Now, as far as the first one goes, yes, I know out[0,1] creates a COPY of > the first character of the string, and I know that out[0] returns a > FixNum, but still... there's something that screams "too much work" to me. > It's probably because there's no concept of pointers here. I've been > thinking of implementing pointer-like things into Perl, but I'm not sure > how useful they would be. Here's a new part of MetaRuby (samples/SubArray.rb) 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; end class SubString; include HollowString, SimpleStringP, SubList; 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" ________________________________________________________________ Mathieu Bouchard http://hostname.2y.net/~matju