These PNI (Programmable Network Interface) Magik commands are handy to have at your fingertips during an interactive Smallworld session. To get a handle on an object first, try something like:
MagikSF session example
MagikSF> bb << dbv[:mit_bay].an_element() $
mit_bay4444:(70511)
With a reference in hand, the commands below let you inspect, navigate, and debug Magik objects efficiently.
| # | Command | Description |
|---|---|---|
| 1 | setvars() | Has an optional print? argument. Sets useful and frequently used Smallworld Magik environment variables in the current session. |
| 2 | m() | Returns a method for an object. Can be used together with source_file to locate the method's source. |
| 3 | object.ap(str/symbol [OPT including_private? including_system?]) | Shows all methods defined on the object where the name matches the given string or symbol. Optional flags expose private and system methods. |
| 4 | view() | Opens a view of the object in the Smallworld environment for visual inspection. |
| 5 | pms() | Prints method source — displays the source code of a Magik method directly in the session. |
| 6 | colap() | Collapses or summarises a collection, useful for quickly reviewing collection contents in the MagikSF environment. |
| 7 | w() / p() / dp() | Write, print, and deep-print shortcuts for outputting object representations to the session transcript. |
| 8 | a_view.apn() | Returns or prints the application name associated with a given view object in the Smallworld session. |
| 9 | a_record_or_collection.df() | Displays the fields of a record or collection, giving a structured overview of its data in MagikSF. |
These commands are intended for use within the MagikSF interactive environment. They complement the Emacs extensions covered across the site's Core Features posts and screen-casts.
When working with Magik objects in a Smallworld session, the PNI commands serve as an essential bridge between the developer and the underlying GIS environment. These commands allow you to inspect object references, navigate collections, and debug method calls with precision. By obtaining a handle on an object through database views or collections, you can then apply commands that reveal its internal structure, including fields, methods, and symbols. This interactive workflow is particularly valuable when dealing with complex datasets or when tracing how information flows through the system. Understanding these commands transforms a standard debugging session into a productive exploration of your Smallworld environment.
The setvars() command is one of the most frequently used tools for configuring your Magik session. It establishes useful environment variables that streamline development work, making it easier to access commonly referenced objects and settings. When you invoke this command, it sets up variables that persist throughout your session, reducing the need for repetitive manual configuration. This is especially helpful when switching between different projects or databases, as it ensures consistent access to key resources. Developers working with large collections or complex object hierarchies find this command indispensable for maintaining an efficient workflow during extended debugging and development sessions.
Navigating collections and records in Smallworld requires a firm grasp of how objects relate to one another within the database. Using commands that inspect elements, fields, and keys, you can traverse from a top-level collection down to individual records and their associated methods. This hierarchical approach mirrors the structure of the underlying GIS data, where each object may contain nested collections or references to other objects. Understanding how to move through these relationships using PNI commands allows you to trace data lineage, identify caching behavior, and verify that the correct objects are being accessed during method execution.
Memory management and performance tuning are critical aspects of working with Smallworld Emacs, especially when handling large datasets. PNI commands that display caching statistics, object sizes, and memory usage help developers identify bottlenecks and optimize their code. By examining how objects are stored and retrieved, you can make informed decisions about when to clear caches or restructure your approach. This is particularly relevant when working with extensive collections or when performing repeated operations on the same dataset. A solid command of these debugging tools leads to more efficient sessions and better performing Magik applications overall.
The difference between methods, fields, and symbols in Magik becomes clear when you use PNI commands to inspect objects interactively. Methods define behavior, fields store data, and symbols provide named references within the environment. By querying an object for its defined methods or examining its field values, you gain insight into how the object was constructed and how it behaves at runtime. This inspection capability is invaluable for understanding third-party code, debugging unexpected behavior, or learning how established patterns work within your Smallworld system. The ability to switch between viewing source files, method signatures, and runtime values makes these commands a cornerstone of effective Magik development.