Clojureã®ä¸ç観
ããã°ãæ¸ãã®ã¯ä¹
ã
ã§ãã
京é½ã§å°ããªä¼ç¤¾ããã£ã¦ãã¦ãèªç¤¾éçºã§Clojureã¨ClojureScriptã使ç¨ãç¶ãã¦ãæ¦ãï¼å¹´ããã使ãç¶ãã¦ãã¾ãããã®éç¨ã§ãClojureèªä½ã«ãå°ãããªããã½ã¼ã¹ã¬ãã«ã®è²¢ç®ãã§ããããã¦ããªã¼ãã³ã½ã¼ã¹ããã¸ã§ã¯ãã¨ãã¦ãé¢ç½ãã£ãã®ã§ããããã¨ãã¨ãªãã¸ã§ã¯ãæåè¨èªã°ãããã£ã¦ããã¨ãããããClojureã¨ãããã¾ã£ãããªãã¸ã§ã¯ãæåè¨èªã§ã¯ãªãè¨èªã«é£ã³è¾¼ãã çµé¨ãèãããã¨ãªããããããã°ã«ã¹ããã¯ããã¨ãä½ãä»ã®äººã«ãå½¹ç«ã¤ãã¨ããããã¨æã£ã¦ãããã°ã«æ¸ããã¨ã«ãã¾ããã
ãã®ã¨ãããã£ã¨ãèªç¤¾ã®ä»äºã¨ã¯å¥ã«ãæµæ¯å¯¿ã«ãã æ ªå¼ä¼ç¤¾ã¦ã¼ã¶ãã¼ã¹ ããã®ãä»äºã«åå ãã¦ãã¾ãï¼ç§ãæ³äººãä½ãåãããªã®ã§ãããï¼ãï¼å¹´ãããã«ãªãã¾ãï¼ããã¡ãã®æ¹ã§ãClojureãã·ã¹ãã è¨è¨ã®è©±ï¼ãã¬ã¼ã³ãªã©ï¼ãªã©ãä½åº¦ãããã¦ããã£ãããããåå¹´ãããã¯ãã¦ã¼ã¶ãã¼ã¹ããã§ãClojureãå®éçºã¸æå
¥ãå§ãããããéçºæ¯æ´ã¨ãã¦æºããã¾ããï¼Clojureã®ã·ã¹ãã ã¯ç¾å¨ãéæéçºä¸ã§ããã¶ã£ã¡ããClojureéçºè
åéä¸ã§ãï¼ã
ã¦ã¼ã¶ãã¼ã¹ããã®ã·ã¹ãã ã«ããã¦ããClojureã§go-blockãå®ç¾ãã並è¡å¦çã©ã¤ãã©ãª core.async ã使ã£ã¦ä¸¦è¡å¦çã·ã¹ãã ãä½ã£ãããã¦ããã®ã§ãããã§å¾ããããClojure+core.asyncã§ã®ä¸¦è¡ããã°ã©ãã³ã°ã®ç¥è¦ãªãããæ¸ãã¦ããããããããããã°ãããä¸å®æã§Clojureã«ã¤ãã¦ããã°ãæ¸ãã¦ããã¤ããã§ããæ°åãç¶ãã°ã
ä»åã¯ãClojureã使ããã¨ã«ãã£ã¦ãClojureãåæã¨ãã¦ããä¸ç観ããèªåã空æ°ã®ããã«åæã¨ãã¦ãããã®ã¨ç°ãªã£ã¦ãã¨ããã¨ãã¦ãClojureã«ãããæ½è±¡ãã¼ã¿æ§é ã¨ãããªã¢ãã£ãºã ã®ä»çµã¿ã«ã¤ãã¦æ¸ãã¦ã¿ã¾ãã
å°ãªãæ½è±¡ãã¼ã¿æ§é ã¨ãããããã®é¢æ°
Clojureã§ã¯ããªãã¸ã§ã¯ãæåè¨èªã¨ç°ãªããé¢æ°ã¨ãã¼ã¿ã¯ããããå®å ¨ã«åé¢ãã¦ãã¾ãããªãã¸ã§ã¯ãæåè¨èªã§ãªãã®ã ãããããªã®ã ããã£ã¦ãã¨ã¯çãç¥ã£ã¦ã¯ããã®ã ãããã©ããé¢æ°ï¼ã¡ã½ããï¼ããã¼ã¿ã¨çµã³ã¤ãã¦èãã¦ãã¾ãã¨ããã®ã¯ããªãã¸ã§ã¯ãæåè¨èªã«æ £ãã人ã®çã¿ãããªãã®ã¨ãã¦ãæã¿ã¤ãã¦ããã¨ããã®ããã«ãæãã¾ãã
Javaçãªãã¯ã©ã¹ãã¼ã¹ã®ãªãã¸ã§ã¯ãæåè¨èªã®å ´åãã¡ã½ãããä½ãã«ã¯ã¯ã©ã¹ãå®ç¾©ãã¦ããã«ã¡ã½ããã足ããããªã®ã§ãã¡ã½ããï¼é¢æ°ï¼ã¯ãããã¼ã¿ã®éã¾ãï¼ãªãã¸ã§ã¯ãï¼ãæä½ããå°ç¨ã®é¢æ°ã¨ãã¦å®ç¾©ããã¡ã§ããããããããã®ãªãã¸ã§ã¯ããæä½ããããã®ã¡ã½ããããªã®ã ããå½ããåã§ãã
ä¸æ¹ããã¼ã¿ã¨é¢æ°ãåé¢ãã¦ããå ´åã¯ãé¢æ°ãç¹å®ã®ã¯ã©ã¹ããªãã¸ã§ã¯ãã«çµã³ã¤ããæå³ã¯ãªãã§ãããéã«ãããé¢æ°ã®ããã«å°ç¨ã®ã¯ã©ã¹ãä½ãæå³ããªãã極端ã«èããã°ããã¹ã¦ã®é¢æ°ãå ±éã®ãã¼ã¿æ§é ãå¦çããããã«ããæ¹ããå¤æ§ãªé¢æ°ãæè»ã«æ´»ç¨ã§ããããã«ãªãã
ã¨ãããããããªãã¸ã§ã¯ãã«é¢æ°ãçµã³ã¤ãã¦ããããããããã®ã¡ã½ããã¯ãã®ãªãã¸ã§ã¯ãæ§é ãå¦çããããã®ãã®ã ï¼ä»ã®ç¨éã«ã¯ä½¿ããªãï¼ãã¨ãã風ã«å°éåã§ãã¦ãããã§ãã£ã¦ããã¼ã¿ã¨é¢æ°ãåå¥ã®ãã®ã¨æ±ã以ä¸ã¯ãããã®é¢æ°ã¯ãã®ãªãã¸ã§ã¯ãã ããæ±ããã¨ããåæãç½®ããªãã®ã§ãï¼å½ããåã§ãï¼ããããªãã¸ã§ã¯ãã¨å¥ã®ãªãã¸ã§ã¯ãããåã§ãã£ããã¯ã©ã¹ã§ãã£ãããç°ãªã£ãã¨ãã¦ããé¢æ°ã¯ããã®ãªãã¸ã§ã¯ãããé¢æ°ã®å¦çã§ããæ§é ã§ããã°ãå¦çã§ããã¹ããªãã§ããé¢æ°ã¨ãªãã¸ã§ã¯ããç¬ç«ãã¦ããã¨ããã®ã¯ããããæå³ã§ããã¹ãã§ããã§ããã°ããã¹ã¦ã®é¢æ°ã«ã¾ããããããªãå ±éã®æ±ç¨ãã¼ã¿æ§é ããã£ã¦ããã¹ã¦ã®ãã¼ã¿ã¯ãã®æ±ç¨æ§ãæ ä¿ãã¦ãã»ããããã
ãã¡ãããã縦ãã¨ã横ãã¨ããæ å ±ãæã£ããã¼ã¿ã使ã£ã¦ãé¢ç©ããæ±ããé¢æ°ã¯ããã¼ã¿ãã縦ãã¨ã横ãã¨ããæ å ±ãæã£ã¦ãããã¨ãæ±ããã ãããã©ããRectangleã ã¨ãTableã ã¨ãã®ç¹å®ã®ã¯ã©ã¹ã«ãã¤ã¬ã¯ãã«çµã³ã¤ãã¹ãã§ã¯ãªãã
ãã®èª²é¡ã«ã¯ããããªã¢ããã¼ãããããã§ããããï¼Structural Typeã¨ãï¼ï¼ãClojureã®å ´åã¯ãè¨èªå
¨ä½ãåæã¨ããæ½è±¡ãã¼ã¿æ§é ãããã¾ãããªã¹ãç¶ã®ãã®ã¯Seqã¨å¼ã°ããæ½è±¡ãã¼ã¿ï¼ä»£è¡¨ä¾ã¯é
åï¼ã¨ãã¦ããããç¶ã®ãã®ã¯Associativeã¨å¼ã°ããæ½è±¡ãã¼ã¿ï¼ä»£è¡¨ä¾ã¯ãããï¼ã¨ãã¦æ±ãã¾ããäºå®ä¸ã»ã¨ãã©ã®ãã¼ã¿ããã®ï¼ã¤ã§è¡¨ç¾ããã¦ãã¦ãå¤ãã®é¢æ°ããå¼æ°ã¨ãã¦Seqã¾ãã¯Associativeãåãåãï¼ãããã¯å
é¨ã§èªåã§å¤æããï¼ããSeqã¾ãã¯Associativeãåºåãã¾ãã
èªåãé¢æ°ãæ¸ãã¨ãã«ããç¬èªã®ãã¼ã¿åã§ã¯ãªããSeqãAssociativeãåæã¨ãã¦æ¸ãã®ããªã¹ã¹ã¡ã§ãããããããã¨ã§ãé¢æ°ã¯ä»ã®é¢æ°ã®ã¤ã³ãããã«ãªããã¾ãããä»ã®é¢æ°ã®åºåãå
¥åã§ãã¾ãï¼åé¢æ°ã®å
¥åã¨åºåãåãæ½è±¡ãã¼ã¿æ§é ã ããï¼ã
ãã®æ½è±¡åã¯å¾¹åºãã¦ãã¦ãä¾ãã°ãClojureã«ã¯defrecordããããããã使ãã°ã ã¬ã³ã¼ãã¨å¼ã°ãããç¬èªã®åã¨ãã£ã¼ã«ããæã£ããã¼ã¿æ§é ãä½ãåºããã¨ãã§ãã¾ããããã«ãã¬ã³ã¼ãã«å¯¾ãã¦ãããã³ã«ãå®è£ ãããã¨ã§ãJavaã«ãããã¤ã³ã¿ã¼ãã§ã¼ã¹ãå®è£ ãããããªæãã®ã³ã¼ããæ¸ããã¨ãã§ãã¾ãã
(defrecord User [name age mail-address] IAuthenticate (auth [this param] (something-great param)))
ããã ãè¦ãã¨ãã¾ãã§ã¯ã©ã¹ãå®ç¾©ã§ãããã®ããã«æãã¾ããã¨ããããã®ã¬ã³ã¼ãã¯ãã¹ã¦Associativeã§ãããã¾ããã¤ã¾ãããã¹ã¦ã®ã¬ã³ã¼ãã¯Associativeãå¦çããé¢æ°ã«æ¸¡ããã¨ãå¯è½ã§ããã¾ãããã®ãã¼ã¿ã使ãå´ã¯ããã¼ã¿ãå®ã¯ã¬ã³ã¼ãã§ããã¨ãããã¨ãæ°ã«ããå¿ è¦ãï¼ååã¨ãã¦ã¯ï¼ããã¾ãããããã¯Associativeã ã¨ãããã¨ãããããã°ãããå®éãããã©ã¤ãã©ãªã®ããé¢æ°ã®æ»ãå¤ãããããã¼ã¸ã§ã³ã¾ã§ãããï¼å ¸åçãªAssociativeãã¼ã¿ï¼ã§ãã£ããã®ãã次ã®ãã¼ã¸ã§ã³ããã¬ã³ã¼ãã«å¤ãã£ã¦ããã¨ãã¦ããç¹ã«å½±é¿ã¯ãªãã¯ãã§ãã
;; ããã (def data1 {:name "t_yano"}) ;; ã¬ã³ã¼ã (defrecord User [name]) (def data2 (->User "t_yano")) ;; ã©ã¡ããAssociativeãªã®ã§ã:nameé¢æ°ã§:nameã®å¤ãåãåºãã (:name data1) ;=> "t_yano" (:name data2) ;=> "t_yano"
ãã®ãããªæ§é ã¯Javaã®ã¤ã³ã¿ãã§ã¼ã¹ã®ãããªãã®ãããã°ãä»ã§ãå®ç¾ã§ããã¨æãã ãããã©ãï¼å®éãAssociative㨠Seqã¯ãJavaã®ã¤ã³ã¿ãã§ã¼ã¹ã¨ãã¦å®ç¾©ããã¦ãã¾ãï¼ãããã¯ã注ææ·±ãè¨è¨ããã°ãã®ã©ã¤ãã©ãªå ã§ã¯ããã§ãããã¨ãã話ã§ãã£ã¦ãè¨èªã¨ãã¦æ¨æºã®æ½è±¡ãã¼ã¿ãå®ç¾©ãã¦ããã¹ã¦ãããã«éç´ãããããã¨ããä¸çã§ã¯ãä»ã®è¨èªæ©è½ãããã¹ã¦ããã®ãããªä»çµã¿ãæ¯æ´ããããã«ä½ããã¦ãã¾ããè¨èªã¨ãã¦ã®åæã§ããããã§ãããã¨ãã°ãJavaã§ãã¹ã¦ã®ãã¼ã¿ãMapã§ä½ã£ã¦ããè¦ããã ãã§å©ç¹ãªã©ãªãã§ããããããããåæã§è¨èªãä½ããã¦ããªãããã§ãã
ãã®ãããªæ½è±¡ãã¼ã¿æ§é ããããããããé¢æ°ã¨ãã¼ã¿ãåé¢ã§ããããã§ããé¢æ°ã¯å ±éã®æ½è±¡ãã¼ã¿æ§é ããè¦ã¦ããªããããããå®éã®ã¯ã©ã¹ã¨ã¯çµã³ã¤ãå¿ è¦ããªãã®ã§ãã
ã10種é¡ã®ãã¼ã¿æ§é ã«ãããããæ±ã10åã®é¢æ°ãããããããã²ã¨ã¤ã®ãã¼ã¿æ§é ãæ±ã100åã®é¢æ°ãããæ¹ãè¯ã (It is better to have 100 functions operate on one data structure than to have 10 functions operate on 10 data structures)ãã¨ããè¨èããã¾ãã
ãã¼ã¿æ§é ã«ããããé¢æ°ããã
ä¸ã¤ã®ãã¼ã¿æ§é ãæ±ã100åã®é¢æ°
ãã®ä¸æã«è³æã®äººãå対ã®äººãããã§ãããããClojureã¯æ確ã«ãã²ã¨ã¤ã®ãã¼ã¿æ§é ãæ±ã100åã®é¢æ°ãããããããªä¸çã®æ¹ããããã¨ããåæã§ä½ããã¦ããã®ã§ãã
ã¢ãããã¯ãªå¤æ ï¼ããªã¢ãã£ãºã ï¼
ãã¦ãå°ãªãæ½è±¡ãã¼ã¿æ§é ã¨ããããã®é¢æ°ãã¨ããçå±ã¯ããã£ãã¨ãã¦ããªãã¸ã§ã¯ãã«çµã³ã¤ãã¦ãªãé¢æ°ã«ããããå¤æ
ï¼ããªã¢ãã£ãºã ï¼ã¯ã©ããªããã§ãããããç¨éãã¨ã«ç°ãªãé¢æ°ãç¨æããã°ããã£ã¦ãã¨ãªãã§ããããã
ãã¡ãããå®éã®éçºã«ã¯å¤æ
ã¯å¿
è¦ã§ããå¤æ
ãªãã§ãMySQLã¨PostgreSQLã§ç°ãªãåããããconnecté¢æ°ãã©ããã£ã¦å®ç¾©ããããããã§ãããã mysql-connect 㨠psql-connect ã使ãåãããã¨ãããããªãã¨ãé¿ãããã¨ããã§ãã
ã§ããããClojureã«ãå¤æ é¢æ°ãå®ç¾©ããä»çµã¿ãããã¾ããdefrecordã«ãã£ã¦ç¬èªã®åãå®ç¾©ããå¼æ°ã®åã«é¢æ°å®è£ ãç´ã¥ãããã¨ãã§ãã¾ãããããã¯defmulti / defmethod ã使ã£ã¦ãã«ãã¡ã½ãããå®ç¾©ãããã¨ã§ããã¼ã¿ã®å¤ï¼å®éã«ã¯å¼ã®çµæã§ããï¼ã«ãã£ã¦é¢æ°å®è£ ãåãæ¿ãããã¨ãã§ãã¾ããä¾ãã°ãå¼æ°ã¨ãã¦æ¸¡ãããDBæ¥ç¶å®ç¾©ã®ãã©ã¤ãåã«åºã¥ãã¦ãconnecté¢æ°ã®å®è£ ãåãæ¿ãããã¨ãã£ã使ãæ¹ãã§ãã¾ãã
é¢æ°ï¼ã¡ã½ããï¼ãå¤æ ã«ããä»çµã¿ã«ã¤ãã¦ã¯JavaScriptã¿ãããªã¢ããã¼ãããå¼æ°ã®åã®çµã¿åããã«ãã£ã¦åãæ¿ãããã«ããã«ãã£ã¹ãããããã£ãããä¸ã®ä¸ã«ã¯ãã§ã«è²ã ãªãã®ãããã®ã§ãClojureã®å¤æ ã®ä»çµã¿ãããã»ã©ç¬èªã®ãã®ã ã¨ããããã§ã¯ãªãã§ããããå¼·ãã¦ããã°ãClojureã®ãã«ãã¡ã½ããã§è¿½å ããé¢æ°ã¯ãåçã«ç´ä»ãã追å ãããåãé¢ãããã§ããã®ãé¢ç½ãã¨ããã§ãããããèªä½ããä»ã®è¨èªï¼ç¹ã«åçãªè¨èªï¼ã§ã§ããªãã¨ãããã®ã§ãããã¾ããã
å¤æ
ãå®ç¾ããä»çµã¿ããããClojureã®ãå¤æ
ã«å¯¾ããæ
度ã¨ããããèãæ¹ã®æ¹ããé¢ç½ãã®ã§ã¯ãªããã¨æãã¾ãã
Clojureã§ã¯ãClojureã®å¤æ
ã®ä»çµã¿ã®ãã¨ãAd-hoc Polymophismã¨å¼ãã§ã¾ãããã®ã¯ã¼ãèªä½ã¯ï¼Clojureãããåã«ï¼çµæ§æãããããããªã®ã§ãæ°ããæ¦å¿µã§ã¯ãªãã®ã§ãããããããã«ããå®éã®éçºã¸ã®å½±é¿ãçµæ§é¢ç½ãã
å¤æ
ï¼ããªã¢ãã£ãºã ï¼ã¨ããã®ã¯ããªãã¸ã§ã¯ãæåã®ä¸çã§ã¯ãããããªãã¸ã§ã¯ãã¨å¥ã®ãªãã¸ã§ã¯ããåãã¡ã½ãããæã£ã¦ãããã©ãéãåä½ããããã¨ããéã®è¦ç¹ãããããããªãã¸ã§ã¯ãã¨å¥ã®ãªãã¸ã§ã¯ãã¯ãå®éã«ã¯éãåä½ãããã ããããåãã¡ãã»ã¼ã¸ã«åå¿ããã®ã§åããªãã¸ã§ã¯ãã¨ã¿ãªãããã¨ãã£ãæèã§ä½¿ãããæãããã¾ãããªãã¸ã§ã¯ãæåã®ã¡ãã»ã¼ã¸ã»ããã·ã³ã°ã®èãæ¹ã«ã®ã£ã¨ãã°ããããªãã¸ã§ã¯ãAã¨Bã«åãã¡ãã»ã¼ã¸ãéã£ã¦ããå®éã«åãå¦çï¼ã¡ã½ããï¼ã¯å¥ãããããªããã ãåãã¡ãã»ã¼ã¸ã«å¿çã§ããã®ã ããã両è
ã¯åããªãã¸ã§ã¯ãã¨ã¿ãªãããã¨ããããã§ãã
ã¤ã¾ãããã¤ããªãã¸ã§ã¯ãã¨ã¨ãã«ããªãã¸ã§ã¯ãå士ã®é¢ä¿ï¼åãã¡ãã»ã¼ã¸ã«å¿çããã®ã ããå®è³ªåãã¨ãã¦æ±ãããã¨ãããµãã¿ã¤ãã§ãããã¨ãï¼ã¨ãã¦èªãããå¾åãããã¾ãã
ä¸æ¹ãClojureã«ã¨ã£ã¦å¤æ ã¨ã¯ãé¢æ°ãã£ã¹ãããã®è©±ã¨æãããã¦ãã¾ããé¢æ°ã¯ãã¼ã¿ï¼ãªãã¸ã§ã¯ãï¼ã¨ãã¤ã¬ã¯ãã«ã¯çµã³ã¤ãã¦ãªãã®ã§ãå¤æ ã®èª¬æã¨ãã¦ããªãã¸ã§ã¯ããã¯ã©ã¹ã¨çµã³ã¤ãã¦èªããã¨ã¯ã§ãã¾ãããããé¢æ°ãå¼ãã æã«ãå®éã«å®è¡ãããé¢æ°å®è£ ã¯ã©ããªã®ãï¼ã¨ãããã£ã¹ãããã®åé¡ã«éããªãã®ã§ãã
ãã£ã¹ãããã®åé¡ãã¨ãããã¨ã¯ãå®éã®ã¨ãããé¢æ°ã使ãå´ã«ã¨ã£ã¦ã¯ãå®ã¯é¢æ°ãå¤æ
ã§ãããã©ããã¨ãããã¨ã¯ã使ç¨ä¸ãã¾ãé¢ä¿ããªãã¨ãããã¨ã§ããé¢æ°ã¯é¢æ°ã§ãã£ã¦ããããå¤æ
ã§ãããã¯ã¦ã¼ã¶ã¼ã«ã¯é¢ä¿ããªãã
ä¾ãã°ããã ã®é¢æ°ã¯ããã®é¢æ°ãå¼ã¶ã¨é¢æ°æ¬ä½ã«ç´æ¥ãã£ã¹ãããããã¾ãããããé¢æ°ãã£ã¹ãããã®ã²ã¨ã¤ã®å½¢ã§ãã
ããããã«ãã¡ã½ããã§ããã°ãå¼æ°ã®å¤ï¼å®éã«ã¯å¤ãè¨ç®ããçµæï¼ã«ãã£ã¦å®éã«ä½¿ãé¢æ°å®è£
ãæ¢ãããå¾ã«å¼ã³åºããã¾ããdefrecord / defprotocol ã«ãããã£ã¹ãããã§ã¯ãå¼æ°ã®åã«ãã£ã¦ãã£ã¹ãããããã¾ããããã¯å®è£
ã®è©³ç´°ã§ãã£ã¦ãé¢æ°ã使ãå´ã«ã¨ã£ã¦ã¯ãé¢æ°ãå¼ã¹ã°é¢æ°ãå®è¡ãããã°ããã®ã§ãã
ããããå¥ã®äººã®ä½ã£ãé¢æ°å®è£ ããå é¨ã§ããã°ã©ã ã¨ãã¦ifæã使ã£ã¦å¥ã®é¢æ°ã«å¦çããã£ã¹ããããã¦ããã¨ãã¦ãã使ãå´ã«ã¨ã£ã¦ã¯é¢ä¿ãªãã®ã¨åãã§ããifæã§ã®åå²ã¯ãæåã®é¢æ°ãã£ã¹ãããã¨èããã°ããã«ãã¡ã½ããã¨åããé¢æ°ãã£ã¹ãããã ã¨è¨ãã¾ããã
使ãå´ã«ã¨ã£ã¦ã¯ãããã«ãããã ã®é¢æ°ã«è¦ããã®ã§ããããClojureã«ããã¦ãé¢æ°ã¯ãã¨ã§ãã¤ã§ãå¤æ ã«åãæ¿ããããåå¨ãªããã§ãã
éå»ã«ç§ãDBæä½ã©ã¤ãã©ãªã®ä¸ã¤ Korma ã«éã£ããããã§ã¯ãååãã¯ãªã¼ãããå¦çãMySQLã¨PostgreSQLã¨ã§åããå¿ è¦ã«å¯¾å¿ãã¾ããã対å¿ã¯ç°¡åã§ãã¯ãªã¼ãããé¢æ°ããã«ãã¡ã½ããã«å¤æ´ããå¼æ°ã¨ãã¦æ¸¡ã£ã¦ããDBæ¥ç¶å®ç¾©ã®æ¥ç¶URLã使ã£ã¦é©åãªã¯ãªã¼ãå¦çã«ãã£ã¹ãããããã ãã§ããé¢æ°ããã«ãã¡ã½ããã«å¤ãã£ãããã§ãããé¢æ°ãå¼ã³åºãå´ããè¦ãã¨ããã¯ããã ã®é¢æ°ã«è¦ãã¾ãã®ã§ãä»ã®é¨åã«ã¯ã¾ã£ããå½±é¿ãã¾ããã
ã¤ã¾ããã³ã¼ããæ¸ãã¦ããæã«ãããé¢æ°ãå¤æ ã«ãããã©ããã¨ããã®ã¯å¾ããèãã¦ã大ä¸å¤«ãªä»çµã¿ãªããã§ãããã¡ãããä½ã£ã¦ã段éã§ãè¨è¨ã¨ãã¦ãããã®é¢æ°ã¯å¤ããæ¡å¼µã§ããããã«ãããããããã«ãã¡ã½ããã«ãã¦ããããã¨ããããã¯ã¦ã¼ã¶ã¼å©ä¾¿æ§ãèãã¦ãããã³ã«ãå®ç¾©ãã¦ããããã¨ãããã¨ã¯ããã¾ãããããã§ãªãã¨ãããå¾ãããã«ãã¡ã½ããããããã³ã«é¢æ°åãããã¨ããçµæ§ç°¡åã«è¡ããã®ã§ãã
ã ããAd-hocï¼å ´å½ããçãªï¼ããªã¢ãã£ãºã ã¨å¼ã¶ããã§ãããã¡ãã注æãã¹ããã¨ã¯ãã£ã¦ã対象ã®å¦çãé¢æ°ã«åé¢ããã¦ãªããã°ãå¾ã§å¤æ é¢æ°åãããã¨ãã§ãã¾ãããããã§ããã°é¢æ°ã¯ç´°ããåãã¦ãããæ¹ããå¾ãã対å¦ããããã¨æãã¾ãããã®ãããªæ³¨æç¹ããã¯ãªã¢ãã¦ããã°ãæè»ã«å¾ããã³ã¼ãå¤æ´å¯è½ã ãã¨ããã®ããClojureã®å©ç¹ã®ä¸ã¤ã§ãã
ä»ã®æåãç¡çããæã¡è¾¼ã¾ãªãã®å¤§äº
ããã°ã©ãã³ã°è¨èªã«ã¯ãè¨èªãã¨ã«æåã¨ãããã大äºã«ãã¦ããèãæ¹ããããã®ã§ããClojureã«ã¯Clojureã®å¤§äºã«ãã¦ãããã®ããã£ã¦ãè¨èªä»æ§èªä½ãããã®å¤§äºã«ãã¦ãããã®ãåæã«è¨è¨ããã¦ããã¯ãã§ããä¸ã«ç´¹ä»ãããã®ããClojureã¨ããè¨èªã«æå³çã«çµã¿è¾¼ã¾ããä»æ§ãªè¨³ã§ãã
ä»ã®è¨èªããæ°ããè¨èªã«ç§»ã£ã¦ããã¨ãæåã¯ãä»ã¾ã§é¦´æãã§ããè¨èªã®æåã¨ãæ°ããè¨èªã®ããæ¹ã¨ããã¾ã£ããç°ãªã£ã¦ãããã¨ã«æ··ä¹±ãã¦ãèªåã®é¦´æãã§ããæåã¨åãã«ãããã¨ãã¦ãã¾ããã¡ã§ããããããè¨èªä»æ§ã¨ãã®è¨èªã®æåã¯å¼·ãã¤ãªãã£ã¦ããã®ãªã®ã§ãæåãç¡è¦ãã¦å¥ã®æåã§æ¸ããã¨ãã¦ãè¦ããã ãã§ãã
ãã®ããã«ã¯ããã¯ãããã®è¨èªã大äºã«ãã¦ãããã®ã¯ãªããªã®ããã©ãããæå³ã§ãã©ããããã¨ãå®ç¾ãããã¦ããããè¨èªãã¶ã¤ã³ã«ãªã£ã¦ããã®ãããç¥ãã®ã大äºã ã¨æãã®ã§ããæå³ããããã°ã馴æããªãã£ããã®ã«ãæ¥ã«ããªãã»ã©ããããããã¨ããã¨ç´å¾æãå¾ããããã®ã§ããæ½è±¡ãã¼ã¿æ§é ãå¤æ ã®ä»çµã¿ãªãããããã®ãããªä¾ã®ä¸ã¤ã§ãã
Clojureã¯Javaã¿ãããªåãã¼ã¹ã®ãªãã¸ã§ã¯ãæåè¨èªã¨ã¯ãããªãéãè¨èªãªã®ã§ãããä¸è¦ãããã£ã¦Javaã®ã¤ã³ã¿ã¼ãã§ã¼ã¹ã¨åãããã¨ããããã£ã¦Lombokã§@Valueã§ã¯ã©ã¹å®ç¾©ãããããªãã®ï¼ãã¨ãæãã¦ãã¾ãæ©è½ããã£ãããã¾ããããããã¡ããããããã¯ã¤ã³ã¼ã«ã§ã¯ãªãããæå³ãã¦ããã¨ãç°ãªã£ã¦ããã¨ãããã¾ãã
ä»ã®è¨èªãã移ã£ã¦ããæã«ã¯ãããªãã§ããããä»çµã¿ã«ãªã£ã¦ããã®ãï¼ãã®èæ¯ã¯ãªããªã®ãï¼ããææ¡ããã®ãã¨ã¦ã大äºã ã¨æãã¾ããæå³ããããã£ã¦ãã¾ãã°ãã¨ã¦ãç°¡æ½ã§æ¸ããããè¨èªã§ãããã
æ½è±¡ãã¼ã¿æ§é ãAd-hocå¤æ 以å¤ã«ããClojureã«ã¯ãã·ã³ãã«ã§æ§é åããããè¨èªãä½ãããã«ãããããªã¢ã¤ãã¢ãåãè¾¼ã¾ãã¦ãã¦é¢ç½ãã®ã§ãä»å¾ããç解ã§ããç¯å²ã§æ¸ãã¦ããããã¨ããã§ãã