1.3.0 permalink Arrow_down_16x16

declare

clojure.core

  • (declare & names)
defs the supplied var names with no bindings, useful for making forward declarations.

2 Examples top

  • user=> (defn foo []
             (undefined-func))
    ; Evaluation aborted. Unable to resolve symbol: undefined-func in this context
    nil
    
    user=> (declare undefined-func)
    #'user/undefined-func
    
    user=> (defn foo []
             (undefined-func))
    #'user/foo
    
  • user=> (declare show)
    #'user/show
    user=> (defn welcome [user-name] (prn (show) user-name))
    #'user/welcome
    user=> (defn show [] (prn "welcome "))
    #'user/show
    user=> (welcome "lu4nx")
    "welcome "
    nil "lu4nx"
    nil
    user=> 
Log in to add / edit an example.

See Also top

Log in to add a see also.

Plus_12x12 Minus_12x12 Source clojure/core.clj:2665 top

(defmacro declare
  "defs the supplied var names with no bindings, useful for making forward declarations."
  {:added "1.0"}
  [& names] `(do ~@(map #(list 'def (vary-meta % assoc :declared true)) names)))
Vars in clojure.core/declare:
Used in 0 other vars

Comments top

No comments for declare. Log in to add a comment.