3

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.

user467257
  • 1,714
  • 1
  • 16
  • 19

1 Answers1

1

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.

tukan
  • 17,050
  • 1
  • 20
  • 48
  • Thanks for your response, I'm just giving it another week or so before I mark it as accepted in case there are other responses. I'm surprised there is no easier way to do this, within the gst context itself. Is exploring a namespace really not done within gst itself ? – user467257 Jan 28 '22 at 17:16
  • @user467257 the Smalltalk code is run at gst. I don't understand what do you mean by 'within gst itself'. – tukan Jan 29 '22 at 18:23
  • @user467257 Did you try it out? – tukan Feb 09 '22 at 08:20
  • By within gst itself, I was thinking single messages you could send to the namespace objects. Kind of like "Object selectors" to get a list of methods, ie selectors built into gst itself already. Seems crazy that people have to write their own code for doing such a bog standard task. – user467257 Feb 12 '22 at 23:00
  • @user467257 The reason here is that Smalltalk developers do not need it. For that purpose they use System Browser (they have overview of packages/classes/protocols/methods all the time. See more at http://onsmalltalk.com/on-the-smalltalk-browser. – tukan Feb 14 '22 at 07:42