{"id":1789,"date":"2017-05-18T03:20:38","date_gmt":"2017-05-17T18:20:38","guid":{"rendered":"https:\/\/blog.ymyzk.com\/?p=1789"},"modified":"2017-05-18T16:40:56","modified_gmt":"2017-05-18T07:40:56","slug":"ocaml-unused-variable","status":"publish","type":"post","link":"https:\/\/blog.ymyzk.com\/2017\/05\/ocaml-unused-variable\/","title":{"rendered":"OCaml \u306e\u672a\u4f7f\u7528\u5909\u6570\u306e\u8b66\u544a\u306b\u3064\u3044\u3066"},"content":{"rendered":"

OCaml \u306b\u304a\u3044\u3066\uff0c\u4ee5\u4e0b\u306e\u3088\u3046\u306a\u5834\u5408\u306f\u672a\u4f7f\u7528\u5909\u6570\u306e\u8b66\u544a\u304c\u51fa\u307e\u3059\u304c\uff0c<\/p>\n

$ ocaml\r\n        OCaml version 4.04.0\r\n\r\n# let x = 1 in 1;;\r\nWarning 26: unused variable x.\r\n- : int = 1<\/code><\/pre>\n

\u6b21\u306e\u3088\u3046\u306a\u5834\u5408\u306f\u672a\u4f7f\u7528\u5909\u6570\u306e\u8b66\u544a\u304c\u51fa\u307e\u305b\u3093\uff0e<\/p>\n

$ ocaml\r\n        OCaml version 4.04.0\r\n\r\n# let f x = 1;;\r\nval f : 'a -> int = <fun><\/code><\/pre>\n

\u3053\u306e\u9055\u3044\u304c\u6c17\u306b\u306a\u3063\u305f\u306e\u3067\u8abf\u3079\u3066\u307f\u307e\u3057\u305f\uff0e<\/p>\n

<\/p>\n

OCaml \u306e\u8b66\u544a\u306b\u3064\u3044\u3066\u6700\u3082\u8a73\u3057\u304f\u66f8\u304b\u308c\u3066\u3044\u308b\u306e\u306f ocamlc(1) \u306e man page<\/a> \u306e\u3088\u3046\u3067\u3059\uff0eOCaml \u3067\u306f\u8b66\u544a\u306e\u7a2e\u985e\u3054\u3068\u306b\u756a\u53f7\u304c\u3064\u3044\u3066\u304a\u308a, OCaml 4.04.0 \u306b\u306f\u4e00\u90e8\u6b20\u756a\u306f\u3042\u308a\u307e\u3059\u304c 1 \u304b\u3089 61 \u307e\u3067\u3042\u308a\u307e\u3059\uff0e\u672a\u4f7f\u7528\u5909\u6570\u306b\u3064\u3044\u3066\u306e\u8b66\u544a\u306f\uff0c\u4ee5\u4e0b\u306e2\u7a2e\u985e\u3067\u3059\uff0e<\/p>\n

26 Suspicious unused variable: unused variable that is bound
\nwith let or as, and doesn’t start with an underscore (_) charac-
\nter.<\/p>\n

27 Innocuous unused variable: unused variable that is not
\nbound with let nor as, and doesn’t start with an underscore (_)
\ncharacter.<\/p>\n

ocamlc(1)<\/a><\/cite><\/p><\/blockquote>\n

-w \u30aa\u30d7\u30b7\u30e7\u30f3\u3067\u6709\u52b9\u306b\u3059\u308b\u8b66\u544a\u3092\u6307\u5b9a\u3067\u304d\uff0c\u30c7\u30d5\u30a9\u30eb\u30c8\u3067\u306f -w +a-4-6-7-9-27-29-32..39-41-42-44-45-48-50-60<\/code> \u304c\u6307\u5b9a\u3055\u308c\u3066\u3044\u307e\u3059\uff0e+a<\/code> \u3067\u3042\u308b\u3059\u3079\u3066\u306e\u8b66\u544a\u3092\u6709\u52b9\u5316\u3057\uff0c-num<\/code> \u3067\u3042\u308b\u756a\u53f7\u306e\u8b66\u544a\u3092\u7121\u52b9\u5316\u3057\u3066\u3044\u307e\u3059\uff0e(\u305d\u306e\u4ed6\u306b\u3082\u3044\u308d\u3044\u308d\u306a\u6307\u5b9a\u65b9\u6cd5\u304c\u3042\u308a\u307e\u3059\u304c\uff0cman page \u3092\u53c2\u7167\u3057\u3066\u4e0b\u3055\u3044\uff0e) \u672a\u4f7f\u7528\u5909\u6570\u306b\u3064\u3044\u3066\u306e\u8b66\u544a\u306b\u3064\u3044\u3066\u306f\uff0c26 \u306e\u307f\u304c\u6709\u52b9\u5316\u3055\u308c\u3066\u3044\u308b\u305f\u3081\uff0c27 \u3082\u6709\u52b9\u5316\u3059\u308b\u3068\u5192\u982d\u306e\u3088\u3046\u306a\u4f8b\u3067\u3082\u8b66\u544a\u3092\u51fa\u3059\u3053\u3068\u304c\u51fa\u6765\u307e\u3059\uff0e<\/p>\n

$ ocaml\r\n        OCaml version 4.04.0\r\n\r\n# let f x = 1;;\r\nWarning 27: unused variable x.\r\nval f : 'a -> int = <fun><\/code><\/pre>\n

\u4e0a\u306e\u4f8b\u306f\u4eba\u5de5\u7684\u3067\u3059\u304c\uff0c\u4ee5\u4e0b\u306e\u3088\u3046\u306a\u3082\u3046\u5c11\u3057\u6c17\u3065\u304d\u306b\u304f\u3044\u3088\u3046\u306a\u3082\u306e\u3067\u3082\u8b66\u544a\u304c\u51fa\u308b\u3088\u3046\u306b\u306a\u308b\u306e\u3067\uff0c27 \u306f\u57fa\u672c\u7684\u306b\u6709\u52b9\u5316\u3057\u3066\u304a\u304f\u3068\u826f\u3044\u8b66\u544a\u3060\u3068\u601d\u3044\u307e\u3059\uff0e<\/p>\n

# List.fold_left (fun m -> fun n -> m + m);;\r\nWarning 27: unused variable n.\r\n- : int -> '_a list -> int = <fun><\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"

OCaml \u306b\u304a\u3044\u3066\uff0c\u4ee5\u4e0b\u306e\u3088\u3046\u306a\u5834\u5408\u306f\u672a\u4f7f\u7528\u5909\u6570\u306e\u8b66\u544a\u304c\u51fa\u307e\u3059\u304c\uff0c $ ocaml OCaml version 4.04.0 # let x = 1 in 1;; Warning 26: unused variable […]<\/p>\n","protected":false},"author":2,"featured_media":1794,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[26],"tags":[88],"_links":{"self":[{"href":"https:\/\/blog.ymyzk.com\/wp-json\/wp\/v2\/posts\/1789"}],"collection":[{"href":"https:\/\/blog.ymyzk.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.ymyzk.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.ymyzk.com\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.ymyzk.com\/wp-json\/wp\/v2\/comments?post=1789"}],"version-history":[{"count":4,"href":"https:\/\/blog.ymyzk.com\/wp-json\/wp\/v2\/posts\/1789\/revisions"}],"predecessor-version":[{"id":1793,"href":"https:\/\/blog.ymyzk.com\/wp-json\/wp\/v2\/posts\/1789\/revisions\/1793"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/blog.ymyzk.com\/wp-json\/wp\/v2\/media\/1794"}],"wp:attachment":[{"href":"https:\/\/blog.ymyzk.com\/wp-json\/wp\/v2\/media?parent=1789"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.ymyzk.com\/wp-json\/wp\/v2\/categories?post=1789"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.ymyzk.com\/wp-json\/wp\/v2\/tags?post=1789"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}