Marc
Marc

Reputation: 596

How to look at image code in GNU Smalltalk?

how can I look at class / message code from within 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 :-)

Upvotes: 2

Views: 220

Answers (1)

Paolo Bonzini
Paolo Bonzini

Reputation: 1930

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>

Upvotes: 3

Related Questions