You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/tutorials/pharo-basics/collections.md
+6Lines changed: 6 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,3 +1,9 @@
1
+
---
2
+
title: Collections
3
+
sidebar_position: 5
4
+
slug: /collections
5
+
---
6
+
1
7
# Collections
2
8
3
9
This guide introduces you to **collections** in Pharo - groups of objects used to organize and manipulate data. You will learn how to create and use arrays, ordered collections, sets, and dictionaries, understand what makes each type special, and explore how to iterate over them with messages like `do:`, `collect:`, `select:`, and others. These operations are essential for building models and handling data effectively in Cormas.
Copy file name to clipboardExpand all lines: docs/tutorials/pharo-basics/messages.md
+11-10Lines changed: 11 additions & 10 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,6 +1,7 @@
1
1
---
2
-
title: Understanding Messages in Pharo
3
-
sidebar_position: 4
2
+
title: Messages
3
+
sidebar_position: 6
4
+
slug: /pharo-messages
4
5
---
5
6
6
7
In Pharo (and therefore in **Cormas**), *everything is an object* - agents, cells, plots, and even numbers and strings. Objects **interact** by *sending messages* to each other. Messages are how we tell an object what to do.
@@ -14,7 +15,7 @@ plot burn.
14
15
Here we send the message `burn` to the object `plot`.\
15
16
If the object knows how to respond to `burn`, it performs an action - for example, it may change its color to red and mark itself as burned.
16
17
17
-
## 1. What is a Message?
18
+
## What is a Message?
18
19
19
20
A **message** in Pharo is similar to a "function call" in other languages, but it's more natural to read:
20
21
@@ -46,7 +47,7 @@ Here:
46
47
-`moveTo:` is the **message**
47
48
-`newPlot` is an **argument**
48
49
49
-
## 2. Everything Happens by Sending Messages
50
+
## Everything Happens by Sending Messages
50
51
51
52
Objects never access another object's data directly.\
52
53
They always **communicate by sending messages**.
@@ -62,7 +63,7 @@ This means that when you design a Cormas model, you define:
62
63
-**the messages your agents understand** (their behavior),
63
64
- and **the messages you send** to make them act or query information.
64
65
65
-
## 3. Messages vs. Methods
66
+
## Messages vs. Methods
66
67
67
68
It's important to understand that **messages** and **methods** are not the same thing.
68
69
@@ -84,7 +85,7 @@ In short:
84
85
-**Message**: what you send.
85
86
-**Method**: what the object does when it receives that message.
86
87
87
-
## 4. Messages Can Have Arguments
88
+
## Messages Can Have Arguments
88
89
89
90
Some messages require extra information, called *arguments*.
90
91
@@ -98,7 +99,7 @@ Here `biomass:`, `moveTo:` and `addTree:` are *keyword messages* that take argum
98
99
99
100
Notice the colon (`:`) - it indicates that the message expects a value.
100
101
101
-
## 5. Messages Return Values
102
+
## Messages Return Values
102
103
103
104
Each message returns a result, which can be stored or used in another message:
104
105
@@ -121,7 +122,7 @@ growBiomass
121
122
Then the message `cell growBiomass` will increase the biomass by 1 and return cell. You can imagine that there is an invisible `^ self` at the end of each method.
122
123
:::
123
124
124
-
## 6. Nested Messages
125
+
## Nested Messages
125
126
126
127
You can also *nest* messages to combine multiple requests in one expression:
127
128
@@ -134,7 +135,7 @@ This means:
134
135
1. Ask the forest for its largest tree.
135
136
2. Then ask that tree for its height.
136
137
137
-
## 7. Messages Can Be Chained
138
+
## Messages Can Be Chained
138
139
139
140
You can send several messages to the same object in sequence by using a semicolon (`;`):
140
141
@@ -146,7 +147,7 @@ This reads naturally: *"Increment, increment, then decrement the counter."*
146
147
147
148
This is a key idea in Pharo - code is readable and close to natural language.
148
149
149
-
## 8. Message Types
150
+
## Message Types
150
151
151
152
In Pharo, there are three kinds of messages. These are just different ways of writing instructions for objects, depending on how many arguments (extra pieces of information) they need.
Copy file name to clipboardExpand all lines: docs/tutorials/pharo-basics/pharo-environment.md
+11-2Lines changed: 11 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,3 +1,9 @@
1
+
---
2
+
title: Pharo Environment
3
+
sidebar_position: 4
4
+
slug: /pharo-environment
5
+
---
6
+
1
7
# Basics of Pharo Environment
2
8
3
9
In this short guide we will teach you how to use navigate the Pharo environment and use 4 main tools: Playground, Inspector, System Browser, and Debugger. We will also teach you how to search for methods and classes with Spotter and how to browse implementors and senders of different methods and classes.
@@ -51,7 +57,8 @@ The first tool that you will learn is called _"Playground"_. It allows us to exe
51
57
Copy the following two lines to your Playground and click on _"Do it all"_ button in the top-left corner.
@@ -67,7 +74,9 @@ You can also execute one specific line by placing your cursor on it, right click
67
74
Let's add some more lines, evaluate (execute) them and print the result. Don't worry if the variables are highlighted in red. This happens because they are not explicitly declared. But as soon as you execute your code in the Playground, it will automatically declare all varibles for you. Select the lines that you added, right-click and select _Print it_ from the menu. You can also use the shortcut _Ctrl+P_ or _Cmd+P_ on Mac.
Copy file name to clipboardExpand all lines: docs/tutorials/pharo-basics/pharo-playground.md
+6Lines changed: 6 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,3 +1,9 @@
1
+
---
2
+
title: Running Code in Playground
3
+
sidebar_position: 2
4
+
slug: /run-code-in-playground
5
+
---
6
+
1
7
# Running Code in Pharo Playground
2
8
3
9
Before starting, make sure you already have Pharo installed. If not, follow the Installing Pharo section from our [How to Install Cormas](/download) tutorial.
Copy file name to clipboardExpand all lines: docs/tutorials/pharo-basics/pharo-syntax.md
+7-1Lines changed: 7 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,8 +1,14 @@
1
+
---
2
+
title: Pharo Syntax
3
+
sidebar_position: 3
4
+
slug: /pharo-syntax
5
+
---
6
+
1
7
# Pharo Syntax in a Nutshell
2
8
3
9
Pharo is a live, object-oriented language. Everything is an object, and you send messages to objects to make them do things. This short guide covers only the essentials you need to read and write the code for Cormas models.
4
10
5
-
**We encourage you to follow this tutorial hands‑on:** type each example in a Playground and try evaluating, printing, and inspecting it yourself. If you are new to Playground, check out our tutorial on [Running code in Pharo Playground](pharo-playground).
11
+
**We encourage you to follow this tutorial hands‑on:** type each example in a Playground and try evaluating, printing, and inspecting it yourself. If you are new to Playground, check out our tutorial on [Running code in Pharo Playground](run-code-in-playground).
0 commit comments