2

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 :-)

Marc
  • 585
  • 5
  • 19

1 Answers1

3

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>
Paolo Bonzini
  • 1,900
  • 15
  • 25