--000e0cd304705285d5046f5dc7f6
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit

Matz,
I have been thinking a lot about trying to find a way to make it easier to
implement code reloading in Ruby. Rails already implements code reloading
using remove_const, undef, etc., but it's fairly messy and can produce
problems. It's also a fair bit of code to implement.

I was thinking that the addition of a simple feature would make this a lot
easier to do in Ruby: savepoints. It would work like this:

class Foo
end

sp  bjectSpace.savepoint

class Bar
end

bar  ar.new

sp.rollback

Foo #Foo
Bar #nil (or RefError)
bar #nil (or RefError)

Then, if we load the files again, we should get a reliable new set of
classes. This feature would only be used in development, single-threaded
mode, and in isolated scenarios (the user changed a file--next time the user
requests a page, roll back the savepoint and reload the user's classes).

I am unsure what the correct solution is, but having a more explicit way in
Ruby to handle class reloading (which we already do in Rails, and it's an
important feature) would be very helpful.

-- 
Yehuda Katz
Developer | Engine Yard
(ph) 718.877.1325

--000e0cd304705285d5046f5dc7f6
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable

Matz,<div><br></div><div>I have been thinking a lot about trying to find a way to make it easier to implement code reloading in Ruby. Rails already implements code reloading using remove_const, undef, etc., but it&#39;s fairly messy and can produce problems. It&#39;s also a fair bit of code to implement.</div>

<div><br></div><div>I was thinking that the addition of a simple feature would make this a lot easier to do in Ruby: savepoints. It would work like this:</div><div><br></div><div><font class="Apple-style-span" face="&#39;courier new&#39;, monospace"><span class="Apple-style-span" style="font-size: large;">class Foo</span></font></div>

<div><font class="Apple-style-span" face="&#39;courier new&#39;, monospace"><span class="Apple-style-span" style="font-size: large;">end</span></font></div><div><font class="Apple-style-span" face="&#39;courier new&#39;, monospace"><span class="Apple-style-span" style="font-size: large;"><br>

</span></font></div><div><font class="Apple-style-span" face="&#39;courier new&#39;, monospace"><span class="Apple-style-span" style="font-size: large;">sp = ObjectSpace.savepoint</span></font></div><div><font class="Apple-style-span" face="&#39;courier new&#39;, monospace"><span class="Apple-style-span" style="font-size: large;"><br>

</span></font></div><div><font class="Apple-style-span" face="&#39;courier new&#39;, monospace"><span class="Apple-style-span" style="font-size: large;">class Bar</span></font></div><div><font class="Apple-style-span" face="&#39;courier new&#39;, monospace"><span class="Apple-style-span" style="font-size: large;">end</span></font></div>

<div><font class="Apple-style-span" face="&#39;courier new&#39;, monospace"><span class="Apple-style-span" style="font-size: large;"><br></span></font></div><div><font class="Apple-style-span" face="&#39;courier new&#39;, monospace"><span class="Apple-style-span" style="font-size: large;">bar = Bar.new</span></font></div>

<div><font class="Apple-style-span" face="&#39;courier new&#39;, monospace"><span class="Apple-style-span" style="font-size: large;"><br></span></font></div><div><font class="Apple-style-span" face="&#39;courier new&#39;, monospace"><span class="Apple-style-span" style="font-size: large;">sp.rollback</span></font></div>

<div><font class="Apple-style-span" face="&#39;courier new&#39;, monospace"><span class="Apple-style-span" style="font-size: large;"><br></span></font></div><div><font class="Apple-style-span" face="&#39;courier new&#39;, monospace"><span class="Apple-style-span" style="font-size: large;">Foo #=&gt; Foo</span></font></div>

<div><font class="Apple-style-span" face="&#39;courier new&#39;, monospace"><span class="Apple-style-span" style="font-size: large;">Bar #=&gt; nil (or RefError)</span></font></div><div><font class="Apple-style-span" face="&#39;courier new&#39;, monospace"><span class="Apple-style-span" style="font-size: large;">bar #=&gt; nil (or RefError)</span></font></div>

<div><br clear="all">Then, if we load the files again, we should get a reliable new set of classes. This feature would only be used in development, single-threaded mode, and in isolated scenarios (the user changed a file--next time the user requests a page, roll back the savepoint and reload the user&#39;s classes).</div>

<div><br></div><div>I am unsure what the correct solution is, but having a more explicit way in Ruby to handle class reloading (which we already do inails, and it&#39;s an important feature) would be very helpful.</div>

<div><br>-- <br>Yehuda Katz<br>Developer | Engine Yard<br>(ph) 718.877.1325<br>
</div>

--000e0cd304705285d5046f5dc7f6--