RandomB
RandomB

Reputation: 3737

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?

Upvotes: 4

Views: 250

Answers (2)

Stephan Eggermont
Stephan Eggermont

Reputation: 15907

And if you want to read a bit more about the Tonel file format, there is a specification. It was developed to enable better git support. Smalltalk has used different version control systems before, including the Monticello dvcs which made it slow in embracing git.

Upvotes: 3

EstebanLM
EstebanLM

Reputation: 4357

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).

Upvotes: 8

Related Questions