Emacs Extensions for
GE Smallworld Magik Development
Screen-casts, tutorials, and productivity tools for Magik programmers who use Emacs. From tab-mode and code folding to the Magik Debugger and object inspector — explore features built by a developer, for developers.
Learn MoreNine screen-casts published between November 2010 and January 2011 — covering everything from ECB mode to the Tree Item GUI control. Read the story behind the project →
Get in Touch
Magik object inspection with Emacs' Inspector
In a Smallworld application, the most useful answer is often the one held by the running system. A slot may contain a specialisation rather than the class named in source, a collection may contain fewer records than expected, and a value fetched from another object may change after a transaction boundary. Reading Magik source can reveal intent, but runtime inspection shows the actual object graph the application is working with.
Magik's Object Inspection brings that runtime view into Emacs, where developers already navigate code, breakpoints, and evaluation buffers. Instead of switching repeatedly between an IDE and a general-purpose editor, a developer can select an object, reveal its slots, and follow references while keeping the relevant source nearby. The result is less context switching and a tighter connection between an observed value and the code that produced it.
This guide follows a practical inspection path: connect to a suitable Magik session, identify the object being studied, read its state, walk collections, and compare the result with a debugger frame or a method's expectations. It also treats inspection as an active diagnostic activity rather than a passive viewer, because some apparently convenient actions can still mutate data.
Why runtime state matters
Magik code frequently describes behaviour through objects whose contents are established elsewhere. A constructor may calculate a property, a transaction may load it from a database, and a collection may be filtered by information supplied by the user. The declared class tells you what the code expects, while the live object reveals what is actually present.
Object identity also matters. Two records can have equivalent visible fields while remaining distinct objects, and references held by another slot do not automatically become copies. When an inspector displays a reference, following it can expose ownership relationships that are difficult to reconstruct from source alone.
Runtime inspection is particularly valuable with Smallworld systems because models often contain many specialised classes and persistent collections. A method may appear to receive a generic collection even though its live value contains a constrained subset. Seeing the runtime class, slot names, and reference targets turns an abstract type error into a concrete investigation.
Connecting to a Magik session
Start with a session that can safely expose the relevant state. A development database, a recent snapshot, or a controlled test environment is usually more appropriate than an active production transaction. The important distinction is not simply whether the process is called production, but whether inspection or evaluation could expose, change, or lock sensitive data.
Use the connection controls supported by the installed Magik Emacs components, and confirm that the process, database, and Smallworld version match the code being investigated. The Magik Emacs development tools guidance provides the appropriate starting point for the supported workflow and associated configuration details.
Once connected, open the inspector from a live Magik context rather than attempting to infer an object from source text. An object created only inside a method may not exist outside that call, so pausing execution or arranging a controlled evaluation can be necessary. Keep the target session and the Emacs buffer visibly associated to reduce the chance of inspecting the wrong environment.
Reading an object's state
The most useful inspector views separate an object's identity from its contents. The object header generally provides the runtime class and a stable way to distinguish the instance. Below it, a slot table can show slot names, declared classes, and current values. This combination helps identify a familiar problem: the slot exists, but its value has been replaced by an unexpected specialisation.
Expand slots incrementally and follow references deliberately. A short reference path is easier to interpret than a large graph dumped at once, particularly when objects contain parent, child, or transactional links. Labels or notes can preserve the route taken through the graph, making it easier to return to the same object after examining a nested value.
Methods appear separately from stored state. Their presence confirms that an operation is available on the live class, but it does not prove that invoking the method will be safe. A getter may be read-only, while another method could update a collection, create a transaction, or trigger external processing. Prefer direct inspection of slots when that answers the question, and treat method invocation as a deliberate debugging action.
Walking collections and references
Collections deserve separate attention because their size, ordering, and membership often determine whether a feature behaves correctly. Begin with the collection's count, key access, and a small sample of its entries. Look for missing keys, unexpected specialisations, and values that appear in the wrong order. If the collection is filtered or generated dynamically, record those conditions while inspecting it.
Large collections should be explored in bounded chunks. Loading an unrestricted result into an Emacs buffer can make the editor slow and obscure the original defect. Use filtering, paging, or incremental expansion where the available tools permit it. Keep the query or access path alongside the sample so another developer can reproduce the same view later.
This evidence-first approach also aligns with disciplined testing. Teams that verify a browser-facing Smallworld workflow through a browser test workflow commonly keep inputs traceable, check boundary conditions, and preserve enough context to reproduce a failure. The technologies serve different layers, but the same principle applies: inspect a representative value, verify its relationship to the source, and avoid treating a convenient sample as the complete collection.
When following references between collections, watch for circular relationships and duplicate paths. A self-referencing object or a shared child can make a graph look larger than it is. Expand the branches connected to the original question first, then return to peripheral values if they still appear relevant.
Inspection during debugging
A debugger frame gives the inspector a precise starting point. Pause at a method boundary, identify the receiver and parameters, and compare their runtime values with the method's assumptions. Slot inspection can reveal that a parameter is a subtype with overridden behaviour, while a collection inspection can show that its count or membership differs from the expected result.
Use evaluation for small, controlled questions such as retrieving a slot or computing a read-only expression. Preserve the method context while doing so, because a value obtained elsewhere may not represent the receiver involved in the failure. If evaluation changes state, include that fact in the debugging notes so later analysis does not mistake the modified value for the original condition.
Transactions add another layer to the evidence. Record whether the inspected object was created, loaded, or modified within the current transaction, and take care before committing changes made during debugging. A rollback can invalidate assumptions about references held earlier, so reconnect or re-inspect the affected objects after the transaction state changes. For production support, capture the smallest safe diagnostic sequence and avoid copying customer data into local notes.
Building a routine that travels well
Australian Smallworld teams commonly work across Melbourne, Sydney, Brisbane, Adelaide, and Perth. Mining, utilities, water, and transport operators are prominent users in the market, and these sectors often operate large or long-lived datasets. Such projects benefit from a consistent inspection routine because an issue may need to move between an application team, a consulting specialist, and an operational support group without losing context.
Time zones and handover practices shape that movement. Support and consulting work commonly follows Australian Eastern Standard Time or Australian Central Time, while operational systems may run continuously. An “arvo” handover can be effective when it includes the live object path, transaction state, relevant slot values, and the exact Magik version. Australian English conventions such as organisation, behaviour, and authorised also keep technical notes consistent with local business documentation.
A useful routine is straightforward: confirm the environment, capture the runtime class, record the inspected path, limit collection expansion, note any invoked methods, and separate observations from hypotheses. Screenshots can help, but copied values and method signatures are often easier to search. Store artefacts according to the organisation's confidentiality rules, especially when objects contain personal, commercial, or infrastructure-sensitive information.
Begin with a non-production object and follow it through the live inspector before introducing more elaborate techniques. Review the Magik Emacs configuration, practise reading slots and bounded collection samples, and keep a concise record of the connection details required by your team.
HydePark Consulting can help Australian Magik teams configure Emacs, refine their debugging workflow, and document inspection practices for ongoing support. Put the method into use with a controlled example, then apply it to the next real Smallworld issue with evidence that another developer can reproduce.
Core Features
Tab Mode & ECB
Quick tab switching and Emacs Code Browsing mode for navigating Magik codebases efficiently.
Magik Smeller
Code analysis tool that helps identify potential issues in Magik source files.
Code Folding
Hide/Show mode for collapsing and expanding Magik code blocks to focus on what matters.
Visual Bookmarks
Quick visual bookmarks for jumping between key locations in your Smallworld session buffers.
Object Inspector
Inspect Magik objects and display them in an Emacs Deep Print buffer for detailed examination.
Magik Debugger
Set breakpoints and monitor slots and variables directly from within Emacs.
Development Tools
Direct links between Emacs and the Smallworld Development Tools application, including Click Monitor.
Screen-casts & Tutorials
Screen-cast 1: Tab Mode, ECB & More
Covers tab-mode, ECB, Magik Smeller, code folding, visual bookmarks, pragma toggling, moving code, external editor, and MS Explorer.
Screen-cast 5: Object Inspection & Deep Print
Inspect a Magik object, prompt for an expression evaluated within a Smallworld session, and display results in a Deep Print buffer.
Screen-cast 7: Magik Debugger
Useful tools for application developers: Object Inspector and Magik Debugger with breakpoints and slot/variable monitoring.
Screen-cast 9: Tree Item GUI Control
Tree Item is a GUI control providing extensive facilities for displaying lists with rows, columns, trees, and in-place editing.