Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 443
RandomB Avatar asked Dec 18 '22 12:12

RandomB


1 Answers

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

like image 105
EstebanLM Avatar answered Feb 20 '23 12:02

EstebanLM