muszę dodać kilka metod do Clojure defprotocol
że piszę dla kilku identycznych komponentów SwingZwracanie wielu wartości z Clojure makro
(defprotocol view-methods
(ok-button-add-action-listener [this listener])
(ok-button-set-enabled [this enabled])
(ok-button-set-selected [this selected])
(cancel-button-add-action-listener [this listener])
(cancel-button-set-enabled [this enabled])
(cancel-button-set-selected [this selected])
(other-button-add-action-listener [this listener])
(other-button-set-enabled [this enabled])
(other-button-set-selected [this selected]))
Czy jest jakiś sposób, że mogę napisać makro, które zwraca wszystkie trzy z sygnatur metody (xxx-button-add-action-listener
, xxx-button-set-enabled
, xxx-button-set-selected
)?
(defprotocol view-methods
(add-methods ok)
(add-methods cancel)
(add-methods other))
To makro musi dodać trzy pozycje do rosnącej defprotocol
z każdym wywołaniu.
Czy można zwrócić makro `[email protected]
i rozwinąć "na miejscu"?
Odkrywam to patrząc na makra 'do-template' Stuarta Sierra (http://clojure.github.com/clojure/clojure.template-api.html). Eksperymentuję z nim, gdy mówimy :-). Dzięki. – Ralph