GemStone compatibility and development rules
All GT / GemStone code related operations should be performed on the live system using available tools (via the gtoolkit mcp server). git repositories should only be inspected / modified for shell scripts, topaz files or if specifically required.
All code is managed from within GT, any time a method is to be added or modified it should be done in GT and then updated in GemStone.
When modifying an existing method, check what it's protocol is, and unless it is 'as yet unclassified', DO NOT CHANGE THE PROTOCOL unless explicitly requested. This is particularly important for EXTENSION METHODS (where the protocol begins with a '*'). If you feel the need to change a protocol, stop and ask for confirmation
GemStone will commit the value of class and class-instance variables to the database. In general, this is not what is desired when porting code. In particular, class methods that answer a default, instance or uniqueInstance that store the instance in a class or class-instance variable should not store the value in the database. In these cases they should be added to SessionTemps with a name based on the class and accessor method, e.g. SessionTemps current at: #Class_selector_value ifAbsentPut: [ self new ].
There are many differences between GT and GemStone classes. Where GemStone requires an alternate implementation there are a few different potential solutions:
Adding a pragma with the <gsCode: gemstoneSourceString> pragma to the method will result in the gemstoneSourceString being used when the code is exported (see GtGemStoneGtCodeExporter
). An example is GtGemStoneTopazExporterExamples>>#gsCodeExampleMethod
.
NOTE: the gemstoneSourceString replaces everything below the pragma, meaning that the method signature doesn't need to be included, so in the example linked above the method signature and comment will be part of the generated GemStone code.
Note that the method's class must be included in the GtGemStoneGtCodeExporter>>#gsCodeClasses
list.
This can only be used in methods owned by feenkcom, i.e. CompiledMethod>>#hasFeenkRepositoryAvailable
answers true.
Extension methods can be added to GemStone with the code managed by GT by using GtGemStoneExtensionMethod
and GtGemStoneExtensionMethods
, see their class comments for further information.
This is generally preferred for Pharo methods that aren't managed by GT, e.g. Collection>>#intersection:
, and where the class otherwise isn't exported.
For methods that are largely the same in both GT and GemStone, Object>>#gtDo:gemstoneDo:
provides a way to have a small section of code be platform specific. An example use is in BlockClosureOnProcessExamples>>#getCallStack
.
When choosing between gsCode: and gtDo:gemstoneDo:, gsCode: is normally used when the method body is significantly different between GT and GemStone.
The following are a number of commonly encountered issues when getting GT code working in GemStone:
In GemStone, new, and its variants, don't call initialize.
Unless the GT version also defines new, or one of its variants, this will be resolved by adding a GtGemStoneExtensionMethod
method.
When debugging code being ported from GT to GemStone, if an existing method appears to not initialise instance variables, first check that the initialize method is being called prior to adding lazy initialisation to the ported method.
Navigating the class / method structure in GemStone is often much slower than in GT. Instead of requesting classes directly, lookups such as superclasses, subclasses, references, etc. should be made through the ClassOrganizer gtDefault instance.
The following list of methods that exist in GT, but are missing in GemStone and have equivalents in GemStone that are considered close enough for now. The list is formatted originalMethod -> replacementMethod: 'canPerform: aSelector' -> 'canUnderstand: aSelector' 'includesSubstring: aString' -> 'findPattern: { aString} startingAt: 1' 'includesSubstring: aString caseSensitive: false' -> 'findPatternNoCase: { aString } startingAt: 1'
When responding, GT method references are normally styled using the gtMethod: attribute. As GemStone methods often don't exist in the GT image, they should be styled using the normal code styling, i.e. back-ticks (`).