A couple of quick questions:
a) Are object id's ever reused within the life of a Ruby process?
b) Are object id's unique across the whole Ruby process, or only within a given context?
···
--
Alex
A couple of quick questions:
a) Are object id's ever reused within the life of a Ruby process?
b) Are object id's unique across the whole Ruby process, or only within a given context?
--
Alex
Hi,
a) Are object id's ever reused within the life of a Ruby process?
They are recycled by garbage collector.
b) Are object id's unique across the whole Ruby process, or only within
a given context?
They are unique in the certain point of the execution.
matz.
In message "Re: Object IDs" on Tue, 11 Jul 2006 23:10:15 +0900, Alex Young <alex@blackkettle.org> writes:
A couple of quick questions:
a) Are object id's ever reused within the life of a Ruby process?
I believe that Object#equal? compares ids if not overridden.
b) Are object id's unique across the whole Ruby process, or only within a given context?
Unique across the process.
Guillaume.
Le 11 juil. 06, à 10:10, Alex Young a écrit :
--
Alex
Yukihiro Matsumoto wrote:
Hi,
>a) Are object id's ever reused within the life of a Ruby process?
They are recycled by garbage collector.
Thanks... That explains a minor oddness I'm seeing. Are they recycled before the finalizers are called?
>b) Are object id's unique across the whole Ruby process, or only within >a given context?
They are unique in the certain point of the execution.
I thought they would be, just wanted to be sure
Thanks,
In message "Re: Object IDs" > on Tue, 11 Jul 2006 23:10:15 +0900, Alex Young <alex@blackkettle.org> writes:
--
Alex
if you wait long enough they can be recycled so i wouldn't say they are unique
'across' a process. that is to say ruby code which does this
hash = Hash.new{|h, object_id| h[object_id] << 42}
will stack info about two different objects if it runs long enough or is
simply unlucky and only runs for a short time.
in otherwords
id = object.object_id
# time
value = ObjectSpace::_id2ref id
may or may not retreive the same object and the error may or may not go
unnoticed.
in summary, i'd say that object_ids are unique in a given context, that
context being an instant of time in a given process. as time progresses, even
by a millisecond, the chances of objects being recycled increases. fyi.
regards.
-a
On Tue, 11 Jul 2006, Guillaume Marcais wrote:
Le 11 juil. 06, à 10:10, Alex Young a écrit :
A couple of quick questions:
a) Are object id's ever reused within the life of a Ruby process?
I believe that Object#equal? compares ids if not overridden.
b) Are object id's unique across the whole Ruby process, or only within a given context?
Unique across the process.
--
suffering increases your inner strength. also, the wishing for suffering
makes the suffering disappear.
- h.h. the 14th dali lama
Hi,
In message "Re: Object IDs" on Tue, 11 Jul 2006 23:41:11 +0900, Alex Young <alex@blackkettle.org> writes:
Thanks... That explains a minor oddness I'm seeing. Are they recycled
before the finalizers are called?
No. Finalizers are called before the recycling.
matz.
Yukihiro Matsumoto wrote:
Hi,
>Thanks... That explains a minor oddness I'm seeing. Are they recycled >before the finalizers are called?
No. Finalizers are called before the recycling.
matz.
Great. Thanks for confirming that.
In message "Re: Object IDs" > on Tue, 11 Jul 2006 23:41:11 +0900, Alex Young <alex@blackkettle.org> writes:
--
Alex