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: 05-messages-and-slots.md
+22-6Lines changed: 22 additions & 6 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -298,7 +298,9 @@ TestObject test
298
298
299
299
## Operator Messages
300
300
301
-
Operators are messages with special precedence rules:
301
+
Operators are messages with special precedence rules. Unlike many languages where operators are built-in syntax, in Io they're regular messages that follow configurable precedence levels. This means you can treat operators like any other method - you can override them, create new ones, or call them using regular message passing syntax.
302
+
303
+
The OperatorTable manages operator precedence, with levels from 0 (highest) to 13 (lowest). Standard arithmetic follows familiar rules: multiplication and division (level 3) bind tighter than addition and subtraction (level 4). Assignment operators like := and = have the lowest precedence (level 13), ensuring they capture everything to their right.
302
304
303
305
```io
304
306
// These are equivalent
@@ -321,6 +323,8 @@ Number @@ := method(n,
321
323
"hello" send("at", 1) println // e
322
324
```
323
325
326
+
This unified treatment of operators as messages enables powerful metaprogramming techniques. You can intercept arithmetic operations for logging, create domain-specific operators for mathematical or business logic, or even implement operator overloading for custom types - all using the same message passing mechanism that underlies the entire language.
// Direct calls are faster, but message objects enable metaprogramming
452
+
// Direct calls are ~3x faster, but message objects enable metaprogramming
447
453
```
448
454
449
455
## Common Patterns
450
456
457
+
Message passing and slot manipulation enable elegant implementations of common design patterns. These patterns leverage Io's dynamic nature to create flexible, maintainable code structures that would require significant boilerplate in more static languages.
458
+
451
459
### Property Access Pattern
452
460
461
+
This pattern demonstrates how to dynamically generate getters and setters using message construction. Instead of manually writing accessor methods for each property, we use Io's metaprogramming capabilities to create them on demand. The generated methods follow a naming convention where properties are stored with an underscore prefix internally, while the public interface uses clean method names.
The beauty of this approach is that it scales effortlessly - adding new properties requires just one line of code per property, and the accessor methods are created with consistent behavior and naming. This pattern is particularly useful when building data models or domain objects where property access needs to be controlled or monitored.
493
+
482
494
### Chain of Responsibility
483
495
496
+
The Chain of Responsibility pattern creates a pipeline of handlers where each handler decides whether to process a request or pass it to the next handler. In Io, this pattern is particularly clean because message passing naturally supports delegation. Each handler in the chain examines the request and either processes it or forwards it using simple message passing.
497
+
484
498
```io
485
499
Handler := Object clone
486
500
Handler next := nil
@@ -499,7 +513,7 @@ AuthHandler process := method(request,
499
513
"Authenticating..." println
500
514
)
501
515
502
-
LogHandler := Handler clone
516
+
LogHandler := Handler clone
503
517
LogHandler canHandle := method(request, true)
504
518
LogHandler process := method(request,
505
519
("Logging: " .. request type) println
@@ -520,6 +534,8 @@ auth handle(request)
520
534
// Logging: GET
521
535
```
522
536
537
+
This pattern is invaluable for building middleware systems, request processors, or event handling pipelines. The chain can be dynamically reconfigured at runtime by simply changing the `next` references, and new handler types can be added without modifying existing code. The pattern also naturally supports optional processing - handlers can choose to stop the chain or allow it to continue based on the request's characteristics.
538
+
523
539
## Debugging Messages
524
540
525
541
Understanding message flow is crucial for debugging:
Copy file name to clipboardExpand all lines: CLAUDE.md
+49-1Lines changed: 49 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -2,6 +2,7 @@
2
2
3
3
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
4
4
5
+
5
6
## Project Overview
6
7
7
8
This is a comprehensive book about the Io Programming Language, written in Markdown format with one file per chapter. The book targets experienced programmers and provides in-depth comparisons with mainstream languages like JavaScript, Python, Ruby, and Java.
@@ -66,4 +67,51 @@ Common Io patterns seen in examples:
66
67
- Everything is an object receiving messages
67
68
- Methods are defined as slots: `Object methodName := method(...)`
68
69
- Cloning for inheritance: `Child := Parent clone`
69
-
- Blocks for closures: `block(x, x * 2)`
70
+
- Blocks for closures: `block(x, x * 2)`
71
+
=======
72
+
## Repository Purpose
73
+
74
+
This is a comprehensive book about the Io programming language, written entirely in Markdown. The book targets experienced programmers as a second or third language resource, focusing on prototype-based object-oriented programming concepts with comparisons to mainstream languages (JavaScript, Python, Ruby, Java).
75
+
76
+
## Content Structure
77
+
78
+
The repository contains 19 numbered chapter files (00-preface.md through 18-conclusion.md) that form a complete technical book. Each chapter builds on previous concepts while maintaining standalone value. The `examples/` directory contains runnable Io code organized by chapter.
79
+
80
+
## Working with Content
81
+
82
+
### Running Examples
83
+
```bash
84
+
io examples/chapter-02/hello.io
85
+
```
86
+
Note: The Io interpreter may not be installed on all systems. Installation:
87
+
- macOS: `brew install io`
88
+
- Linux: Build from source at https://github.com/IoLanguage/io
89
+
- Windows: Use WSL or Docker
90
+
91
+
### Key Content Characteristics
92
+
93
+
1.**Technical Comparisons**: Examples frequently compare Io concepts to JavaScript, Python, Ruby, and Java equivalents
94
+
2.**Code Examples**: All code blocks are meant to be runnable in the Io REPL
4.**Progressive Complexity**: Early chapters introduce fundamentals, later chapters cover advanced topics like metaprogramming and concurrency
97
+
98
+
## Maintenance Guidelines
99
+
100
+
### When Adding Content
101
+
- Maintain consistent comparison style with other languages
102
+
- Include runnable code examples with expected outputs
103
+
- Place example files in appropriate `examples/chapter-XX/` directories
104
+
- Follow the established chapter numbering scheme
105
+
106
+
### When Reviewing Feedback
107
+
- The book has been reviewed by Steve Dekorte (Io's creator) - his feedback focused on adding outputs for benchmarks and expanding explanations for operator messages and common patterns
108
+
109
+
### Version Control
110
+
- The repository uses semantic versioning with tags (current: v1.1.0)
111
+
- Major content improvements warrant version bumps
112
+
- Include acknowledgments for technical reviewers in README.md
113
+
114
+
## Important Context
115
+
116
+
This book was generated by Claude (Opus 4.1) in collaboration with a human developer. The entire 400+ page book was created in a single conversation session, demonstrating AI-assisted technical writing capabilities. The content is released under CC0 1.0 Universal license, encouraging community contributions and corrections.
Copy file name to clipboardExpand all lines: README.md
+3-1Lines changed: 3 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -84,7 +84,9 @@ This collaboration between human creativity and AI capability demonstrates the p
84
84
85
85
## Acknowledgments
86
86
87
-
Thanks to Steve Dekorte for creating Io, and to the Io community for keeping this fascinating language alive.
87
+
Special thanks to Steve Dekorte, creator of the Io programming language, for reviewing this book and providing valuable feedback and insights that improved its accuracy and depth. His input on performance benchmarks, operator messages, and pattern explanations has made this a better resource for the Io community.
88
+
89
+
Thanks also to the broader Io community for keeping this fascinating language alive and continuing to explore its unique approach to object-oriented programming.
0 commit comments