From: Gavin Sinclair Date: 2004-11-26T10:19:50+09:00 Subject: Re: Fixnum#clone and Float#clone raise different exceptions On Friday, November 26, 2004, 10:47:02 AM, Yukihiro wrote: > Hi, > In message "Re: Fixnum#clone and Float#clone raise different exceptions" > on Thu, 25 Nov 2004 22:49:20 +0900, Gavin Sinclair > writes: |4.clone ->> 4 sounds better to me, but I must be missing something. > Do you accept the following behavior? > a = 4 > a.instance_eval{@a=5} > b = a.clone # b = 4 > b.instance_eval{@a=10} > a.instance_eval{@a} # @a = 10 > Similar thing can happen for a Float and singleton methods. Yes, I do accept that behaviour, because setting instance variables of a number is very esoteric. But I realise it could cause some people to come to grief :) Thanks for pointing it out. Could immediate objects adopt copy-on-write semantics? Such that it's possible to clone 4 and have two separate objects when needed (e.g. for instance variables), but optimised for the common case? Gavin