开发者

How to look at image code in GNU Smalltalk?

how can I look at class / message code from within开发者_如何学JAVA the GST command line interface? I only know the #inspect message, but this shows only a definition or summary of the object, not the code.

Thank you :-)


You can use the "methodSourceString" method, like

st>(Object >> #printNl) methodSourceString
'printNl [
        "Print a represention of the receiver on stdout, put a new line
         the Transcript (stdout the GUI is not active)"

        <category: ''printing''>
        Transcript showCr: self printString
    ]'

However, the string will be printed with double quotes, which can be inconvenient for non-trivial code.

It's often simpler to just use a text editor, because almost always classes are contained in a single file. You can query the file name from the REPL, too:

st> Object methodDictionary anyOne methodSourceCode file
<File /usr/share/smalltalk/kernel/Object.st>
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜