ruby-dev summary 21403-21530

M

Minero Aoki

Hi all,

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

[ruby-dev:21416] return value of #warn

In current 1.8, #warn returns its argument. U.Nakamura
reported that #warn returns undetermined value on -W0.
The return value was fixed to nil.

[ruby-dev:21176] marshalling ivtbl of Time

In old 1.8, ruby did not dump instance variables if #_dump or
#marshal_dump is defined. Almost all built-in classes do not
have #_dump/#marshal_dump, except the Time class (it has #_dump).
So instance variables of Time objects will not be dumped. e.g.

% ruby -ve '
t = Time.now
t.instance_eval { @ivar = 3 }
Marshal.load(Marshal.dump(t)).instance_eval { p @ivar }
'
ruby 1.8.0 (2003-08-10) [i686-linux] # != 1.8.0 release (2003-08-04)
-e:3: warning: instance variable @ivar not initialized
nil

Matz decided to dump/restore instance variables automatically,
even if #_dump/#marshal_dump is defined. But it causes needless
errors when trying to dump objects which include unserializable
objects, e.g. IO. Then if an object has #_dump/#marshal_dump
and meets unserializable objects, ruby will not raise exception,
just ignore it. See following example for changes.

% cat marshal_io
class C
def initialize
@io = STDIN
@n = 99
end
def marshal_dump
3
end
def marshal_load( obj )
@io = STDIN
end
end
c = C.new
p c
p Marshal.load(Marshal.dump(c))


% ruby-1.8.0 marshal_io
#<C:0x401ace1c @io=#<IO:0x401b3280>, @n=99>
#<C:0x401accc8 @io=#<IO:0x401b3280>> # @n is not restored

% ruby-HEAD marshal_io
#<C:0x40270e1c @n=99, @io=#<IO:0x40277294>>
#<C:0x40270cc8 @n=99, @io=#<IO:0x40277294>>

[ruby-dev:21498] {test,lib}/ChangeLog?

Now ChangeLog file contains ruby's whole changes, including
test/*, lib/*, ext/*, etc. But there are other schemes of logging,
e.g. one file per one directory. NAKAMURA Hiroshi asked what our
scheme should be; where to log for test scripts, for example.

Matz replied that he prefers one ChangeLog file.

[ruby-dev:21508] eval BEGIN/END at runtime

NAKAMURA Hiroshi asked how appropriate is current BEGIN/END block
behavior. See following script:

eval 'BEGIN { puts "begin" }
END { puts "end" }'
puts '----'

Ruby prints "begin", "----", then "end". So, when we execute
BEGIN/END in eval, BEGIN block is executed at the beginning of
eval, END block is executed at the end of ruby process.

Matz replied that this is a feature.


-- Minero Aoki
 
Y

Yukihiro Matsumoto

Hi,

In message "Re: ruby-dev summary 21403-21530"
|
|On Thu, Oct 09, 2003 at 06:40:41AM +0900, Minero Aoki wrote:
|> Matz decided to dump/restore instance variables automatically,
|> even if #_dump/#marshal_dump is defined. But it causes needless
|> errors when trying to dump objects which include unserializable
|> objects, e.g. IO. Then if an object has #_dump/#marshal_dump
|> and meets unserializable objects, ruby will not raise exception,
|> just ignore it.
|
|This seems like a bad idea to me. My object may have references to
|objects that I do not want dumped, for one reason or another.

I agree you _now_. That's the benefit from this experiment. See next
week's ruby-dev summary [ruby-talk:84138].

matz.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,990
Messages
2,570,211
Members
46,796
Latest member
SteveBreed

Latest Threads

Top