ã¾ããPP ã®ã¢ã¸ã¥ã¼ã«ã void context ã§ãããã¨ãå¤å®ã«ã¤ãã£ã¦ãã±ã¼ã¹ã£ã¦ã»ã¨ãã©ãªããã§ããã©ãã
ãªãã§ããããèªåããããªã®æ¸ããªããã
ã¡ãªã¿ã«Class-MOPã§ã¯lib/Class/MOP/Method/Wrapped.pmã§voidã³ã³ããã¹ãé¢é£ã®å¦çãæ¸ããã¦ã¾ãããï¼åã®ã¨ã³ããªã®æå¾ã«æ¸ããã®ã¨åãç¨éï¼
ã©ããç³»ã¯voidã³ã³ããã¹ãã®é¢åãè¦ãªãã¨ãããªãã§ããããã
ããã¾ã§ã®æµãã ã¨ãããããvoidã³ã³ããã¹ãã£ã¦ä½ã«ä½¿ããããã£ã¦æã£ã¦ã人ãããããªã®ã§ä¾ãæãã¦ããã¾ãã
voidã³ã³ããã¹ãã®å®ç¨ä¾ã¨ãã¦ã¯ãä¾ãã°Pod::Simple::RTFï¼Perl5.9.3以éãªãã³ã¢ã¢ã¸ã¥ã¼ã«ï¼ã«ãã£ã¦ãlib/Pod/Simple/RTF.pmã®sub rtf_escã§åºç¾ãã¾ããã³ã¡ã³ããä»ãã¦ã¦å¦çãå¹³æãªã®ã§ãä½ãã£ã¦ããã¯è¦ãã°åããã¨æãã¾ãã
ããã¾ãè¡åãè¯ãã¨ã¯æããªãã§ããã©ããã®ä¸æ¹ã§ãæ¸ãæã®æå³ï¼æèï¼ã³ã³ããã¹ãï¼ã«å¿ãã¦ãããªã«ãã¦ãããæããPerlããããªãã¨ãæã£ãããã¾ãã
ã¾ãå°ãéã使ãæ¹ã®ä¾ã§Data::Dumpããã£ã¦ãData::Dump::dumpã¯
dump($foo); # STDERRã«printãã $x = dump($foo); # printããªãã§å¤ã$xã«è¿ã
ã¨ãã2種é¡ã®æ¸ãæ¹ãã§ãããã§ããããããå®ç¾ããããã«voidã³ã³ããã¹ãã«ããæ¯ãåããè¡ããã¦ãã¾ããï¼lib/Data/Dump.pmã®sub dumpï¼
æ®éã«èããã¨ããããã®ã¯voidã³ã³ããã¹ãã«é ¼ããã«
print STDERR dump($foo); $x = dump($foo);
ã®ããã«å¼ã³åºãå´ã§æ確ã«å¦çãæ¸ããããªã¤ã³ã¿ã¼ãã§ã¤ã¹ã«ãã¾ãããããããã¯çæç¨ã®ã¡ã½ããã¨åºåç¨ã®ã¡ã½ãããå¥ã«ãã¦
# sub dumpãprintããªãããã«ãã¦ããã¦ã package Data::Dump; sub p { print STDERR dump(@_); }
ã¨ããï¼ã ããèªåã§ã¯voidã³ã³ããã¹ãã使ã£ãå¦çããã¾ãæ¸ããäºãªãããçãæ¸ããªããã ã¨æãã¾ãï¼
ã¾ããã ããããããã°ç¨éã§ä½¿ãã ãããã¨ããData::Dumpã®å½¹å²ãèããã¨ããdump($foo)ãã£ã¦ç°¡æ½ã«æ¸ããæ¹ãè¯ãã¨æã£ããããªãã§ããããã
ããã¾ã§æ¸ãã¦ã¦ãã³ã³ããã¹ããæ¡å¼µããã¢ã¸ã¥ã¼ã«ãã£ããã ãã©ä½ã ã£ãããªããã£ã¦æ°ã«ãªã£ãã®ã§èª¿ã¹ã¦ã¿ãããDamianå çã®Contextual::Returnã§ãããããã¥ã¡ã³ãèªãã ãã§ãã¯ã¯ã¯ã¯ãã¾ãããã ã¬ãã¥ã¼è¦ããããããªã®ä½¿ãã®ãå§ãããªããï¼ãã£ã¦æ¸ãã¦ãã£ããèªåãããæãã¾ãï¼ç¬ï¼
ã¤ãã§ã«ã¬ãã¥ã¼ã®ä¸ã§è¦ã¤ããããâhttp://www.perlfoundation.org/perl5/index.cgi?pbp_module_recommendation_commentary åãã¦è¦ã¾ãããä½ãè¯ããããåç©«åç©«ã