smalltalkgnu-smalltalk

How to explore a namespace in gnu smalltalk


When using gnu smalltalk (without emacs integration) what commands/process does one use to explore the contents of a namespace ? For example, I want to find out how to use the contents of NetClients but if I just type

NetClients examine

I get an enormous amount of text scrolling past. Is it even possible to pass this into something like less so I can scroll back and forth through it ? Ideally I'd like to see a list of classes for example, along with their general description. Then for those classes I'd like to be able to see only their selectors.


Solution

  • If you want to search in the text output when sending messages, I would simply redirect the output to file.

    I would do the following:

    1. gst -a > netclients_namespace.txt
    2. type: NetClients examine
    3. check the netclients_nemespace.txt file where you will have the output of the messages. You can check it while the gst is still running
    4. If you are done just break it via ctrl+c

    Explaining:

    -a --smalltalk-args           Pass the remaining arguments to Smalltalk.
    

    Allows you to type in the messages and get the output redirected.

    Edit: (missed that question about classes at Namespace)

    That being said I'm not big fan of GNU Smalltalk as I don't like the CLI only interface in supports. I think the biggest advantage of Smalltalk from the beginning was its GUI support and if you need it you can use CLI if the Smalltalk environment you are using is supporting it like Smalltalk/X-jv.

    Usually inspect is the keyword used in Smalltalk instead of examine. Which will give you an internal view of an object.

    If you want to list classes at Namespace you could do it the following way:

    NetClients do: [ :namespaceDetail | 
        namespaceDetail isClass ifTrue: [ namespaceDetail printNl ]
    ].
    

    To print description of the classes you could to it like this:

    NetClients do: [ :namespaceDetail | 
        namespaceDetail isClass ifTrue: [
            '--->' printNl. namespaceDetail printNl. '<---' printNl. 
            namespaceDetail comment printNl
        ]
    ].
    

    In similar fashion you would get selectors.