Hi Jurjen,

That wrapper for defn is something I was looking for in another post;
I previously asked how I can inspect the definitions of my functions
on the REPL. When I'm exploring stuff I'll be redefining many
functions many times and sometimes I lose track things. I basically
have to scroll around searching my REPL for the last definition. It
sounds like you have a solution to this problem. It seems strange to
me that Clojure doesn't support this concept natively. At some point
the function definition is compiled into bytecode to run on the JVM,
why not just automatically safe the original definition in metadata
when this is done? Have you should about adding your wrapper code to
Contrib?

Rob




On Wed, Jul 8, 2009 at 12:30 PM, Jurjen<jurjen.hait...@gmail.com> wrote:
>
> I had the same thought (as posted in the other thread) and haven't
> come to a final solution yet. The main reason I wanted to achieve it
> was that I do my developing / tinkering / brainstorming spread over
> several work boxes spread out through several locations, and a clojure
> REPL is cheap and easy, whereas maintaining several IDEs in synch (3
> locations at work, 2 at home) can be a bit of a nightmare.
>
> The compromise I've got at the moment is that I've made a custom
> wrapper around [defn] that records the code used to create the
> instance, and stores it in the metadata of the var that points to the
> function. I can then cycle through the namespace definitions using ns-
> interns / ns-publics and see the definition of each function, and can
> save it to a file.
>
> I tried to create a print-dup method so that the entire contents of a
> namespace could be dumped to a file, but as chouser pointed out, print-
> dup works on the function itself, whereas the code is stored in the
> metadata of the var that points to the function (and there's no back-
> link from the function to the var), so now it is a multi-stage process
> to port current code in its entirety, but as I'm generally only
> working on fairly limited areas of code it isn't a huge deal.
> Also, any closures are not captured by capturing the source, so
> there's still issues there, but for me the function definition is
> generally good enough. Still have to implement it for macros as well,
> but haven't needed that as much.
>
> Incidentally, I find the easiest way to port my code around is to
> print it to the repl, then cut-and-paste it to etherpad, which I can
> then access from anywhere (without having to save). Now if only there
> was a hosted REPL that integrated an IDE nicely I would really be set.
> Lord-of-all-repls comes close, but is not pure clojure or JVM.
>
> Jurjen
>
> On Jul 8, 8:13 pm, Robert Campbell <rrc...@gmail.com> wrote:
>> Hello,
>>
>> Sometimes I have pretty long REPL sessions where I'm trying to flesh
>> out some ideas. When I close my instance of Clojure Box (Emacs based)
>> I lose all the definitions I had worked out over time. Is there any
>> way to dump namespace(s) to an image? It would be great to be able to
>> load up some workspace image and pick up where I left off.
>>
>> Rob
> >
>

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to