From: Alexander Kellett Date: 2005-01-20T00:52:32+09:00 Subject: Re: value by reference On Jan 19, 2005, at 4:38 PM, Michel Martens wrote: > Hi, David. I know how it works now, that's why it's a proposal. The > idea would be to modify the language to allow that kind of > manipulation. Then, the following methods would be allowed: > > a = 'hello world' # String > a.replace(/\w+/) # Regexp > a.replace(35) # Fixnum > a.replace(SomeClass.new) # SomeClass > > And then you would be able to add methods like to_s! or to_i!, > etcetera. replace already exists in string and makes a lot of sense. for what its worth i just had the need for the above, if you want a quick hack solution. go for this: class Ref < SimpleDelegator; def replace obj; __setobj__ obj; end; end its slow as heck, but at least you'll just be able to code away and eventually replace it with a better design which doesn't require such crap. ruby is a happy medium between a functional language without any side effects whatsoever and most of the other side effect ridden languages (perl is an awful example) of these. i'd prefer to see ruby stay as it is. sure, maybe its difficult for you to see redesign just yet, but you'll have to do so in any case. the use of such misdesign will just get you further down the well... Alex