Scalaã®traitã¯mixinãï¼
Rubyã®mixin(ã¢ã¸ã¥ã¼ã«)ãSqueakã®traitãScalaã®traitããããã«ã¤ãã¦ï¼
Q1: ã¡ã½ããã®å®è£ ãæã¦ãï¼
ã¯ããã¯ããã¯ã
Javaã®ã¯ã©ã¹ã¯ãã¯ãããã¤ã³ã¿ã¼ãã§ã¤ã¹ã¯ããããããC++ã¨Pythonã®ã¯ã©ã¹ã¯ãã¯ãã
Q2: ã¯ã©ã¹ããããè¤æ°åç¶æ¿ã§ããï¼
ã¯ããã¯ããã¯ã
Javaã®ã¯ã©ã¹ã¯ããããããã¤ã³ã¿ã¼ãã§ã¤ã¹ã¯ãã¯ãããC++ã¨Pythonã®ã¯ã©ã¹ã¯ãã¯ãã
Q3: ã¤ã³ã¹ã¿ã³ã¹ãä½ããï¼
ããããã¯ããããã
Q4: è¤æ°åç¶æ¿ããéã«ååãè¡çªãã¾ãããã©ããªãï¼
ããã£ã¨ä¸æ¸ããã¨ã©ã¼(*)ãã¨ã©ã¼
(*) Squeakã¯ã¯ã©ã¹å®ç¾©æã«ã¯ä¾å¤ãæãããè¡çªããã¡ã½ããããè¡çªããæ¨ã®ä¾å¤ãæããã¡ã½ãããã«ç½®ãæãããã¦ã¼ã¶ãè¡çªã«æ°ã¥ãã®ã¯ãã¯ã©ã¹ãã©ã¦ã¶ã§ã¡ã½ããã確èªããæãããã®ã¡ã½ãããå¼ãã æã«ãªãã
Q5: ç¶æ¿ãã¹ã«åå ããï¼
ããï¼ï¼ï¼ãããªããããï¼ï¼ï¼
ç¶æ¿ãã¹ã«åå ãã¦ãããã©ããã®æ¤è¨¼ã®ä»æ¹ããããã°ã©ãã³ã°è¨èªã®ã¦ã¼ã¶ã«ã©ãããå½±é¿ãããããã®ãããã¤ãã¤ãããããããªãã
Q6: ãããç¶æ¿ããã¯ã©ã¹ãç¹å®ã®ã¡ã½ãããæã¤ãã¨ãåã§å¼·å¶ã§ããï¼(Scalaã®self type annotation)
ããããããããã¯ã
Q7: ããã¯ã©ã¹ãããã¨å¥ã®ã¯ã©ã¹ã¨ãç¶æ¿ãã¦ããå ´åã«ã親ã¯ã©ã¹ã¨ããã¨ã®éã§ååãè¡çªãããã©ããªãï¼
ããã®å®ç¾©ã§ä¸æ¸ããããã®å®ç¾©ã§ä¸æ¸ããã¨ã©ã¼
ã¾ã¨ã
Q1 Y, Y, Y Q2 Y, Y, Y Q3 N, Y, N Q4 O, E, E Q5 Y, N, Y Q6 N, N, Y Q7 O, O, E
ã¾ããè¦ããã«ã3ã¤ããããå¥ç©ãã ããid:sumimããã®ä¸»å¼µ(Scalaã®ãã¬ã¤ãã¯å®ã¯ãã¬ã¤ããããªããã ã®ãã¯ã¹ã¤ã³)ã¯Q5ã«é¢ãã¦Scalaã®traitã¯mixinã¿ãããªãã®ã¨ãããã¨ã ããid:kmizushimaããã®ä¸»å¼µã¯Q4ã¨ãQ6ã®ãã¨ãèããã¨mixinã¨ã¯éãã ãã¨ãããã¨ã ãããå人çã«ã¯Q3ã§Squeakããã¯ãããªç¹ã«ã®ã§ãã¨ããã
ã½ã¼ã¹ã³ã¼ã: https://github.com/nishio/learn_language/tree/master/trait
æ°ãåãããC++ã¨ãPythonã¨ãã追å ãããã