Search code examples
smalltalkpharo

How to understand this syntax construction in Pharo Smalltalk?


What does this syntax { ...: ...} mean? Example:

Class {
    #name : #TypExamples,
    #superclass : #Object,
    #category : #'Typer-Core-Examples-OLD'
}

{ #category : #accessing }
TypExamples >> recursion [
    | x |
    x := [ x ].
    ^ x
]

Is it a dictionary? I did not find such syntax in the Pharo Cheat Sheet. Is it legal for Playground and for methods body?


Solution

  • This is not Pharo syntax at all. It is "tonel" format, which is a code storing format. It is composed by chunks of STON (Smalltalk Object Notation, sort of JSON for Pharo) and code itself.

    And no, this is not "direct-to-playground" code, you need to use a tool to inject it (like Iceberg or Monticello).