From: "Mauricio Fernández" Date: 2002-10-24T00:04:16+09:00 Subject: Re: Things That Newcomers to Ruby Should Know (10/16/02) On Wed, Oct 23, 2002 at 09:34:35PM +0900, Bulat Ziganshin wrote: > Hello Mauricio, > > Wednesday, October 23, 2002, 4:09:02 PM, you wrote: > > >> def a(s) > >> s << '!' > >> s += '?' > >> return s > >> end > > MF> Would it be possible for Ruby to know whether an object is referenced by > MF> several variables so += does '<<' or '... = ... + ...' when appropriate? > > MF> Perhaps a bit in each String indicating whether it is shared or > MF> not would make it... and GC issues could be ignored at first. > > simple things must remain simple :) instead of counting references > and checking reference count at each '+=' ruby just creates new > objects ang g.c. old and unreferenced > Yeah, KISS applies always, but I may anyway try to implement this in the future for the following reasons: * the modification seems easy enough * I will possibly learn more about Ruby's internals in the process * if it's simple and makes Ruby faster, what can be wrong about it? If I consider there's a limited resource (developer time/skills) and something to make (a better Ruby implementation), it would of course make sense for me to spend time on other implementation issues; but as this is as much a "ruby internals exercise" as an actual usable thing, it might end up improving my skills, and actually increasing the amount of available resources (time x skill), and henceforth my output in the midterm :-)! -- _ _ | |__ __ _| |_ ___ _ __ ___ __ _ _ __ | '_ \ / _` | __/ __| '_ ` _ \ / _` | '_ \ | |_) | (_| | |_\__ \ | | | | | (_| | | | | |_.__/ \__,_|\__|___/_| |_| |_|\__,_|_| |_| Running Debian GNU/Linux Sid (unstable) batsman dot geo at yahoo dot com Hah! we have 2 Johnie Ingrams in the channel :) Hey all btw :)