- 論壇徽章:
- 0
|
本帖最后由 sjdy521 于 2012-08-27 16:38 編輯
發(fā)現(xiàn)一個(gè)現(xiàn)象:
use IO::Handle之后,類似STDOUT、STDERR之類的句柄就可以繼承IO::Handle,用oo的形式使用,比如:
STDOUT->autoflush(1);
我看了一下IO::Handle以及其他一些相關(guān)聯(lián)的模塊的源代碼,并沒有發(fā)現(xiàn)什么代碼產(chǎn)生了這種效果。
我的疑問是,perlobj里有提到:
When you call a method, the thing on the left side of the arrow is passed as the first argument to the method. That means when we call Critter->new() , the new() method receives the string "Critter" as its first argument. When we call $fred->speak() , the $fred variable is passed as the first argument to speak() .
按照這樣的理解,那么STDOUT->autoflush(1)就相當(dāng)于是STDOUT::autoflush(STDOUT,1);
但顯然事實(shí)上不是這樣的。
想了解下,具體是哪里的代碼產(chǎn)生這種效果,還是說,perl內(nèi)部針對文件句柄做了特殊的處理? |
|