Pastie now auto-senses if line-wrap is a bad or good idea. Feedback?
## mark a section (Learn more)
This paste will be private.
diff --git a/kernel/bootstrap/array.rb b/kernel/bootstrap/array.rb index 5c1ce06..530235d 100644 --- a/kernel/bootstrap/array.rb +++ b/kernel/bootstrap/array.rb @@ -1,4 +1,8 @@ class Array + def self.__allocate__ + Ruby.primitive :allocate + raise PrimitiveFailure, "Array.allocate failed" + end def size @total diff --git a/kernel/core/array.rb b/kernel/core/array.rb index d89b6c1..fa4283d 100644 --- a/kernel/core/array.rb +++ b/kernel/core/array.rb @@ -30,27 +30,19 @@ class Array def self.[](*args) new args end - - def self.new(*args, &block) - raise ArgumentError, "Wrong number of arguments, #{args.size} for 2" if args.size > 2 - - ary = allocate - ary.__send__ :setup - ary.__send__ :initialize, *args, &block - ary - end # At present, @tuple.kind_of?(Tuple) is essentially an invariant for Array. # If we relax this and ensure that every method behaves correctly if # @tuple == nil, then we can omit initializing @tuple here. We cannot # easily know whether #initialize is defined in a subclass when this # method is called. - def setup - @start = 0 - @total = 0 - @tuple = Tuple.new 8 + def self.allocate + ary = __allocate__ + ary.start = 0 + ary.total = 0 + ary.tuple = Tuple.new 8 + ary end - private :setup
From the Design Piracy series on my blog: