Meaningless Drivel is fun!
The moose likes Clojure and the fly likes dynamic update Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Languages » Clojure
Bookmark "dynamic update" Watch "dynamic update" New topic

dynamic update

Pradeep bhatt
Ranch Hand

Joined: Feb 27, 2002
Posts: 8927

From chp1

Almost everything defined in a Clojure program can be re-defined, even while the
program is running: functions, multimethods, type hierarchies, even Java method
implementations as provided via proxy and gen-class.

Can someone help me understand the internal working ? Is it same as class reloading ?

Hussein Baghdadi
clojure forum advocate

Joined: Nov 08, 2003
Posts: 3479

While I'm not sure and of course waiting for the authors to confirm but I think basically they are talking about Macros in Clojure and the Meta-programming capabilities.
Chris Houser

Joined: Feb 07, 2011
Posts: 22

The exact mechanism used varies based on the kind of thing being reloaded.

Records and protocols (deftype, defrecord, and defprotocol) indeed do something like class reloading using a custom classloader provided by Clojure itself.

Most of the rest are built on top of Clojure Vars, which are a concurrency construct that allows for thread-safe mutation. Updating one of these amounts to making its Var point to the new definition.
I agree. Here's the link:
subject: dynamic update
It's not a secret anymore!