Ruby-dev summary 17965-18021

Hi all,
This is a summary of ruby-dev ML in these days.

-------- #17965-18021 (2002-08-09 …2002-08-16) --------

[ruby-dev:17966] Hash has default block?

TANAKA Akira has asked that there is a method to determine
whether a hash has the default block. Matz has proposed a new method
Hash#default_proc and Akira has agreed.

[ruby-dev:17970] new scope-in-state

Keiju Ishitsuka has announced his scope-in-state module.
This module allows you to restrict an effect of
"destructive" library, such as jcode.rb or mathn.rb.

# e.g.
1 / 1       # is 1 (Fixnum)
MathnScope.scope_in {
    1 / 1   # is Rational(1,1)
}
1 / 1       # is 1 (Fixnum)

You can get scope-in-state library from RAA:
http://www.ruby-lang.org/en/raa-list.rhtml?name=scope-in-state

[ruby-dev:17974] optimization module

Takaaki Tateishi has announced `optimize’ module and
Matz has suggested it is worth including to the core.

see also: [ruby-talk:46661] optimization module and tail recursion

[ruby-dev:17965] inferior-ruby-mode and irb

This thread has occurred synchronizing with ruby-talk:
[ruby-talk:47113] ruby-mode / inferior ruby.

[ruby-dev:18004] allocation framework

TANAKA Akira has noted that following code causes segmentation
fault.

# pattern 1
class << Object
  alias obj_allocate allocate
end
Hash.obj_allocate   # calls Object.allocate for Hash

# pattern 2
class << Hash
  remove_method :allocate
end
Hash.allocate   # calls Object.allocate for Hash

# pattern 3
class << Object
  alias obj_allocate allocate
end
class << Array
  alias allocate obj_allocate
end
Array.allocate   # calls Object.allocate for Array

The purpose of the allocation framework is to get an internal
structure of instances from the class (e.g. struct RObject for Object).
Currently CLASS.allocate works for it, but it is too easy to
modify class methods from Ruby programs. Result: Ruby programs
will become very weak.

Matz has said that we must reconsider allocation framework itself.

– Minero Aoki

Keiju Ishitsuka has announced his scope-in-state module.
This module allows you to restrict an effect of
"destructive" library, such as jcode.rb or mathn.rb.

# e.g.
1 / 1       # is 1 (Fixnum)
MathnScope.scope_in {
    1 / 1   # is Rational(1,1)
}
1 / 1       # is 1 (Fixnum)

You can get scope-in-state library from RAA:
http://www.ruby-lang.org/en/raa-list.rhtml?name=scope-in-state

In what ways does this library differ from dblack’s Ruby Behaviors
(http://www.superlink.net/~dblack/ruby/behaviors/)?

The purpose of the allocation framework is to get an internal
structure of instances from the class (e.g. struct RObject for Object).
Currently CLASS.allocate works for it, but it is too easy to
modify class methods from Ruby programs. Result: Ruby programs
will become very weak.

Matz has said that we must reconsider allocation framework itself.

I thought the purpose of the allocation framework was so that I could
intercept the allocation of an object; that is, I could know when an
object was about to be allocated, and I could know when an object had
already been allocated but not yet initialized.

Why would I want to allocate an object but not initialize it?

Paul

···

On Mon, Aug 19, 2002 at 11:35:01PM +0900, Minero Aoki wrote:

Where can I find an example of how the type information of the class
instance is obtained/used?

Paul

···

On Tue, Aug 20, 2002 at 08:09:54AM +0900, Yukihiro Matsumoto wrote:

The original intention was

  • to allow hook for the object creation
  • to know the type (e.g. T_OBJECT) of the class instance.

Hi,

···

In message “Re: ruby-dev summary 17965-18021” on 02/08/20, Paul Brannan pbrannan@atdesk.com writes:

  • to know the type (e.g. T_OBJECT) of the class instance.

Where can I find an example of how the type information of the class
instance is obtained/used?

marshal.c in the latest CVS. Notice it is going to change.

						matz.