What are some uses of Clojure metadata?

后端 未结 4 1716
灰色年华
灰色年华 2020-12-14 15:55

How have you used metadata in your Clojure program?

I saw one example from Programming Clojure:

(defn shout [#^{:tag String} message] (.toUp         


        
4条回答
  •  伪装坚强ぢ
    2020-12-14 16:15

    For diversity some answer, which does not concentrate on interaction with the language itself:

    You can also eg. track the source of some data. Unchecked input is marked as :tainted. A validator might check things and then set the status to :clean. Code doing security relevant things might then barf on :tainted and only accept :cleaned input.

提交回复
热议问题