Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

dynamic update

 
Pradeep bhatt
Ranch Hand
Posts: 8927
Firefox Browser Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Bartender
Posts: 3479
Clojure Mac Objective C
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
author
Greenhorn
Posts: 22
Clojure Linux VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic