it is possible to unload a class?

S

sayoyo

Hi,

we can load a library, a class or a gem with the funtionc "require". If
I want to unload a library, a class or a gem, how can I do this, (or it
is possible?)

Thanks you very much

sayoyo
 
E

Edward Faulkner

--t0UkRYy7tHLRMCai
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable

we can load a library, a class or a gem with the funtionc "require". If
I want to unload a library, a class or a gem, how can I do this, (or it
is possible?)

In general it's not possible. =20

I suppose you could try to hunt down and rebind every reference to the
classes/modules in the library, eventually allowing them to be garabge
collected. But I can't think of a practical reason to do that.

--t0UkRYy7tHLRMCai
Content-Type: application/pgp-signature; name="signature.asc"
Content-Description: Digital signature
Content-Disposition: inline

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.1 (GNU/Linux)

iD8DBQFD1opAnhUz11p9MSARAkyeAKDSPS7oMmQuky/p9l3U8pNG21N2qwCgrcnp
eLWQ9EMWQ+RzdScCZ9SpLJQ=
=tmJb
-----END PGP SIGNATURE-----

--t0UkRYy7tHLRMCai--
 
K

Kelly Dwight Felkins

------=_Part_3510_10647874.1138135356444
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
Content-Disposition: inline

Is it possible to reload a class in irb?

In general it's not possible.

I suppose you could try to hunt down and rebind every reference to the
classes/modules in the library, eventually allowing them to be garabge
collected. But I can't think of a practical reason to do that.


-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.1 (GNU/Linux)

iD8DBQFD1opAnhUz11p9MSARAkyeAKDSPS7oMmQuky/p9l3U8pNG21N2qwCgrcnp
eLWQ9EMWQ+RzdScCZ9SpLJQ=3D
=3DtmJb
-----END PGP SIGNATURE-----

------=_Part_3510_10647874.1138135356444--
 
J

Jules Jacobs

You could try something with continuations? Go back to the original
state if you want to unload a library. You'll lose other things too,
unfortunately.

Jules
 
L

Logan Capaldo

You could try something with continuations? Go back to the original
state if you want to unload a library. You'll lose other things too,
unfortunately.

Jules

Continuations aren't that magical. They don't go back in time, just
space as it were. IOW, if you can't do it with first class functions
(possibly using CPS) (or catch/throw or exceptions (although
exceptions for flow control is evil)), you probably can't do it with
continuations either. Of course certain things may be easier to
express with continuations. Continuations are really just glorified
gotos.
 
S

Steffen Kern

Edward said:
I suppose you could try to hunt down and rebind every reference to the
classes/modules in the library, eventually allowing them to be garabge
collected. But I can't think of a practical reason to do that.

Well, there is at least one practical reason I can think of. Consider
a server running several services. Theses services may be started/loaded
and stopped/unloaded during runtime. Thus, it would be really nice to
get rid of classes or modules, which belong to an old service which was
stopped.

Another aspect in this topic is: Is it possible to get rid of a mix-in
which was introduced to a class? I mean, you have a class definition and
afterwards you add a mix-in to that class. At some point in the future,
you don't need the functionality of the mix-in and want to get rid of
it. Maybe it is possible with undef or something like that?

- Steffen
 
P

Paul Brannan

Hi,

we can load a library, a class or a gem with the funtionc "require". If
I want to unload a library, a class or a gem, how can I do this, (or it
is possible?)

See [ruby-talk:161691] and the following thread (in particular,
[ruby-talk:161865]).

Paul
 
T

troyhen

I haven't looked at the source to Webrick, but it seems to me that it
is doing this exact thing. For each request it somehow unloads and
reloads the entire application. If it didn't then your changes between
requests would not take effect. Please enlighten us on how this magic
happens.

Troy
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,202
Messages
2,571,057
Members
47,661
Latest member
FloridaHan

Latest Threads

Top