【发布时间】:2011-06-06 03:28:42
【问题描述】:
在以下代码中,我收到了关于反射的警告:
(ns com.example
(:import
[org.apache.commons.cli CommandLine Option Options PosixParser]))
(def *help-option* "help")
(def *host-option* "db-host")
(def *options*
(doto (Options.)
(.addOption "?" *help-option* false "Show this usage information")
(.addOption "h" *host-option* true "Name of the database host")))
(let
[^CommandLine command-line (.. (PosixParser.)
(parse *options* (into-array String args)))
db-host (.getOptionValue command-line "h")] ; WARNING HERE ON .getOptionValue
; Do stuff with db-host
)
我在command-line 上有一个类型提示。为什么会出现警告?
我在 OS X 10.6.6(Apple VM)上使用 Clojure 1.2。
我假设我确实不会在(.addOption ...) 上收到警告,因为编译器知道(Options.) 是org.apache.commons.cli.Options)。
【问题讨论】:
标签: clojure type-hinting