Clojure

Reloading a multimethod declaration strips off the metadata

Details

  • Type: Defect Defect
  • Status: Closed Closed
  • Resolution: Completed
  • Affects Version/s: None
  • Fix Version/s: Release 1.2
  • Component/s: None
  • Labels:
    None

Description

With commit 1b8d50, running past a defmulti twice (e.g., reloading),
causes the metadata to get squashed:

(defmulti add
"Add item to the accumulator acc. The exact meaning of adding an
an item depends on the type of the accumulator.")

(defmulti add
"Add item to the accumulator acc. The exact meaning of adding an
an item depends on the type of the accumulator.")

(doc add)

yields =>

-------------------------
user/add
nil
nil

To standard out. I assume that this is because of the def on line
1191:

`(let v# (def ~mm-name)
(when-not (and (.hasRoot v#) (instance? clojure.lang.MultiFn
(deref v#)))
(def ~(with-meta mm-name m)
(new clojure.lang.MultiFn ~(name mm-name) ~dispatch-fn
~default ~hierarchy)))))))

This is mucking up the autodoc stuff.

Activity

Hide
Assembla Importer added a comment -

tomfaulhaber said: [file:a24DeetD4r34ureJe5dVir]: A patch that addresses the specific problem

Show
Assembla Importer added a comment - tomfaulhaber said: [file:a24DeetD4r34ureJe5dVir]: A patch that addresses the specific problem
Hide
Assembla Importer added a comment -

tomfaulhaber said: I've made a patch for this exact issue, but I'm not sure it's sufficient for the following reasons:

1) With the new mechanism created in 1b8d50 it is impossible to change a multimethod definition once it's been set up, so you can't modifiy the dispatch function and reload for instance (without doing a "def" in between to reset it).

2) If you use declare ahead of the defmulti it still strips off the metadata. Declare currently expands to (basically) def which has caused problems with metadata and reloading in other places as well. Declare should probably also be modified to preserve metadata as well.

Show
Assembla Importer added a comment - tomfaulhaber said: I've made a patch for this exact issue, but I'm not sure it's sufficient for the following reasons: 1) With the new mechanism created in 1b8d50 it is impossible to change a multimethod definition once it's been set up, so you can't modifiy the dispatch function and reload for instance (without doing a "def" in between to reset it). 2) If you use declare ahead of the defmulti it still strips off the metadata. Declare currently expands to (basically) def which has caused problems with metadata and reloading in other places as well. Declare should probably also be modified to preserve metadata as well.
Hide
Assembla Importer added a comment -

tomfaulhaber said: Ticket #330 (and the associated patch) addresses concern #2 above (declare also stripping metadata).

Show
Assembla Importer added a comment - tomfaulhaber said: Ticket #330 (and the associated patch) addresses concern #2 above (declare also stripping metadata).
Hide
Assembla Importer added a comment -

tomfaulhaber said: I confirmed that the fix to ticket #330 fixed the problem shown in the test case here as well.

I will mark this fixed, as that does fix the immediate problem.

The inability to modify the dispatch function remains. Rich, go ahead and reopen the bug if that concerns you.

Show
Assembla Importer added a comment - tomfaulhaber said: I confirmed that the fix to ticket #330 fixed the problem shown in the test case here as well. I will mark this fixed, as that does fix the immediate problem. The inability to modify the dispatch function remains. Rich, go ahead and reopen the bug if that concerns you.

People

  • Assignee:
    Unassigned
    Reporter:
    Anonymous
Vote (0)
Watch (0)

Dates

  • Created:
    Updated:
    Resolved: