Search the IDE pages
Every section of the IDE pages, with its text. Type to narrow the list; every word must match.
| Page | Section | Text |
|---|---|---|
| The EK9 IDE | The EK9 IDE | The EK9 IDE is a desktop editor for EK9 with the compiler built in. You start it with ek9 -ide. ek9 -ide The EK9 IDE with helloworld.ek9 open: two hovers on the right describe stdout and println, and the run dialog shows Success with the output Hello, World! |
| The EK9 IDE | What you need | ek9 -ide starts the IDE. Like the rest of EK9, it needs Java 25 or later. |
| The EK9 IDE | A first program | Your first project makes a new project and runs a program in it, step by step, with a picture of each step. To open a directory of .ek9 files you already have, use File > Open Project…, open a source file, and run its program with Run > Run Program…. Here is the program from the introduction: The ... |
| The EK9 IDE | The lessons | The IDE teaches itself in lessons: each one shows you an action step by step, then watches while you do it. Each lesson has a page of its own here, with every step and a picture of the IDE once it is done. To play one in the IDE, choose Help > Lessons and its group, or run ek9 -ide -lesson <name>. |
| The EK9 IDE | Getting started | Your first project, and finding your way round the IDE. Your first project: A new project, a new file, the example program pasted in from the answers, and run.Chapter 6: reading errors: Where an error shows - the Problems tab and the margin - the Tab quick fix for a misspelt name, Next Error (F2) ... |
| The EK9 IDE | Finding | Search and replace, in Text or Symbols mode, across one file, a module or the whole project - and the two other ways of finding your way, Find Construct and Find References. Find: text: Type into the find bar and watch the count update live, step through matches with Find Next/Previous, then ... |
| The EK9 IDE | Writing code | New constructs - classes, functions, records - and the fields, methods and operators they hold. New Construct: the dialogs: What the New Construct dialogs ask for: a class made Open, a class that Extends it, a trait (which has neither choice), Preview before Apply, and Code > New Package… for a ... |
| The EK9 IDE | Applications and services | Applications and dependency injection, aspects, web services and networking - each built with the IDE's tools, then run. An application and its test double: Build dependency injection with the IDE's tools: an abstract Notifier component, a production and a test implementation, two Applications ... |
| The EK9 IDE | Getting Started with EK9 | The book's examples, chapter by chapter, each built with the IDE's own tools - typing only the logic no tool can write. Chapter 1: a second greeting, typed: Build the book's Greeting program: New Construct ▸ Program… writes the shell and the two print lines are typed. Then run it.Chapter 2: ... |
| The EK9 IDE | EK9 in Depth | The second book's examples, chapter by chapter, each built with the IDE's own tools - typing only the logic no tool can write. Chapter 24: settings, an Optional and a Result, built: Build the chapter's start-up routine: New Construct ▸ Constant… writes the two port limits, ▸ Function… the lookup ... |
| The EK9 IDE | Refactoring | Rename, extract, inline, change a signature, move: each previewed before it is applied. Extract Constant: Give a literal a name: a constant defined once, and every use of the literal in the file replaced by it.Rename Symbol: Rename a name and every use of it, wherever it is - for a name that says ... |
| The EK9 IDE | Running and testing | Run configurations, tests and the Tests tab, coverage. Run configurations: Run > Run Program… for a run you will not repeat, then Run > Configurations… to save several configurations for one program - each its own arguments and environment variables - the toolbar's picker to switch between them ... |
| The EK9 IDE | Quality and reports | The quality report, complexity and the other measures. The quality report: Run > Quality Report, the pass/fail pill, why Verification's centre number is asserted rather than covered, Coverage Detail, a module then a file with its own covered/uncovered lines, and one of the DI Wiring / Module ... |
| The EK9 IDE | Debugging and the Journal | Breakpoints and stepping, and the Journal: a run recorded and read backwards to its cause. Breakpoints and stepping: Click the breakpoint column to stop a line every time it runs, then step - Over without leaving the line that called it, Into to follow a call, Out to come back - and Run to Cursor ... |
| The EK9 IDE | Understanding a codebase | The Analyse views: what calls what, what depends on what. Show Blast Radius: See who a purity change would reach before you make it - the callers that break if pure is removed, the callees that must become pure if it is added - from the right-click Show Blast Radius item, at the point of ... |
| The EK9 IDE | Security, packages and Git | Sanitised input, packages and their versions, and Git. Capabilities: The security-capability audit window: every gated system type the code uses against what the package declares - under-declared (the E12010 set) fixed with Add Capability, over-declared (declared but unused) tidied with Remove ... |
| The EK9 IDE | Fixing errors | Every error EK9 reports is explained - in the Help tab, or by ek9 -h and its code - and the explanation ends with "Show me how to fix it": a lesson that opens the error's example and fixes it, step by step. They are listed in the error index. |
| The EK9 IDE | The menus | Each menu holds one kind of action. Right-click in the editor for everything that applies where the caret is, or use Refactor > Refactor This… (Ctrl+T) for the same menu from the keyboard. MenuWhat it holdsFileNew Project…, Open Project…, Recent Projects, Save, Save All, Settings…EditUndo, ... |
| The EK9 IDE | Using VS Code or IntelliJ instead | The EK9 extension for VS Code (vscode-ek9-ls) starts the EK9 language server, ek9 -ls. The server reports the compiler's errors as you type, and answers hover, completion, go to definition and find references. The EK9 plugin for IntelliJ (intellij-ek9-ls) uses the same language server, and the ... |
| The EK9 IDE | The language | This section covers the IDE. The language itself is in the EK9 language reference, starting with Structure. |
| Your first project | Your first project | This page makes a first project in the EK9 IDE and runs a program in it. It follows Help > Getting Started, and every picture is of the IDE doing each step. |
| Your first project | The IDE as it first opens | Start the IDE with ek9 -ide. With no project open it shows the Welcome page, with the keys for the most used actions and, under the title, New to EK9? Getting Started, which shows these same steps in the IDE's Help tab. The EK9 IDE with no project open: the Welcome page lists keyboard shortcuts ... |
| Your first project | Step 1: A new project | A project is a folder that holds your .ek9 files. Choose File > New Project…. The File menu open, with New Project… highlighted above Open Project…, Recent Projects, Save, Save All, Settings… and Exit Choose where the folder goes and give it a name. The name is hello to start with; the line at ... |
| Your first project | Step 2: A new EK9 file | In the Project panel, right-click the project and choose New EK9 File…. The Project panel with the project hello right-clicked: a menu with New Directory…, New EK9 File… (highlighted) and Add dev Name it HelloWorld.ek9. The module name is filled in from the project, and the file opens with its ... |
| Your first project | Step 3: The example program | Help > Getting Started shows the steps in the Help tab. Click ek9 -q 1 in step 3. The Help tab showing GETTING STARTED: the steps in the IDE and in a terminal, with the command ek9 -q 1 in step 3 underlined as a link The Answers tab opens at the answer to What does a minimal EK9 program look ... |
| Your first project | Step 4: Paste it in | In HelloWorld.ek9, select everything (Cmd+A on a Mac, Ctrl+A elsewhere) and paste (Cmd+V or Ctrl+V) the example over it, then save (Cmd+S or Ctrl+S). Saving compiles it: the status bar says Build clean, and a green run arrow appears beside the program's name, MinimalProgram(). HelloWorld.ek9 ... |
| Your first project | Step 5: Run it | Click the run arrow. Run Program opens with the program chosen; a program that takes arguments has them typed here. Choose Run. The Run Program dialog with MinimalProgram chosen, from HelloWorld.ek9 line 5, no run configurations, an empty Arguments field, and Cancel and Run The program runs and ... |
| Your first project | Next | The program's parts, and what to read next: ek9 -h quickstart in a terminal, or the Structure of an EK9 program in the language reference.Ask about anything in your own words: type it in the bar at the top of the IDE, or ek9 -q and your question in a terminal. |
| Chapter 6: reading errors | Chapter 6: reading errors | Three small programs, each with something wrong - two of them broken forms from chapter 6, Reading the Compiler's Guidance. The compiler has found one error so far, in greeting.ek9: the Problems tab lists it, and the editor underlines it. Read the code and find the underlined word. To play it in ... |
| Chapter 6: reading errors | Step 1: Where an error shows | Click the error in the Problems tab. The editor opens that place. The EK9 IDE once this is done: Click the error in the Problems tab The editor marks the same place: a red circle in the margin beside line 8 and a red underline under printn. Rest the pointer on printn and a tooltip gives the code, ... |
| Chapter 6: reading errors | Step 2: The quick fix | Click on printn and leave the pointer there a moment, then press Tab. The compiler offers the names that fit - print and println; Tab again moves to println and Enter takes it. (Clicking println under Quick Fixes in the Hovers panel does the same.) Then choose File > Save. The EK9 IDE once this ... |
| Chapter 6: reading errors | Step 3: The next errors | The compiler checks in stages and reports one stage's errors at a time. Names it cannot find come first; the later checks run once they are fixed. Now they have run: two more errors, in two files - a condition that is always true (E08086) and a bare number in a comparison (E11064). The EK9 IDE ... |
| Chapter 6: reading errors | Step 4: How much it says | Move the error-detail slider, at the right of the status bar, to E3. The EK9 IDE once this is done: Move the error-detail slider, at the right of the status bar, to E3 At E3 the Build Output tab explains every error in full - what is wrong, why, and how to put it right. E0 is the bare minimum, E1 ... |
| Chapter 6: reading errors | Step 5: The full explanation | Type /h E08086 in the input bar at the top and press Enter. The Help tab explains the error in full - the same text as ek9 -h E08086 in a terminal. The EK9 IDE once this is done: Type /h E08086 in the input bar at the top and press Enter |
| Chapter 6: reading errors | The result | That is how to read the compiler: where an error is (the Problems tab, the margin, Next Error), a quick fix when the compiler can name the answer, as much detail as you want (E0 to E3), and /h with the error's code for everything it knows. The other two errors are still here - E08086 and E11064 - ... |
| Chapter 6: reading errors | Where this lesson comes from | The errors it fixes - each one's explanation offers this lesson: E50060.Answers - ek9 -q and the IDE's Answers tab: 247.For AI assistants - the MCP tool ek9_compile, ek9_explain_error. |
| The panels | The panels | The IDE's window has the editor in the middle, tool windows at its sides and a bottom panel of tabs - Problems, Build Output, Help and more. This lesson folds the panel away, opens a tool window, tears it off into a window of its own and brings it back. To play it in the IDE: Help > Lessons > ... |
| The panels | Step 1: The bottom panel | Choose View > Bottom Panes > Toggle Bottom Panel (Shift+Cmd+P). The panel folds away and the editor takes its room. The EK9 IDE once this is done: Choose View > Bottom Panes > Toggle Bottom Panel (Shift+Cmd+P) Choose it again. The panel opens, on the tab it was on. The EK9 IDE once this is done: ... |
| The panels | Step 2: Tool windows | Choose View > Tool Windows > Constructs (Cmd+6). The Constructs window opens beside the editor and lists the project's constructs; its button on the activity bar, at the window's edge, lights. The EK9 IDE once this is done: Choose View > Tool Windows > Constructs (Cmd+6) |
| The panels | Step 3: A window of its own | Right-click the Constructs button on the activity bar and choose Detach to Window. The pane moves into a window of its own. The EK9 IDE once this is done: Right-click the Constructs button on the activity bar and choose Detach to Window Choose Window > Redock All. Every detached window goes back ... |
| The panels | Step 4: View switches | Choose View > Toggles > Complexity Badges. The switches for how the editor looks are all here, ticked when on, each with its shortcut. The EK9 IDE once this is done: Choose View > Toggles > Complexity Badges Choose it again to turn it off. The EK9 IDE once this is done: Choose it again to turn it ... |
| The panels | The result | The bottom panel folds away with Shift+Cmd+P and every pane in it comes back from View > Bottom Panes; the tool windows open from View > Tool Windows (Cmd+1 to Cmd+0) or their buttons on the activity bar; a window can be torn off with a right-click and brought home with Window > Redock All; and ... |
| Asking the IDE | Asking the IDE | The bar at the top of the window answers questions: /h for a type, a keyword or an error code, /q for a question, /t for a tool. Each answers in a tab of the bottom panel, instantly, and none of them changes your code. Resting the pointer on a name explains it too. To play it in the IDE: Help > ... |
| Asking the IDE | Step 1: A type or a keyword: /h | Type /h String in the input bar and press Enter. The Help tab shows what a String offers - its constructors, methods and operators. Try /h record, or /h E05030 for an error. The EK9 IDE once this is done: Type /h String in the input bar and press Enter |
| Asking the IDE | Step 2: A question: /q | Type /q followed by some words - /q read compiler error messages - and press Enter. The Answers tab lists the questions that match, each with a worked example. A question's number, /q 247, opens just that one. The EK9 IDE once this is done: Type /q followed by some words - /q read compiler error ... |
| Asking the IDE | Step 3: A tool: /t | Type /t rename and press Enter. The Tooling tab lists the tools that match - the same ones an AI assistant is given. A tool's name, /t ek9_rename_symbol, shows its arguments. The EK9 IDE once this is done: Type /t rename and press Enter |
| Asking the IDE | Step 4: A name in the editor: Hovers | Rest the pointer on peak, in the editor. The Hovers panel, at the right, explains it. An error rested on is explained there too, in full. The EK9 IDE once this is done: Rest the pointer on peak, in the editor |
| Asking the IDE | The result | /h answers in the Help tab (a type, a keyword or an error code), /q in the Answers tab (a question, by its words or its number) and /t in the Tooling tab (a tool) - the same text as ek9 -h, ek9 -q and ek9 -tool in a terminal. The Hovers panel explains whatever the pointer rests on, and typing ... |
| Asking the IDE | Where this lesson comes from | Answers - ek9 -q and the IDE's Answers tab: 21.For AI assistants - the MCP tool ek9_help, ek9_ask, ek9_query_tool_catalogue. |
| Help and documentation | Help and documentation | The Help menu holds what to read: the paradigm EK9 is built on, the licences, every lesson, and the documentation (offline, in an installed copy). This lesson opens the first three, and then takes the caret to a line, which no other lesson does. To play it in the IDE: Help > Lessons > Getting ... |
| Help and documentation | Step 1: EK9 Paradigm | Choose Help > EK9 Paradigm The EK9 IDE once this is done: Choose Help > EK9 Paradigm A table of what EK9 has no (return, null, break...) and what it uses instead, and the traps a newcomer meets first - the same primer an AI assistant gets from ek9_paradigm. Read it, then choose OK. |
| Help and documentation | Step 2: Licences | Choose Help > Licences The EK9 IDE once this is done: Choose Help > Licences EK9's own licence, the runtime's and the third-party licences, one button each. Read what you need, then choose OK. |
| Help and documentation | Step 3: All the lessons | Choose Help > Lessons > All Lessons… The EK9 IDE once this is done: Choose Help > Lessons > All Lessons… Every lesson, listed by group: choose one for Show me, where the IDE does it, or Do it myself, where it waits for you. Choose Close. |
| Help and documentation | Step 4: Go to a line | Choose Navigate > Go to Line… The EK9 IDE once this is done: Choose Navigate > Go to Line… Type 22 and choose OK. The caret moves to that line of the file in front, and the editor scrolls to it. The EK9 IDE just before choosing OK: Type 22 and choose OK |
| Help and documentation | The result | Help > EK9 Paradigm explains the design decisions, Help > Licences the licences, Help > Lessons > All Lessons… every lesson, and Cmd+L takes the caret to a line. Help > Documentation opens the documentation in your browser - an installed copy carries all of ek9.io and serves it itself, so the ... |
| Help and documentation | Where this lesson comes from | For AI assistants - the MCP tool ek9_paradigm. |
| Find: text | Find: text | The find bar (Edit › Find…) searches this file's text as you type, with a live count of every match. total appears here as a class, a field, a method's tail (subtotal), a local, and inside a comment and a String. To play it in the IDE: Help > Lessons > Finding…, or ek9 -ide -lesson find-text. The ... |
| Find: text | Step 1: Type to search | Choose Edit > Find… The EK9 IDE once this is done: Choose Edit > Find… Type total into the field. The count updates as you type - 15 matches, comments and Strings included. The EK9 IDE once this is done: Type total into the field |
| Find: text | Step 2: Step through the matches | Choose the ↓ (or press Enter) to go to the next match. The EK9 IDE once this is done: Choose the ↓ (or press Enter) to go to the next match Choose the ↑ (or press Shift+Enter) to go back to the previous match. The EK9 IDE once this is done: Choose the ↑ (or press Shift+Enter) to go back to the ... |
| Find: text | Step 3: Whole word | Turn on Whole word (W). total is one word, so it no longer matches inside subtotal - the count drops to 12. The EK9 IDE once this is done: Turn on Whole word (W) |
| Find: text | Step 4: Match case | Turn off Whole word, then turn on Match case (Aa). Capital-letter Total - the class itself, and the others spelled with a capital T - no longer match: 11 matches. The EK9 IDE once this is done: Turn off Whole word, then turn on Match case (Aa) Choose the ✕ (or press Escape) to close the find bar. ... |
| Find: text | The result | That is Text mode: it searches the file's text itself - comments and Strings included - never what the compiler knows. Match case and Whole word narrow it further; the next lesson uses a regular expression to search and replace in one pass. |
| Find: regex replace | Find: regex replace | The find bar's replace row can use a regular expression, whose parenthesised groups the replacement can reorder with $1, $2 and so on. doubled() computes price * 2 - this lesson rewrites it to 2 * price. To play it in the IDE: Help > Lessons > Finding…, or ek9 -ide -lesson find-regex-replace. The ... |
| Find: regex replace | Step 1: Open Replace | Choose Edit > Replace… The EK9 IDE once this is done: Choose Edit > Replace… |
| Find: regex replace | Step 2: A regular expression | Turn on the regular expression toggle (.*), then type (\w+) * (\d) into the field - a word, then * , then a digit, each side held in its own group. One match. The EK9 IDE once this is done: Turn on the regular expression toggle (.*), then type (\w+) * (\d) into the field - a word, then * , then a ... |
| Find: regex replace | Step 3: Replace with a capture group | Type $2 * $1 into the Replace field - the digit first, then the word: the two groups swapped. Choose Replace All. The EK9 IDE once this is done: Type $2 * $1 into the Replace field - the digit first, then the word Text mode changes this file's buffer, not yet saved. Choose File > Save. The EK9 ... |
| Find: regex replace | The result | That is a regular expression's capture groups used in the replacement: price * 2 read, and reordered into 2 * price. Replace changes only the current match; Replace All - just used - changes every match in the file. Text mode edits the buffer, so the file is saved before it is really changed. |
| Find: symbols | Find: symbols | Text mode searches the file's text; Symbols mode asks the last compile for names of the kinds you choose. total here is a class, a field, a method (subtotal), a local, and words inside a comment and a String - only the compiler-known ones survive the switch. To play it in the IDE: Help > Lessons ... |
| Find: symbols | Step 1: Text mode, for contrast | Choose Edit > Find… The EK9 IDE once this is done: Choose Edit > Find… Type total. In Text mode every one of the 15 places matches, comment and String included. The EK9 IDE once this is done: Type total |
| Find: symbols | Step 2: Switch to Symbols | Choose Symbols. The comment and the String drop out, and subtotal counts once, as the method it is, not as a text match on part of its name: 12 matches. The EK9 IDE once this is done: Choose Symbols |
| Find: symbols | Step 3: The three kind chips | Click the Constructs chip to turn it off - the class Total and the program ShowTotal no longer count: 11. The EK9 IDE once this is done: Click the Constructs chip to turn it off - the class Total and the program ShowTotal no longer count Click the Variables chip too, leaving only Members - the ... |
| Find: symbols | Step 4: Declared, Read, Written | Turn off Read, leaving Declared and Written - the field's one read, and the method's own call, drop out: 3. The EK9 IDE once this is done: Turn off Read, leaving Declared and Written - the field's one read, and the method's own call, drop out Turn off Written too, leaving only Declared - the ... |
| Find: symbols | The result | That is Symbols mode: it asks the last compile, never the text, so a comment or a String never matches, and a name is found and classified by what it IS - a construct, a member or a variable - each with its own chip and dropdown, then narrowed by whether it is declared, read or written. Replace, ... |
| Replace: symbols | Replace: symbols | Replace in Symbols mode does not edit text: it renames the symbol Find found, everywhere it is used, through the same compile-checked preview Rename Symbol uses. Here it is the running total ShowTotal keeps in its own local, named total. To play it in the IDE: Help > Lessons > Finding…, or ek9 ... |
| Replace: symbols | Step 1: Find the local | Choose Edit > Replace… The EK9 IDE once this is done: Choose Edit > Replace… Choose Symbols. The EK9 IDE once this is done: Choose Symbols Type total. The EK9 IDE once this is done: Type total Turn off the Constructs chip, then the Members chip, leaving only Variables - just the local remains: 4 ... |
| Replace: symbols | Step 2: Rename it | Type runningTotal into the new-name field. The EK9 IDE once this is done: Type runningTotal into the new-name field Choose Rename. Even though only one match is selected, the whole symbol is renamed - all 4 places, not just that one. The EK9 IDE once this is done: Choose Rename |
| Replace: symbols | Step 3: Preview and apply | The preview shows every place total becomes runningTotal. Choose Apply. |
| Replace: symbols | The result | That is Replace in Symbols mode: every one of the local's 4 places changed together, in one compile-checked preview - never just the match you clicked, the way Text mode's Replace only touches the text at hand. AI assistants use the same ek9_rename_symbol tool. The EK9 IDE when the lesson has ... |
| Replace: symbols | Where this lesson comes from | For AI assistants - the MCP tool ek9_rename_symbol. |
| Find in Project | Find in Project | Edit > Find in Project… opens the find bar at Project scope, every search listed in the Find Results tab. total is in shop.ek9, in receipt.ek9 (the same module), and in till.ek9 (a module of its own). To play it in the IDE: Help > Lessons > Finding…, or ek9 -ide -lesson find-in-project. The EK9 ... |
| Find in Project | Step 1: Open Find in Project | Choose Edit > Find in Project… The EK9 IDE once this is done: Choose Edit > Find in Project… Type total. The Find Results tab lists 27 matches in 3 files - the whole project. The EK9 IDE once this is done: Type total |
| Find in Project | Step 2: List, and jump to a result | Choose the Problems tab, to put Find Results away. The EK9 IDE once this is done: Choose the Problems tab, to put Find Results away Choose List, in the find bar. The Find Results tab comes forward again. The EK9 IDE once this is done: Choose List, in the find bar Click one of till.ek9's own ... |
| Find in Project | Step 3: Narrow to Module | Change the scope to Module. till.ek9 - a module of its own - drops out: 23 matches in 2 files. The EK9 IDE once this is done: Change the scope to Module |
| Find in Project | Step 4: Narrow to File | Change the scope to File. receipt.ek9 drops out too, leaving the open file alone: 15 matches in 1 file. The EK9 IDE once this is done: Change the scope to File |
| Find in Project | The result | That is scope: Project searches the whole workspace, Module just the files of one module, File the open file alone - till.ek9, a module of its own, is the first to drop out narrowing down. Every search lists in the Find Results tab; List brings it forward again, and a result's own click opens it. |
| Find your way | Find your way | Find Construct… jumps straight to a class, function or program by name, anywhere in the project. Find References jumps the other way - from a symbol to every place it is used. To play it in the IDE: Help > Lessons > Finding…, or ek9 -ide -lesson find-your-way. The EK9 IDE as the lesson opens |
| Find your way | Step 1: Find Construct… | Choose Navigate > Find Construct… The EK9 IDE once this is done: Choose Navigate > Find Construct… Type Total. The EK9 IDE once this is done: Type Total Click Total, the class. The editor jumps to its declaration. The EK9 IDE once this is done: Click Total, the class |
| Find your way | Step 2: Find References | Put the caret on the total field's own declaration, on line 7. The EK9 IDE once this is done: Put the caret on the total field's own declaration, on line 7 Choose Navigate > Find References. The References pane lists its declaration, a write and a read. The EK9 IDE once this is done: Choose ... |
| Find your way | The result | Find Construct jumps to a class, function or program by name, anywhere in the project; Find References jumps from a symbol to every place it is used. Neither looks inside text - both ask the compiler, the way Symbols mode does. |
| New Construct: the dialogs | New Construct: the dialogs | Fleet is a module with one small program in it. Code > New Construct writes a new class, record, trait, function, program or other construct into the open file - a dialog asks for what that kind needs, Preview shows the text, Apply writes it. To play it in the IDE: Help > Lessons > Writing code…, ... |
| New Construct: the dialogs | Step 1: A class that may be extended | Choose Code > New Construct > Class… The EK9 IDE once this is done: Choose Code > New Construct > Class… Vehicle is the class's name. Closed is already selected - EK9's default, a class nobody can extend. Vehicle must be a parent. Choose Open under Extensibility. Choose Preview. The EK9 IDE just ... |
| New Construct: the dialogs | Step 2: A class that extends it | Choose Code > New Construct > Class… The EK9 IDE once this is done: Choose Code > New Construct > Class… Truck is the class's name. The Extends field turns red for a type that does not exist, and Preview stays grey until it does. Type Vehicle into Extends. Choose Preview. The EK9 IDE just before ... |
| New Construct: the dialogs | Step 3: A trait | Choose Code > New Construct > Trait… The EK9 IDE once this is done: Choose Code > New Construct > Trait… Describable is the trait's name. There is no Closed, Open or Abstract choice and no Extends field here - a trait is a contract, never extended the way a class is. Choose Preview. The EK9 IDE ... |
| New Construct: the dialogs | Step 4: A package | Choose Code > New Package… The EK9 IDE once this is done: Choose Code > New Package… A package block holds the module's version, description and what to include. Type a description, tick Apply standard includes so every .ek9 file in the tree is part of the package, and choose Create. The EK9 IDE ... |
| New Construct: the dialogs | The result | That is New Construct: every dialog asks for a name and the few choices that kind of construct has - Closed, Open or Abstract and an Extends: for a class, none of either for a trait - then Preview shows the exact text before Apply writes it, and Apply is refused if it would leave an error. ... |
| New Construct: the dialogs | Where this lesson comes from | Answers - ek9 -q and the IDE's Answers tab: 102.For AI assistants - the MCP tool ek9_new_construct. |
| Adding members to a class | Adding members to a class | Parcel is a small class with one field, weight. Right-click its name line and the editor offers to add the members a class can have: a field, a constructor, a method, an operator. Each item writes the code in the right place, in the right order, and is refused if it would leave an error. To play ... |
| Adding members to a class | Step 1: A field | Right-click the Parcel line and choose Add Field… The EK9 IDE once this is done: Right-click the Parcel line and choose Add Field… Type label as String: String() - a name, a type, and the unset value it starts with. Choose OK. The EK9 IDE just before choosing OK: Type label as String The preview ... |
| Adding members to a class | Step 2: A constructor | Right-click the Parcel line and choose Add Constructor > From All Fields (pure). The submenu also offers a no-arg constructor, private or pure - and only the ones that are still missing. The EK9 IDE once this is done: Right-click the Parcel line and choose Add Constructor > From All Fields (pure) |
| Adding members to a class | Step 3: A method | Right-click the Parcel line and choose Add Method… The EK9 IDE once this is done: Right-click the Parcel line and choose Add Method… describe is the method's name. It only reads the fields. Set Return type to String and tick pure. Choose Apply. The EK9 IDE just before choosing Apply: describe is ... |
| Adding members to a class | Step 4: An operator | Right-click the Parcel line and choose Add Operator > $ (string) > skeleton. The other choice, default, would write 'default operator $' - the compiler's own version, with no body to read. The EK9 IDE once this is done: Right-click the Parcel line and choose Add Operator > $ (string) > skeleton |
| Adding members to a class | Step 5: Back to a default operator | Put the caret on the operator $ line - the skeleton just written spells out exactly what the compiler would generate. The EK9 IDE once this is done: Put the caret on the operator $ line - the skeleton just written spells out exactly what the compiler would generate Right-click it and choose ... |
| Adding members to a class | The result | That is the right-click menu on a class: Parcel gained a field, a constructor, a method and an operator without a line typed, and each item refused anything that would have left an error. The describe method is only a stub (//AI: Implement describe) - its logic is yours, or an AI assistant's, to ... |
| Adding members to a class | Where this lesson comes from | Answers - ek9 -q and the IDE's Answers tab: 116.For AI assistants - the MCP tool ek9_add_field, ek9_add_constructor, ek9_add_method, ek9_add_operator, ek9_collapse_to_default_operator, ek9_expand_default_operator. |
| Create Dynamic Function | Create Dynamic Function | Create Dynamic Function authors a closure - a local variable holding a small function, declared where you are, with no construct of its own to name - extending a base function you pick; the compiler validates the result in the same preview every refactoring opens. Here Checker has nothing to ... |
| Create Dynamic Function | Step 1: Where it goes | Put the caret at the end of the threshold <- 5 line - the closure is inserted straight after it. The EK9 IDE once this is done: Put the caret at the end of the threshold <- 5 line - the closure is inserted straight after it |
| Create Dynamic Function | Step 2: Create the closure | Right-click it - or choose Refactor > Refactor This… - and choose Create Dynamic Function…. Name the variable isPositive, pick Predicate of Integer as the base function - its parameter t and return r appear read-only below - type r: t > 0 as the body, and choose Preview. The EK9 IDE just before ... |
| Create Dynamic Function | Step 3: Preview and apply | The preview shows the closure; then the IDE formats the file it changed. Choose Apply. The EK9 IDE just before choosing Apply: The preview shows the closure; then the IDE formats the file it changed |
| Create Dynamic Function | Step 4: Use it | A closure never called is a local EK9 refuses (E08090) - replace stdout.println($threshold) with stdout.println($isPositive(threshold)) and save. The EK9 IDE once this is done: A closure never called is a local EK9 refuses (E08090) - replace stdout.println($threshold) with ... |
| Create Dynamic Function | The result | That is Create Dynamic Function: isPositive is a closure extending Predicate of Integer, its body r: t > 0 - t and r are the base's own parameter and return names, shown read-only once the base is picked - and threshold's println now calls it. Leave the body empty and the tool scaffolds a //AI ... |
| Create Dynamic Function | Where this lesson comes from | Answers - ek9 -q and the IDE's Answers tab: 52.For AI assistants - the MCP tool ek9_create_dynamic_function. |
| Create Dynamic Class | Create Dynamic Class | Create Dynamic Class authors a class - a local variable holding a small object, declared where you are, with no construct of its own to name - implementing one or more traits you pick, extending a generic base, or naming a module-level tuple type; the compiler validates the result in the same ... |
| Create Dynamic Class | Step 1: Where it goes | Put the caret at the end of the prefix <- "item" line - the class is inserted straight after it. The EK9 IDE once this is done: Put the caret at the end of the prefix <- "item" line - the class is inserted straight after it |
| Create Dynamic Class | Step 2: Create the class | Right-click it - or choose Refactor > Refactor This… - and choose Create Dynamic Class…. Name the variable d, add a trait row named Describable - trait is already the chosen form - choose Generate trait methods to stub describe(), and choose Preview. The EK9 IDE just before choosing Preview: ... |
| Create Dynamic Class | Step 3: Preview and apply | The preview shows the class; then the IDE formats the file it changed. Choose Apply. The EK9 IDE just before choosing Apply: The preview shows the class; then the IDE formats the file it changed |
| Create Dynamic Class | Step 4: Use it | An instance never used is a local EK9 refuses (E08090) - replace stdout.println(prefix) with stdout.println(prefix + d.describe()) and save. The EK9 IDE once this is done: An instance never used is a local EK9 refuses (E08090) - replace stdout.println(prefix) with stdout.println(prefix + ... |
| Create Dynamic Class | The result | That is Create Dynamic Class: d is an anonymous class implementing Describable, its one abstract method describe() stubbed by Generate trait methods with a //AI: complete method lead - and prefix's println now reads it too. The same Form selector offers tuple (a named module-level type, captures ... |
| Create Dynamic Class | Where this lesson comes from | Answers - ek9 -q and the IDE's Answers tab: 1126.For AI assistants - the MCP tool ek9_create_dynamic_class. |
| Your own generic class and function | Your own generic class and function | List of String is one generic filled in with String; this lesson WRITES one. The project has a trait Named and two classes that adopt it, Book and Mug. You will write a Shelf that holds one thing of some type T - any T that is Named, so the Shelf itself may ask its contents for their name - and a ... |
| Your own generic class and function | Step 1: Shelf — a generic class | Choose Code > New Construct > Class… The EK9 IDE once this is done: Choose Code > New Construct > Class… Shelf is the class's name. Tick Generic: a type-parameter row appears - T, Constrain by Named, so only a Named type can fill it - and a Fields row: held, of type T. Choose Preview. The EK9 IDE ... |
| Your own generic class and function | Step 2: label — what the constraint buys | Right-click the Shelf line and choose Add Method… The EK9 IDE once this is done: Right-click the Shelf line and choose Add Method… label is the method's name. Set Return type to String. Choose Apply. The EK9 IDE just before choosing Apply: label is the method's name Select the stub and type ... |
| Your own generic class and function | Step 3: describe — a generic function | Choose Code > New Construct > Function… The EK9 IDE once this is done: Choose Code > New Construct > Function… describe is the function's name. Tick Generic and give the same limit, T constrained by Named; one parameter, item of type T; Returns String. Choose Preview. The EK9 IDE just before ... |
| Your own generic class and function | Step 4: The program | Choose Code > New Construct > Program… The EK9 IDE once this is done: Choose Code > New Construct > Program… Show is the program's name. Choose Preview. The EK9 IDE just before choosing Preview: Show is the program's name The preview shows Show about to be written. Choose Apply. The EK9 IDE just ... |
| Your own generic class and function | Step 5: Read Shelf of Book's Effective API | Select books, on the line that declares it, then choose Analyse ▸ Effective API. The EK9 IDE once this is done: Select books, on the line that declares it, then choose Analyse ▸ Effective API Shelf of Book is a type EK9 made from your Shelf, and it carries what you wrote with Book filled in for ... |
| Your own generic class and function | Step 6: Read Shelf of Mug's Type Hierarchy | Select mugs, then choose Analyse ▸ Type Hierarchy. The EK9 IDE once this is done: Select mugs, then choose Analyse ▸ Type Hierarchy Shelf of Mug sits directly under Any - it extends nothing of yours, and is not related to Shelf of Book in the type system: two fillings of one generic are two ... |
| Your own generic class and function | Step 7: Run it | Choose Run > Run Program… The EK9 IDE once this is done: Choose Run > Run Program… The project's only program is already chosen. Choose Run. Dune, Blue mug, then Blue mug in angle brackets - each Shelf asked its own contents for a name, and describe did the same for a Mug passed straight in. ... |
| Your own generic class and function | The result | That is a generic of your own: one Shelf, written once with a type parameter T that must be Named, used with a Book and with a Mug - each a type of its own that Effective API and Type Hierarchy read, and the compiler checked every use. describe() is the same idea as a function. Java would erase T ... |
| Your own generic class and function | Where this lesson comes from | Answers - ek9 -q and the IDE's Answers tab: 194, 195, 58, 196.For AI assistants - the MCP tool ek9_new_construct, ek9_add_method, ek9_add_program, ek9_query_effective_api, ek9_query_type_hierarchy. |
| An application and its test double | An application and its test double | If you know Spring or Guice you expect annotations and a scan; EK9 has neither. A component is a construct, and an Application is a construct that lists which implementation stands for which contract. A program names the Application it runs with and asks for what it needs with a ! suffix. This ... |
| An application and its test double | Step 1: Notifier — the contract | Choose Code > New Construct > Component… The EK9 IDE once this is done: Choose Code > New Construct > Component… Notifier is the component's name. It is the contract: what any notifier can do, with nothing behind it. Choose Abstract under Extensibility. Choose Preview. The EK9 IDE just before ... |
| An application and its test double | Step 2: Two implementations | Choose Code > New Construct > Component… The EK9 IDE once this is done: Choose Code > New Construct > Component… ConsoleNotifier is the component's name. It is the one that really notifies: it answers with the message marked as sent. Type Notifier into Extends. Choose Preview. The EK9 IDE just ... |
| An application and its test double | Step 3: Two applications | Choose Code > New Construct > Application… The EK9 IDE once this is done: Choose Code > New Construct > Application… ShopApp is the application's name. It is production wiring: wherever a Notifier is asked for, the ConsoleNotifier answers. The Registrations table holds ConsoleNotifier as ... |
| An application and its test double | Step 4: A program that injects | Choose Code > New Construct > Program… The EK9 IDE once this is done: Choose Code > New Construct > Program… Announce is the program's name. It runs with application of ShopApp, and its ! line asks for a Notifier, never a ConsoleNotifier. Type ShopApp into Application. Add the injection notifier ... |
| An application and its test double | Step 5: Run it | Choose Run > Run Program… The EK9 IDE once this is done: Choose Run > Run Program… The project's only program is already chosen. Choose Run. sent: order shipped - the program asked for a Notifier and the application it is bound to supplied the ConsoleNotifier. Choose Close. The EK9 IDE just ... |
| An application and its test double | Step 6: DI Wiring | Choose Analyse > DI Wiring. The EK9 IDE once this is done: Choose Analyse > DI Wiring Both applications are drawn: ShopApp registers ConsoleNotifier as Notifier, TestApp registers RecordingNotifier as Notifier, and the injection site Announce.notifier, which needs a Notifier, is ticked under ... |
| An application and its test double | Step 7: A test with the double | Open dev/tests.ek9 - it holds only its module line. A test goes in dev/, and a test in the same module needs no references block. The EK9 IDE once this is done: Open dev/tests.ek9 - it holds only its module line Choose Code > New Construct > Test… The EK9 IDE once this is done: Choose Code > New ... |
| An application and its test double | The result | notify.ek9 now holds a Notifier contract, the ConsoleNotifier that really prints and the RecordingNotifier that stands in for it, two applications that wire one each, and Announce, which asks for a Notifier and is told which by the application it is bound to; dev/tests.ek9 holds a @Test bound to ... |
| An application and its test double | Where this lesson comes from | Answers - ek9 -q and the IDE's Answers tab: 1110, 1113, 111, 203.For AI assistants - the MCP tool ek9_new_construct, ek9_add_method, ek9_add_application, ek9_add_program, ek9_query_dependency_injection, ek9_run_tests. |
| An aspect around a component | An aspect around a component | If you know AspectJ or Spring AOP you expect pointcuts, annotations and a proxy to configure; EK9 has none of them. An aspect is a class that extends Aspect, with advice that runs before and after a call, and it is attached where a component is registered in an Application - the component and its ... |
| An aspect around a component | Step 1: AuditAspect — the advice | Choose Code > New Construct > Class… The EK9 IDE once this is done: Choose Code > New Construct > Class… AuditAspect is the class's name. It is a class like any other - what makes it an aspect is Extends Aspect. Type Aspect into Extends. Choose Preview. The EK9 IDE just before choosing Preview: ... |
| An aspect around a component | Step 2: Register it with the component | Choose Code > New Construct > Application… The EK9 IDE once this is done: Choose Code > New Construct > Application… AuditApp is the application's name. It registers SimpleLedger as a Ledger, and the With Aspect column adds 'with aspect of AuditAspect()' to that line - nothing about the aspect ... |
| An aspect around a component | Step 3: A program that calls the component | Choose Code > New Construct > Program… The EK9 IDE once this is done: Choose Code > New Construct > Program… PostPayment is the program's name. It asks for a Ledger and never mentions SimpleLedger or AuditAspect. Type AuditApp into Application. Add the injection ledger of type Ledger. Choose ... |
| An aspect around a component | Step 4: Run it | Choose Run > Run Program… The EK9 IDE once this is done: Choose Run > Run Program… The project's only program is already chosen. Choose Run. The three lines are the advice around the component's own: before lessons.audit::SimpleLedger.post, then posted 25 from SimpleLedger itself, then after. The ... |
| An aspect around a component | Step 5: Ask the IDE | Type /h aspect into the input bar above the editor and choose -> to send it - the same help ek9 -h aspect prints at a terminal. The EK9 IDE once this is done: Type /h aspect into the input bar above the editor and choose -> to send it - the same help ek9 -h aspect prints at a terminal The Help ... |
| An aspect around a component | The result | audit.ek9 now holds an AuditAspect whose advice runs either side of every call to a Ledger, an Application that registers SimpleLedger with that aspect, and a program that just asks for a Ledger - SimpleLedger never knew, and neither did the program. An aspect is a class, its registration is one ... |
| An aspect around a component | Where this lesson comes from | Answers - ek9 -q and the IDE's Answers tab: 114, 1115, 1116, 1117, 1118, 1119.For AI assistants - the MCP tool ek9_new_construct, ek9_add_method, ek9_add_application, ek9_add_program. |
| A web service, built and served | A web service, built and served | A web service in EK9 is a construct, like a class: no annotations, no scanning, no framework to configure - the compiler knows its routes, checks them, and refuses a program that registers a service without serving it. greeter.ek9 is an empty module. The IDE's own tools write the service and its ... |
| A web service, built and served | Step 1: The service — New Construct ▸ Service… | Choose Code > New Construct > Service… The EK9 IDE once this is done: Choose Code > New Construct > Service… Greetings is the service's name and /greetings the base URI every route sits under. The Routes table holds hello, GET /hello. Choose Preview. The EK9 IDE just before choosing Preview: ... |
| A web service, built and served | Step 2: A second route — Add Route… | Right-click the Greetings line and choose Add Route… The EK9 IDE once this is done: Right-click the Greetings line and choose Add Route… greet is the route's name. It is a second route, whose path holds a variable: a GET for /greet/{name}. The parameter name is bound by PATH - the {name} in the ... |
| A web service, built and served | Step 3: Service Routes | Choose Analyse > Service Routes. The EK9 IDE once this is done: Choose Analyse > Service Routes Both routes of Greetings, read from the compiled program: GET /greetings/hello and GET /greetings/greet/{name}, the second with its name:PATH parameter. Greetings is declared open, so the table marks ... |
| A web service, built and served | Step 4: Serve it — on localhost only | Choose Code > New Construct > Constant… The EK9 IDE once this is done: Choose Code > New Construct > Constant… GREETER_PORT is the constant's name and 8731 its value - a literal in the Value field, from which the type is inferred. The port is in one place. Type both and choose Preview. The EK9 ... |
| A web service, built and served | Step 5: Ask it, then stop it | Run it under the debugger: click the debug (bug) icon beside ServeGreetings - the Run window waits for a program to END and has no Stop, the Debug window has. The EK9 IDE once this is done: Run it under the debugger The program is already chosen. Choose Debug. The server starts, on port 8731, on ... |
| A web service, built and served | The result | That is a web service from nothing: a service construct with two routes - one written by New Construct, one by Add Route…, whose {name} path variable arrives as a parameter - read in Service Routes, registered in an application and served by a program that listens on this machine's loopback ... |
| A web service, built and served | Where this lesson comes from | Answers - ek9 -q and the IDE's Answers tab: 657, 1760.For AI assistants - the MCP tool ek9_new_construct, ek9_add_route, ek9_query_service_routes, ek9_add_application, ek9_add_program. |
| A TCP echo on localhost | A TCP echo on localhost | Two programs that talk over TCP, both on localhost: a server that echoes each line back in capitals and stops when it is sent the word shutdown, and a client that sends hello and then shutdown. The port is a constant in this file, ECHO_PORT, and the server listens on the loopback address alone - ... |
| A TCP echo on localhost | Step 1: The server | Choose Code > New Construct > Program… The EK9 IDE once this is done: Choose Code > New Construct > Program… EchoServer is the program's name. Choose Preview. The EK9 IDE just before choosing Preview: EchoServer is the program's name The preview shows EchoServer about to be written. Choose Apply. ... |
| A TCP echo on localhost | Step 2: The network is gated | E12010: TCP is a gated type - a program that opens a socket must say so. In EK9 that is the package block's capabilities list, checked by the compiler, not a permission prompt at run time. This package declares Stdout and Stderr only. The EK9 IDE once this is done: E12010 Right-click the line ... |
| A TCP echo on localhost | Step 3: The client | Choose Code > New Construct > Program… The EK9 IDE once this is done: Choose Code > New Construct > Program… EchoClient is the program's name. Choose Preview. The EK9 IDE just before choosing Preview: EchoClient is the program's name The preview shows EchoClient about to be written. Choose Apply. ... |
| A TCP echo on localhost | Step 4: A run configuration for each | Choose Run > Configurations… The EK9 IDE once this is done: Choose Run > Configurations… Select EchoServer in the list of programs, then choose + New Configuration…. Name it Echo server. The program takes no arguments and needs no environment. Choose Create. The EK9 IDE just before choosing ... |
| A TCP echo on localhost | Step 5: Run the server | In the toolbar's picker, choose Echo server. The EK9 IDE once this is done: In the toolbar's picker, choose Echo server Choose the green play icon. The server starts and stays running: its window opens, blank until the server ends - a run's output arrives when the program finishes. The EK9 IDE ... |
| A TCP echo on localhost | Step 6: Run the client | Something is now listening on localhost, port 47321. In the picker, choose Echo client. Choose the green play icon again. The EK9 IDE once this is done: Choose the green play icon again The client's window: HELLO and SHUTDOWN, each line it sent answered in capitals by the server. Choose Close. ... |
| A TCP echo on localhost | The result | That is a TCP echo, start to finish, on localhost only: a server on one fixed port that upper-cases each line and stops on the word the project names, a client that sends two lines and reads two answers, and a package block that says out loud which network types it uses - E12010 is the compiler ... |
| A TCP echo on localhost | Where this lesson comes from | Answers - ek9 -q and the IDE's Answers tab: 1273, 1277, 1700.For AI assistants - the MCP tool ek9_add_program, ek9_add_capability, ek9_run_program. |
| Chapter 1: a second greeting, typed | Chapter 1: a second greeting, typed | Chapter 1's Greeting is HelloWorld with a second line. The IDE writes the program's shell - the same New Construct ▸ Program… every later chapter uses - and you type the two prints. To play it in the IDE: Help > Lessons > Getting Started with EK9…, or ek9 -ide -lesson book-greeting. The EK9 IDE ... |
| Chapter 1: a second greeting, typed | Step 1: The program's shell | Choose Code > New Construct > Program… The EK9 IDE once this is done: Choose Code > New Construct > Program… Greeting is the program's name. Choose Preview. The EK9 IDE just before choosing Preview: Greeting is the program's name The preview shows Greeting about to be written. Choose Apply. The ... |
| Chapter 1: a second greeting, typed | Step 2: The body, typed | Select the stub, from ready <- true down to its //AI line, and type the body exactly as the chapter shows it. Saves when typed. The EK9 IDE once this is done: Select the stub, from ready <- true down to its //AI line, and type the body exactly as the chapter shows it |
| Chapter 1: a second greeting, typed | Step 3: Run it | Choose Run > Run Program… The EK9 IDE once this is done: Choose Run > Run Program… The project's only program is already chosen. Choose Run. Hello, World, then Welcome to EK9. Choose Close. The EK9 IDE just before choosing Close: Hello, World, then Welcome to EK9 |
| Chapter 1: a second greeting, typed | The result | Greeting.ek9 now reads exactly as chapter 1 of Getting Started with EK9 shows it: a Stdout, and two println calls. The shell was the tool's (ek9_add_program); the two lines are yours. The EK9 IDE when the lesson has finished |
| Chapter 1: a second greeting, typed | Where this lesson comes from | For AI assistants - the MCP tool ek9_add_program. |
| Chapter 2: values, reshaped | Chapter 2: values, reshaped | Chapter 2 is about values: names for them, EK9's built-in types, and the idea that a value can be set, unset, or briefly absent. Its own closing example - an unset chosenAge, and later, the arithmetic on it, still unset too - is written here plainer first: one extra name that adds nothing over ... |
| Chapter 2: values, reshaped | Step 1: The program | Choose Code > New Construct > Program… The EK9 IDE once this is done: Choose Code > New Construct > Program… Values is the program's name. Choose Preview. The EK9 IDE just before choosing Preview: Values is the program's name The preview shows Values about to be written. Choose Apply. The EK9 IDE ... |
| Chapter 2: values, reshaped | Step 2: A plain start | Select the stub, from ready <- true down to its //AI line, and type the book's own lines - name, age, pi, greeting and total, the four prints that follow, the selectedName checks - plainer only at the very end: chosenAge, one extra name, laterOffset, that only gets in the way, and the arithmetic ... |
| Chapter 2: values, reshaped | Step 3: Inline Variable | Put the caret on laterOffset <- 4 - a name that adds nothing over the literal it holds, read only once, on the very next line. The EK9 IDE once this is done: Put the caret on laterOffset <- 4 - a name that adds nothing over the literal it holds, read only once, on the very next line Choose ... |
| Chapter 2: values, reshaped | Step 4: Extract Variable | Select chosenAge + 4 - chosenAge + 4 itself, not the brackets or the ? around it - inside the last println. The EK9 IDE once this is done: Select chosenAge + 4 - chosenAge + 4 itself, not the brackets or the ? around it - inside the last println Choose Refactor > Extract Variable… The EK9 IDE ... |
| Chapter 2: values, reshaped | Step 5: Run it | Choose Run > Run Program… The EK9 IDE once this is done: Choose Run > Run Program… The project's only program is already chosen. Choose Run. Hello, Ada, then In four years Ada will be 40, then Ada is 36 years old and pi is roughly 3.142 - then selectedName? reads false, then true once it is given ... |
| Chapter 2: values, reshaped | The result | Values.ek9 now reads exactly as chapter 2 of Getting Started with EK9 shows it. greeting and total were typed straight in - ordinary logic, not a tool's job - but the chapter's own closing example, chosenAge and later, started plainer: a stray local, laterOffset, saying nothing 4 did not, written ... |
| Chapter 2: values, reshaped | Where this lesson comes from | For AI assistants - the MCP tool ek9_add_program, ek9_inline_variable, ek9_extract_variable. |
| Chapter 2: escapes in a string, typed | Chapter 2: escapes in a string, typed | Chapter 2 ends its strings with escapes: \n for a new line, \t for a tab, \u followed by four hex digits for any character. No tool writes them - they are typed - so the IDE writes the program's shell and you type the body. To play it in the IDE: Help > Lessons > Getting Started with EK9…, or ek9 ... |
| Chapter 2: escapes in a string, typed | Step 1: The program's shell | Choose Code > New Construct > Program… The EK9 IDE once this is done: Choose Code > New Construct > Program… Show is the program's name. Choose Preview. The EK9 IDE just before choosing Preview: Show is the program's name The preview shows Show about to be written. Choose Apply. The EK9 IDE just ... |
| Chapter 2: escapes in a string, typed | Step 2: The body, typed | Select the stub, from ready <- true down to its //AI line, and type the body exactly as the chapter shows it. Saves when typed. The EK9 IDE once this is done: Select the stub, from ready <- true down to its //AI line, and type the body exactly as the chapter shows it |
| Chapter 2: escapes in a string, typed | Step 3: Run it | Choose Run > Run Program… The EK9 IDE once this is done: Choose Run > Run Program… The project's only program is already chosen. Choose Run. Two lines of verse, a tab between Name: and Ada, then Café costs £1 twice - once from escapes, once typed directly. Choose Close. The EK9 IDE just before ... |
| Chapter 2: escapes in a string, typed | The result | Escapes.ek9 now reads exactly as chapter 2 of Getting Started with EK9 shows it: a new line and a tab by escape, and the same accented letter and pound sign written both as \u escapes and as the characters themselves - the last two lines print the same. The EK9 IDE when the lesson has finished |
| Chapter 2: escapes in a string, typed | Where this lesson comes from | For AI assistants - the MCP tool ek9_add_program. |
| Chapter 2: changing a value, typed | Chapter 2: changing a value, typed | Chapter 2's smallest program declares a value, changes it, and changes it again from its own old value. Nothing here is structure a tool could write for you, so the IDE writes the program's shell and you type the three lines and their comments. To play it in the IDE: Help > Lessons > Getting ... |
| Chapter 2: changing a value, typed | Step 1: The program's shell | Choose Code > New Construct > Program… The EK9 IDE once this is done: Choose Code > New Construct > Program… Mutation is the program's name. Choose Preview. The EK9 IDE just before choosing Preview: Mutation is the program's name The preview shows Mutation about to be written. Choose Apply. The ... |
| Chapter 2: changing a value, typed | Step 2: The body, typed | Select the stub, from ready <- true down to its //AI line, and type the body exactly as the chapter shows it. Saves when typed. The EK9 IDE once this is done: Select the stub, from ready <- true down to its //AI line, and type the body exactly as the chapter shows it |
| Chapter 2: changing a value, typed | Step 3: Run it | Choose Run > Run Program… The EK9 IDE once this is done: Choose Run > Run Program… The project's only program is already chosen. Choose Run. Final score is 15 - declared at 0, then 10, then 10 + 5. Choose Close. The EK9 IDE just before choosing Close: Final score is 15 - declared at 0, then 10, ... |
| Chapter 2: changing a value, typed | The result | Mutation.ek9 now reads exactly as chapter 2 of Getting Started with EK9 shows it: declared with <-, changed with :=, and changed once more using its own current value. The EK9 IDE when the lesson has finished |
| Chapter 2: changing a value, typed | Where this lesson comes from | For AI assistants - the MCP tool ek9_add_program. |
| Chapter 2: declaring and changing values, typed | Chapter 2: declaring and changing values, typed | Chapter 2 shows every way to declare a value and to change one. There is no tool that writes a declaration for you - typing them is the exercise - so the IDE writes only the program's shell, and you type the body, comments included. To play it in the IDE: Help > Lessons > Getting Started with ... |
| Chapter 2: declaring and changing values, typed | Step 1: The program's shell | Choose Code > New Construct > Program… The EK9 IDE once this is done: Choose Code > New Construct > Program… Show is the program's name. Choose Preview. The EK9 IDE just before choosing Preview: Show is the program's name The preview shows Show about to be written. Choose Apply. The EK9 IDE just ... |
| Chapter 2: declaring and changing values, typed | Step 2: The body, typed | Select the stub, from ready <- true down to its //AI line, and type the body exactly as the chapter shows it. Saves when typed. The EK9 IDE once this is done: Select the stub, from ready <- true down to its //AI line, and type the body exactly as the chapter shows it |
| Chapter 2: declaring and changing values, typed | Step 3: Run it | Choose Run > Run Program… The EK9 IDE once this is done: Choose Run > Run Program… The project's only program is already chosen. Choose Run. a=21 b=21 c=21 d=21, then a now 3, then e set? true e now 99 - the unset e took 99 because it was unset. Choose Close. The EK9 IDE just before choosing ... |
| Chapter 2: declaring and changing values, typed | The result | Declarations.ek9 now reads exactly as chapter 2 of Getting Started with EK9 shows it: the same value declared four ways, an unset one, three ways to reassign and the assign-if-unset form. The shell was the tool's (ek9_add_program); the declarations are yours. The EK9 IDE when the lesson has finished |
| Chapter 2: declaring and changing values, typed | Where this lesson comes from | For AI assistants - the MCP tool ek9_add_program. |
| Chapter 3: a three-way test, folded | Chapter 3: a three-way test, folded | Chapter 3's Weather answers a temperature two ways: a jacket test on its own, and a three-way test - warm, cold or mild. This lesson writes the prints first, plain, and lets Surround With fold each under its test: an if for the jacket, an if … else whose else becomes the rest of the chain. To ... |
| Chapter 3: a three-way test, folded | Step 1: A program with a parameter | Choose Code > New Construct > Program… The EK9 IDE once this is done: Choose Code > New Construct > Program… Weather is the program's name. Add one parameter, temperature of type Integer. Choose Preview. The EK9 IDE just before choosing Preview: Weather is the program's name The preview shows ... |
| Chapter 3: a three-way test, folded | Step 2: A plain start | Select the stub, from require temperature? down to its //AI line, and type the plain start: the comment, the named marks and both prints, no test yet. Saves when typed. The EK9 IDE once this is done: Select the stub, from require temperature? down to its //AI line, and type the plain start |
| Chapter 3: a three-way test, folded | Step 3: A first test: Surround With ▸ if | Put the caret on the Bring a jacket print, right-click - or choose Refactor > Refactor This… - and choose Surround With ▸ if .... The EK9 IDE once this is done: Put the caret on the Bring a jacket print, right-click - or choose Refactor > Refactor This… - and choose Surround With ▸ if ... Select ... |
| Chapter 3: a three-way test, folded | Step 4: A three-way test: Surround With ▸ if … else | Put the caret on the It is warm print, right-click - or choose Refactor > Refactor This… - and choose Surround With ▸ if ... else. The EK9 IDE once this is done: Put the caret on the It is warm print, right-click - or choose Refactor > Refactor This… - and choose Surround With ▸ if .. Select the ... |
| Chapter 3: a three-way test, folded | Step 5: Run it | Choose Run > Run Program… The EK9 IDE once this is done: Choose Run > Run Program… Type 30 into Arguments (space-separated), then choose Run. The EK9 IDE just before choosing Run: Type 30 into Arguments (space-separated), then choose Run It is warm - 30 is above warm. A cooler 5 would print Bring ... |
| Chapter 3: a three-way test, folded | The result | Weather.ek9 now reads exactly as chapter 3 of Getting Started with EK9 shows it: a jacket test, and a three-way warm / cold / mild test with named marks instead of bare numbers. Surround With ▸ if and ▸ if … else folded the plain prints under their heads; you typed the conditions and the else if ... |
| Chapter 3: a three-way test, folded | Where this lesson comes from | For AI assistants - the MCP tool ek9_add_program, ek9_surround_with. |
| Chapter 3: a switch, folded | Chapter 3: a switch, folded | Chapter 3's DayKind picks a word for a day number with switch: days 1 to 5 are Weekday, 6 and 7 Weekend, anything else is not a day. This lesson writes the Weekday print first, plain, then lets Surround With ▸ switch fold it into a switch - the case, the default and the indentation arrive with ... |
| Chapter 3: a switch, folded | Step 1: A program with a parameter | Choose Code > New Construct > Program… The EK9 IDE once this is done: Choose Code > New Construct > Program… DayKind is the program's name. Add one parameter, day of type Integer. Choose Preview. The EK9 IDE just before choosing Preview: DayKind is the program's name The preview shows DayKind ... |
| Chapter 3: a switch, folded | Step 2: A plain start | Select the stub, from require day? down to its //AI line, and type the plain start: a Stdout and the one Weekday print. Saves when typed. The EK9 IDE once this is done: Select the stub, from require day? down to its //AI line, and type the plain start |
| Chapter 3: a switch, folded | Step 3: Fold it under a switch | Put the caret on the Weekday print, right-click - or choose Refactor > Refactor This… - and choose Surround With ▸ switch. The EK9 IDE once this is done: Put the caret on the Weekday print, right-click - or choose Refactor > Refactor This… - and choose Surround With ▸ switch Select the stub, from ... |
| Chapter 3: a switch, folded | Step 4: The other cases | Select the Weekday print and below it type the second case: 6 and 7, each its own Weekend. Saves when typed. The EK9 IDE once this is done: Select the Weekday print and below it type the second case Select the default's stub, from defaultComplete <- Boolean(true) down to its //AI line, and type ... |
| Chapter 3: a switch, folded | Step 5: Run it | Choose Run > Run Program… The EK9 IDE once this is done: Choose Run > Run Program… Type 3 into Arguments (space-separated), then choose Run. The EK9 IDE just before choosing Run: Type 3 into Arguments (space-separated), then choose Run Weekday - day 3 is in the first case's list; 6 or 7 would ... |
| Chapter 3: a switch, folded | The result | DayKind.ek9 now reads exactly as chapter 3 of Getting Started with EK9 shows it: a switch with one case listing five days, one listing two, and a default - no fall-through, since each case is its own block. Surround With ▸ switch folded the plain print under the switch head and gave it a default ... |
| Chapter 3: a switch, folded | Where this lesson comes from | For AI assistants - the MCP tool ek9_add_program, ek9_surround_with. |
| Chapter 3: a switch of comparisons, folded | Chapter 3: a switch of comparisons, folded | Chapter 3's Grade turns a score into a word with switch: below the pass mark is Fail, below the merit mark Pass, below the distinction mark Merit, and the rest Distinction. This lesson writes the Fail print and the three marks first, plain, then lets Surround With ▸ switch fold it into a switch. ... |
| Chapter 3: a switch of comparisons, folded | Step 1: A program with a parameter | Choose Code > New Construct > Program… The EK9 IDE once this is done: Choose Code > New Construct > Program… Grade is the program's name. Add one parameter, score of type Integer. Choose Preview. The EK9 IDE just before choosing Preview: Grade is the program's name The preview shows Grade with ... |
| Chapter 3: a switch of comparisons, folded | Step 2: A plain start | Select the stub, from require score? down to its //AI line, and type the plain start: a Stdout, the three marks, and the one Fail print. Saves when typed. The EK9 IDE once this is done: Select the stub, from require score? down to its //AI line, and type the plain start |
| Chapter 3: a switch of comparisons, folded | Step 3: Fold it under a switch | Put the caret on the Fail print, right-click - or choose Refactor > Refactor This… - and choose Surround With ▸ switch. The EK9 IDE once this is done: Put the caret on the Fail print, right-click - or choose Refactor > Refactor This… - and choose Surround With ▸ switch Select the stub, from ... |
| Chapter 3: a switch of comparisons, folded | Step 4: The other cases | Select the Fail print and below it type the two further cases, Pass below the merit mark and Merit below the distinction mark. Saves when typed. The EK9 IDE once this is done: Select the Fail print and below it type the two further cases, Pass below the merit mark and Merit below the distinction ... |
| Chapter 3: a switch of comparisons, folded | Step 5: Run it | Choose Run > Run Program… The EK9 IDE once this is done: Choose Run > Run Program… Type 70 into Arguments (space-separated), then choose Run. The EK9 IDE just before choosing Run: Type 70 into Arguments (space-separated), then choose Run Merit - 70 is not below the pass mark of 40 or the merit ... |
| Chapter 3: a switch of comparisons, folded | The result | Grade.ek9 now reads exactly as chapter 3 of Getting Started with EK9 shows it: a switch whose cases are comparisons, tried in order - the first one that holds wins - with a default for the rest. Surround With ▸ switch folded the plain Fail print under the switch head; you typed the subject, the ... |
| Chapter 3: a switch of comparisons, folded | Where this lesson comes from | For AI assistants - the MCP tool ek9_add_program, ek9_surround_with. |
| Chapter 3: three loops, folded | Chapter 3: three loops, folded | Chapter 3's Counting runs three loops: 1 to 10, 0 to 10 in twos, and 10 down to 0 in twos, each printing its counter. This lesson types the three prints first - each names a counter i that does not exist yet - and lets Surround With ▸ for range wrap each, with i as its loop variable. To play it ... |
| Chapter 3: three loops, folded | Step 1: The program | Choose Code > New Construct > Program… The EK9 IDE once this is done: Choose Code > New Construct > Program… Counting is the program's name. Choose Preview. The EK9 IDE just before choosing Preview: Counting is the program's name The preview shows Counting about to be written. Choose Apply. The ... |
| Chapter 3: three loops, folded | Step 2: Three plain prints | Select the stub, from ready <- true down to its //AI line, and type the three prints. Each uses i, which nothing declares yet - the file shows errors until the loops exist. Saves when typed. The EK9 IDE once this is done: Select the stub, from ready <- true down to its //AI line, and type the ... |
| Chapter 3: three loops, folded | Step 3: Count up: Surround With ▸ for range | Put the caret on the Value print, right-click - or choose Refactor > Refactor This… - and choose Surround With ▸ for range. The EK9 IDE once this is done: Put the caret on the Value print, right-click - or choose Refactor > Refactor This… - and choose Surround With ▸ for range Select the stub - ... |
| Chapter 3: three loops, folded | Step 4: Count by twos, and down | Put the caret on the Even print, right-click - or choose Refactor > Refactor This… - and choose Surround With ▸ for range. The EK9 IDE once this is done: Put the caret on the Even print, right-click - or choose Refactor > Refactor This… - and choose Surround With ▸ for range Select the ... |
| Chapter 3: three loops, folded | Step 5: Run it | Choose Run > Run Program… The EK9 IDE once this is done: Choose Run > Run Program… The project's only program is already chosen. Choose Run. Value [1] to Value [10], then Even [0] to Even [10] in twos, then Down [10] to Down [0] in twos - each loop its own i. Choose Close. The EK9 IDE just before ... |
| Chapter 3: three loops, folded | The result | Counting.ek9 now reads exactly as chapter 3 of Getting Started with EK9 shows it: three for loops - up by one, up by two, down by two - each printing its own i. Surround With ▸ for range wrote the loop head with i already named, so the body that mentions i fell into place; you typed each range ... |
| Chapter 3: three loops, folded | Where this lesson comes from | For AI assistants - the MCP tool ek9_add_program, ek9_surround_with. |
| Chapter 3: a loop, reshaped | Chapter 3: a loop, reshaped | Chapter 3 meets repetition with Countdown: print 5, 4, 3, 2, 1, then Lift off. Rather than type the loop straight away, this lesson writes a plain version first - print the count once, the way chapter 3 itself starts - and then uses Surround With to fold the repeating part under a while head, the ... |
| Chapter 3: a loop, reshaped | Step 1: The program | Choose Code > New Construct > Program… The EK9 IDE once this is done: Choose Code > New Construct > Program… Countdown is the program's name. Choose Preview. The EK9 IDE just before choosing Preview: Countdown is the program's name The preview shows Countdown about to be written. Choose Apply. ... |
| Chapter 3: a loop, reshaped | Step 2: A plain start | Select the stub, from ready <- true down to its //AI line, and type the plain version: a Stdout, countdown starting at 5, one print, then Lift off - said once, not yet repeated. Saves when typed. The EK9 IDE once this is done: Select the stub, from ready <- true down to its //AI line, and type ... |
| Chapter 3: a loop, reshaped | Step 3: Loop it with Surround With | Put the caret on the countdown print, right-click - or choose Refactor > Refactor This… - and choose Surround With ▸ while. The EK9 IDE once this is done: Put the caret on the countdown print, right-click - or choose Refactor > Refactor This… - and choose Surround With ▸ while Select the stub, ... |
| Chapter 3: a loop, reshaped | Step 4: Run it | Choose Run > Run Program… The EK9 IDE once this is done: Choose Run > Run Program… The project's only program is already chosen. Choose Run. 5... then 4... 3... 2... 1... then Lift off - the loop ran while countdown was still above zero, and stopped the moment it was not. Choose Close. The EK9 ... |
| Chapter 3: a loop, reshaped | The result | Countdown.ek9 now reads exactly as chapter 3 of Getting Started with EK9 shows it: a program that counts down and stops. The plain version you typed first printed the count once; Surround With folded it under a loop head, re-indenting it for you, and the condition you typed over its placeholder ... |
| Chapter 3: a loop, reshaped | Where this lesson comes from | For AI assistants - the MCP tool ek9_new_construct, ek9_surround_with. |
| Chapter 3: do ... while, typed | Chapter 3: do ... while, typed | Chapter 3's Countup uses do ... while: the block runs once, then again while the test holds. Surround With has no do ... while, so the IDE writes only the program's shell, its parameter included, and you type the loop. To play it in the IDE: Help > Lessons > Getting Started with EK9…, or ek9 -ide ... |
| Chapter 3: do ... while, typed | Step 1: The program's shell | Choose Code > New Construct > Program… The EK9 IDE once this is done: Choose Code > New Construct > Program… Countup is the program's name. Add one parameter, stopAt of type Integer. Choose Preview. The EK9 IDE just before choosing Preview: Countup is the program's name The preview shows Countup ... |
| Chapter 3: do ... while, typed | Step 2: The body, typed | Select the stub, from require stopAt? down to its //AI line, and type the body exactly as the chapter shows it. Saves when typed. The EK9 IDE once this is done: Select the stub, from require stopAt? down to its //AI line, and type the body exactly as the chapter shows it |
| Chapter 3: do ... while, typed | Step 3: Run it | Choose Run > Run Program… The EK9 IDE once this is done: Choose Run > Run Program… Type 3 into Arguments (space-separated), then choose Run. The EK9 IDE just before choosing Run: Type 3 into Arguments (space-separated), then choose Run 1, 2, 3 - the block ran once before the test was ever asked, ... |
| Chapter 3: do ... while, typed | The result | Countup.ek9 now reads exactly as chapter 3 of Getting Started with EK9 shows it: a loop that always runs at least once. Surround With offers if, try, for range, while and switch; do ... while is typed. The EK9 IDE when the lesson has finished |
| Chapter 3: do ... while, typed | Where this lesson comes from | For AI assistants - the MCP tool ek9_add_program. |
| Chapter 4: three pure functions, built | Chapter 4: three pure functions, built | Chapter 4's Functions builds three pure functions - one parameter, two parameters, and one that calls the others - and a program that prints what each gives. The IDE writes every function's signature, purity ticked in the dialog, and the program's shell; you type the answers and the comments. To ... |
| Chapter 4: three pure functions, built | Step 1: square — a pure function | Choose Code > New Construct > Function… The EK9 IDE once this is done: Choose Code > New Construct > Function… square is the function's name. Add one parameter, n of type Integer, set Returns to Integer and tick pure. Choose Preview. The EK9 IDE just before choosing Preview: square is the ... |
| Chapter 4: three pure functions, built | Step 2: add — a pure function | Choose Code > New Construct > Function… The EK9 IDE once this is done: Choose Code > New Construct > Function… add is the function's name. Add the parameters a of type Integer and b of type Integer, set Returns to Integer and tick pure. Choose Preview. The EK9 IDE just before choosing Preview: ... |
| Chapter 4: three pure functions, built | Step 3: sumOfSquares — a pure function | Choose Code > New Construct > Function… The EK9 IDE once this is done: Choose Code > New Construct > Function… sumOfSquares is the function's name. Add the parameters a of type Integer and b of type Integer, set Returns to Integer and tick pure. Choose Preview. The EK9 IDE just before choosing ... |
| Chapter 4: three pure functions, built | Step 4: The program | Choose Code > New Construct > Program… The EK9 IDE once this is done: Choose Code > New Construct > Program… Demo is the program's name. Add one parameter, n of type Integer. Choose Preview. The EK9 IDE just before choosing Preview: Demo is the program's name The preview shows Demo about to be ... |
| Chapter 4: three pure functions, built | Step 5: Run it | Choose Run > Run Program… The EK9 IDE once this is done: Choose Run > Run Program… Type 5 into Arguments (space-separated), then choose Run. The EK9 IDE just before choosing Run: Type 5 into Arguments (space-separated), then choose Run square of 5 is 25, 5 + 4 is 9, sum of squares of 5 and 3 is ... |
| Chapter 4: three pure functions, built | The result | Functions.ek9 now reads exactly as chapter 4 of Getting Started with EK9 shows it: square, add and sumOfSquares, each pure, the last calling the first two. The signatures were the tool's; the answers are yours. The EK9 IDE when the lesson has finished |
| Chapter 4: three pure functions, built | Where this lesson comes from | For AI assistants - the MCP tool ek9_new_construct, ek9_add_program. |
| Chapter 4: a return settled by an if, built | Chapter 4: a return settled by an if, built | Chapter 4's describe turns a Boolean into the word known or unknown. Its return starts as an empty String and the body settles it - so the body is an if with an else. The IDE writes the signature and the if … else head; you type the return and the words. To play it in the IDE: Help > Lessons > ... |
| Chapter 4: a return settled by an if, built | Step 1: A function that returns a String | Choose Code > New Construct > Function… The EK9 IDE once this is done: Choose Code > New Construct > Function… describe is the function's name. Add one parameter, known of type Boolean, and set Returns to String. Choose Preview. The EK9 IDE just before choosing Preview: describe is the function's ... |
| Chapter 4: a return settled by an if, built | Step 2: Settle the return: Surround With ▸ if … else | Put the caret on the result: "known" line, right-click - or choose Refactor > Refactor This… - and choose Surround With ▸ if ... else. The EK9 IDE once this is done: Put the caret on the result Select the stub, from surroundGuard <- Boolean(true) down to its //AI line, and type the real test: if ... |
| Chapter 4: a return settled by an if, built | Step 3: The program | Choose Code > New Construct > Program… The EK9 IDE once this is done: Choose Code > New Construct > Program… Show is the program's name. Choose Preview. The EK9 IDE just before choosing Preview: Show is the program's name The preview shows Show about to be written. Choose Apply. The EK9 IDE just ... |
| Chapter 4: a return settled by an if, built | Step 4: Run it | Choose Run > Run Program… The EK9 IDE once this is done: Choose Run > Run Program… The project's only program is already chosen. Choose Run. known, then unknown - describe(true) takes the if, describe(false) the else. Choose Close. The EK9 IDE just before choosing Close: known, then unknown - ... |
| Chapter 4: a return settled by an if, built | The result | Describe.ek9 now reads exactly as chapter 4 of Getting Started with EK9 shows it: a return that starts as an empty String and is given its real value by whichever branch runs. The signature was the tool's, Surround With ▸ if … else wrote the branch head and its else; you typed the return's name, ... |
| Chapter 4: a return settled by an if, built | Where this lesson comes from | For AI assistants - the MCP tool ek9_new_construct, ek9_surround_with, ek9_add_program. |
| Chapter 4: a function, built | Chapter 4: a function, built | Chapter 4 meets a function with nothing to return: announce, which prints a greeting and hands nothing back, and the program that calls it twice. Leaving out a function's '<-' line is how EK9 says "returns nothing" - there is no separate keyword for it. The IDE's own tools make the structure - ... |
| Chapter 4: a function, built | Step 1: A function | Choose Code > New Construct > Function… The EK9 IDE once this is done: Choose Code > New Construct > Function… announce is the function's name. doSomething hints that a function's name should say what it does. Add one parameter, name of type String. Choose Preview. The EK9 IDE just before ... |
| Chapter 4: a function, built | Step 2: Its comment, and its logic | Select the announce() line, and above it type a blank line and //No '<-' line: this function does its work and returns nothing. - why there is no '<-' line. Saves when typed. The EK9 IDE once this is done: Select the announce() line, and above it type a blank line and //No '<-' line Select the ... |
| Chapter 4: a function, built | Step 3: The program | Choose Code > New Construct > Program… The EK9 IDE once this is done: Choose Code > New Construct > Program… Demo is the program's name. Choose Preview. The EK9 IDE just before choosing Preview: Demo is the program's name The preview shows Demo about to be written. Choose Apply. The EK9 IDE just ... |
| Chapter 4: a function, built | Step 4: Run it | Choose Run > Run Program… The EK9 IDE once this is done: Choose Run > Run Program… The project's only program is already chosen. Choose Run. Hello, Ada then Hello, Grace - announce ran once for each name Demo called it with. Choose Close. The EK9 IDE just before choosing Close: Hello, Ada then ... |
| Chapter 4: a function, built | The result | Announce.ek9 now reads exactly as chapter 4 of Getting Started with EK9 shows it: a function with no return value - leaving out the '<-' line says it - built by the tools, its logic and the teaching line above it typed. The same two tools - ek9_new_construct and ek9_add_program - are what an AI ... |
| Chapter 4: a function, built | Where this lesson comes from | For AI assistants - the MCP tool ek9_new_construct, ek9_add_program. |
| Chapter 4: a precondition, built | Chapter 4: a precondition, built | Chapter 4's Halve states a precondition: halve works only on an n that is set. The IDE writes the function's signature - and the stub already carries a require for each parameter - so what you type is the return's name and the work. To play it in the IDE: Help > Lessons > Getting Started with ... |
| Chapter 4: a precondition, built | Step 1: halve — a pure function | Choose Code > New Construct > Function… The EK9 IDE once this is done: Choose Code > New Construct > Function… halve is the function's name. Add one parameter, n of type Integer, set Returns to Integer and tick pure. Choose Preview. The EK9 IDE just before choosing Preview: halve is the ... |
| Chapter 4: a precondition, built | Step 2: The program | Choose Code > New Construct > Program… The EK9 IDE once this is done: Choose Code > New Construct > Program… Demo is the program's name. Add one parameter, n of type Integer. Choose Preview. The EK9 IDE just before choosing Preview: Demo is the program's name The preview shows Demo about to be ... |
| Chapter 4: a precondition, built | Step 3: Run it | Choose Run > Run Program… The EK9 IDE once this is done: Choose Run > Run Program… Type 10 into Arguments (space-separated), then choose Run. The EK9 IDE just before choosing Run: Type 10 into Arguments (space-separated), then choose Run half of 10 is 5. Choose Close. The EK9 IDE just before ... |
| Chapter 4: a precondition, built | The result | Halve.ek9 now reads exactly as chapter 4 of Getting Started with EK9 shows it: a pure function whose require n? is checked before result is assigned. The EK9 IDE when the lesson has finished |
| Chapter 4: a precondition, built | Where this lesson comes from | For AI assistants - the MCP tool ek9_new_construct, ek9_add_program. |
| Chapter 4: a precondition that fails, built | Chapter 4: a precondition that fails, built | Chapter 4 ends Halve with a bug on purpose: a caller that hands halve an unset Integer. It compiles - the compiler cannot see the value is unset - and fails when it runs, at the require. The IDE writes the function's signature and the program's shell; you type the function's work and the buggy ... |
| Chapter 4: a precondition that fails, built | Step 1: halve — a pure function | Choose Code > New Construct > Function… The EK9 IDE once this is done: Choose Code > New Construct > Function… halve is the function's name. Add one parameter, n of type Integer, set Returns to Integer and tick pure. Choose Preview. The EK9 IDE just before choosing Preview: halve is the ... |
| Chapter 4: a precondition that fails, built | Step 2: The program | Choose Code > New Construct > Program… The EK9 IDE once this is done: Choose Code > New Construct > Program… Broken is the program's name. Choose Preview. The EK9 IDE just before choosing Preview: Broken is the program's name The preview shows Broken about to be written. Choose Apply. The EK9 IDE ... |
| Chapter 4: a precondition that fails, built | Step 3: Run it | Choose Run > Run Program… The EK9 IDE once this is done: Choose Run > Run Program… The project's only program is already chosen. Choose Run. The run fails with a Panic - Requirement failed: n? - and no half is printed: the precondition caught the unset Integer. Choose Close. The EK9 IDE just ... |
| Chapter 4: a precondition that fails, built | The result | HalveNothing.ek9 now reads exactly as chapter 4 of Getting Started with EK9 shows it, and the run stopped at the require: a precondition is a promise checked when the function is called, not when it is written. The EK9 IDE when the lesson has finished |
| Chapter 4: a precondition that fails, built | Where this lesson comes from | For AI assistants - the MCP tool ek9_new_construct, ek9_add_program. |
| Chapter 5: tests, built | Chapter 5: tests, built | Chapter 5 asks two questions: how do you know a function gives the right answer, and how do you run one on its own when all you have run so far is a program? The answer to both is a test: square and cube, two pure functions, and the @Test programs that check them, kept in a dev/ directory of ... |
| Chapter 5: tests, built | Step 1: square — a pure function | Choose Code > New Construct > Function… The EK9 IDE once this is done: Choose Code > New Construct > Function… square is the function's name. Add one parameter, n of type Integer, set Returns to Integer, and tick pure. Choose Preview. The EK9 IDE just before choosing Preview: square is the ... |
| Chapter 5: tests, built | Step 2: cube — a pure function | Choose Code > New Construct > Function… The EK9 IDE once this is done: Choose Code > New Construct > Function… cube is the function's name. Add one parameter, n of type Integer, set Returns to Integer, and tick pure, as square's were. Choose Preview. The EK9 IDE just before choosing Preview: cube ... |
| Chapter 5: tests, built | Step 3: Where tests live | Open dev/tests.ek9 - already there, with just its own module line. Test code goes in a directory named dev/, kept apart from the code you ship. The EK9 IDE once this is done: Open dev/tests.ek9 - already there, with just its own module line Select the module line, and below it type a references ... |
| Chapter 5: tests, built | Step 4: SquareTest | Choose Code > New Construct > Test… The EK9 IDE once this is done: Choose Code > New Construct > Test… SquareTest is the test's name. A test IS a program, so it is named the same way: no application, no parameters, nothing injected. Choose Preview. The EK9 IDE just before choosing Preview: ... |
| Chapter 5: tests, built | Step 5: CubeTest | Choose Code > New Construct > Test… The EK9 IDE once this is done: Choose Code > New Construct > Test… CubeTest is the test's name, as plain as SquareTest's. Choose Preview. The EK9 IDE just before choosing Preview: CubeTest is the test's name, as plain as SquareTest's The preview shows CubeTest ... |
| Chapter 5: tests, built | Step 6: Run the tests | Run ▸ Run Tests (⌘T) runs every @Test in the project - SquareTest and CubeTest both - and reports pass or fail, the same as ek9 -t at the command line. Choose Run Tests. The EK9 IDE once this is done: Run ▸ Run Tests (⌘T) runs every @Test in the project - SquareTest and CubeTest both - and ... |
| Chapter 5: tests, built | Step 7: Generate Edge-Case Tests | Choose Code > Generate > Edge-Case Tests (whole file)… The EK9 IDE once this is done: Choose Code > Generate > Edge-Case Tests (whole file)… The dialog already has sensible defaults - the output routed to dev/, 200 candidates, a random seed. Choose Generate. However many of the 200 candidates ... |
| Chapter 5: tests, built | The result | maths.ek9 and dev/tests.ek9 now read exactly as chapter 5 of Getting Started with EK9 shows them: two pure functions and the @Test programs that check them, each tool-built, each real claim typed. Run Tests found both passing and shaded every line they covered; Generate Edge-Case Tests then tried ... |
| Chapter 5: tests, built | Where this lesson comes from | For AI assistants - the MCP tool ek9_new_construct, ek9_add_program, ek9_run_tests, ek9_generate_edge_case_tests. |
| Chapter 7: money, typed | Chapter 7: money, typed | Chapter 7's Receipt adds up a shopping basket in pounds: prices written with the #GBP suffix, multiplied by whole quantities, summed and printed in en_GB format. The IDE writes the program's shell; the amounts are yours to type. To play it in the IDE: Help > Lessons > Getting Started with EK9…, ... |
| Chapter 7: money, typed | Step 1: The program's shell | Choose Code > New Construct > Program… The EK9 IDE once this is done: Choose Code > New Construct > Program… Receipt is the program's name. Choose Preview. The EK9 IDE just before choosing Preview: Receipt is the program's name The preview shows Receipt about to be written. Choose Apply. The EK9 ... |
| Chapter 7: money, typed | Step 2: The body, typed | Select the stub, from ready <- true down to its //AI line, and type the body exactly as the chapter shows it. Saves when typed. The EK9 IDE once this is done: Select the stub, from ready <- true down to its //AI line, and type the body exactly as the chapter shows it |
| Chapter 7: money, typed | Step 3: Run it | Choose Run > Run Program… The EK9 IDE once this is done: Choose Run > Run Program… The project's only program is already chosen. Choose Run. Apples x6 £2.10, Bread x2 £2.20, Milk x1 £0.85, Total £5.15. Choose Close. The EK9 IDE just before choosing Close: Apples x6 £2.10, Bread x2 £2.20, Milk x1 ... |
| Chapter 7: money, typed | The result | Receipt.ek9 now reads exactly as chapter 7 of Getting Started with EK9 shows it: Money times an Integer is Money, Money plus Money is Money, and the Locale formats each as pounds. The EK9 IDE when the lesson has finished |
| Chapter 7: money, typed | Where this lesson comes from | For AI assistants - the MCP tool ek9_add_program. |
| Chapter 7: dates, typed | Chapter 7: dates, typed | Chapter 7 does arithmetic on dates: a start date, a notice period of one month and fifteen days, the due date they give, and the span between. The values are literals you type; the IDE writes the program's shell. To play it in the IDE: Help > Lessons > Getting Started with EK9…, or ek9 -ide ... |
| Chapter 7: dates, typed | Step 1: The program's shell | Choose Code > New Construct > Program… The EK9 IDE once this is done: Choose Code > New Construct > Program… Deadline is the program's name. Choose Preview. The EK9 IDE just before choosing Preview: Deadline is the program's name The preview shows Deadline about to be written. Choose Apply. The ... |
| Chapter 7: dates, typed | Step 2: The body, typed | Select the stub, from ready <- true down to its //AI line, and type the body exactly as the chapter shows it. Saves when typed. The EK9 IDE once this is done: Select the stub, from ready <- true down to its //AI line, and type the body exactly as the chapter shows it |
| Chapter 7: dates, typed | Step 3: Run it | Choose Run > Run Program… The EK9 IDE once this is done: Choose Run > Run Program… The project's only program is already chosen. Choose Run. Start: 15 Jan 2026, Due: 2 Mar 2026, Notice period is P1M15D, Due falls on day-of-week 1. Choose Close. The EK9 IDE just before choosing Close: Start |
| Chapter 7: dates, typed | The result | Deadline.ek9 now reads exactly as chapter 7 of Getting Started with EK9 shows it: a Date plus a Duration gives a Date, and a Date minus a Date gives a Duration - all formatted for en_GB. The EK9 IDE when the lesson has finished |
| Chapter 7: dates, typed | Where this lesson comes from | For AI assistants - the MCP tool ek9_add_program. |
| Chapter 7: asking about a type | Chapter 7: asking about a type | Chapter 7 gives real-world values real types: Money, dates and durations, and Dimension - a measurement with a unit, 20cm or 3px. Measures doubles one, widens it by another of the same unit, then adds one of a DIFFERENT unit - centimetres and pixels do not mix, so EK9 gives back not a wrong ... |
| Chapter 7: asking about a type | Step 1: The program | Choose Code > New Construct > Program… The EK9 IDE once this is done: Choose Code > New Construct > Program… Measures is the program's name. Choose Preview. The EK9 IDE just before choosing Preview: Measures is the program's name The preview shows Measures about to be written. Choose Apply. The ... |
| Chapter 7: asking about a type | Step 2: Ask: /h Dimension | Type /h Dimension into the input bar above the editor and choose -> to send it - the same /h this chapter's own types answer to at a terminal. The EK9 IDE once this is done: Type /h Dimension into the input bar above the editor and choose -> to send it - the same /h this chapter's own types ... |
| Chapter 7: asking about a type | Step 3: Ask: Effective API | Select width, on the line that declares it, then choose Analyse ▸ Effective API: cursor-anchored, the same way /h just answered from the input bar instead. The EK9 IDE once this is done: Select width, on the line that declares it, then choose Analyse ▸ Effective API The pane draws Dimension's own ... |
| Chapter 7: asking about a type | Step 4: Run it | Choose Run > Run Program… The EK9 IDE once this is done: Choose Run > Run Program… The project's only program is already chosen. Choose Run. 20.0cm, then 40.0cm doubled, then 25.0cm wider - then 20cm + 3px is set? reads false: centimetres and pixels do not mix. Choose Close. The EK9 IDE just ... |
| Chapter 7: asking about a type | The result | Measures.ek9 now reads exactly as chapter 7 of Getting Started with EK9 shows it: a Dimension doubled, widened by the same unit, and mixed with the wrong one - unset, never a wrong number. /h Dimension and Analyse ▸ Effective API then answered the same question about Dimension two ways - the Help ... |
| Chapter 7: asking about a type | Where this lesson comes from | For AI assistants - the MCP tool ek9_new_construct, ek9_add_program, ek9_help, ek9_query_effective_api. |
| Chapter 7: constants, built | Chapter 7: constants, built | Chapter 7's Constants declares four values at module level - an Integer, a String, a Money and a Time - for the whole program to share. New Construct ▸ Constant… writes each one from its literal; the program that prints them is typed. To play it in the IDE: Help > Lessons > Getting Started with ... |
| Chapter 7: constants, built | Step 1: Constants | Choose Code > New Construct > Constant… The EK9 IDE once this is done: Choose Code > New Construct > Constant… maxRetries is the constant's name and 3 its value - a literal in the Value field, from which the type is inferred. Type both and choose Preview. The EK9 IDE just before choosing Preview: ... |
| Chapter 7: constants, built | Step 2: The program | Choose Code > New Construct > Program… The EK9 IDE once this is done: Choose Code > New Construct > Program… Show is the program's name. Choose Preview. The EK9 IDE just before choosing Preview: Show is the program's name The preview shows Show about to be written. Choose Apply. The EK9 IDE just ... |
| Chapter 7: constants, built | Step 3: Run it | Choose Run > Run Program… The EK9 IDE once this is done: Choose Run > Run Program… The project's only program is already chosen. Choose Run. retries allowed: 3, then Hello — doors open at 09:00:00, entry 12.00#GBP. Choose Close. The EK9 IDE just before choosing Close: retries allowed |
| Chapter 7: constants, built | The result | Constants.ek9 now reads exactly as chapter 7 of Getting Started with EK9 shows it: four constants whose types are inferred from their literals, used by a program in the same module. The EK9 IDE when the lesson has finished |
| Chapter 7: constants, built | Where this lesson comes from | For AI assistants - the MCP tool ek9_new_construct, ek9_add_program. |
| Chapter 7: a constant that is copied, built | Chapter 7: a constant that is copied, built | Chapter 7's ConstantCopy shows what a constant promises: handed to a function that changes its parameter, an ordinary variable really changes, but a constant stays as it was - what the function changes is a copy. The IDE writes the constant, the function's signature and the program's shell; you ... |
| Chapter 7: a constant that is copied, built | Step 1: A constant | Choose Code > New Construct > Constant… The EK9 IDE once this is done: Choose Code > New Construct > Constant… startingLives is the constant's name and 3 its value - a literal in the Value field, from which the type is inferred. Type both and choose Preview. The EK9 IDE just before choosing ... |
| Chapter 7: a constant that is copied, built | Step 2: useOne — a function | Choose Code > New Construct > Function… The EK9 IDE once this is done: Choose Code > New Construct > Function… useOne is the function's name. Add one parameter, lives of type Integer. Choose Preview. The EK9 IDE just before choosing Preview: useOne is the function's name The preview shows useOne ... |
| Chapter 7: a constant that is copied, built | Step 3: The program | Choose Code > New Construct > Program… The EK9 IDE once this is done: Choose Code > New Construct > Program… Show is the program's name. Choose Preview. The EK9 IDE just before choosing Preview: Show is the program's name The preview shows Show about to be written. Choose Apply. The EK9 IDE just ... |
| Chapter 7: a constant that is copied, built | Step 4: Run it | Choose Run > Run Program… The EK9 IDE once this is done: Choose Run > Run Program… The project's only program is already chosen. Choose Run. my variable is now: 2, and the constant is still: 3 - the constant was copied, so useOne changed the copy. Choose Close. The EK9 IDE just before choosing ... |
| Chapter 7: a constant that is copied, built | The result | ConstantCopy.ek9 now reads exactly as chapter 7 of Getting Started with EK9 shows it: useOne takes a life off the variable it is handed, and off nothing at all when handed the constant. The EK9 IDE when the lesson has finished |
| Chapter 7: a constant that is copied, built | Where this lesson comes from | For AI assistants - the MCP tool ek9_new_construct, ek9_add_program. |
| Chapter 8: greeting in three languages, built | Chapter 8: greeting in three languages, built | Chapter 8 keeps translations INSIDE the language, where the compiler can see them. Greeting is a text type with one message, welcome, said in English, French and German; the program asks for each by its locale. The IDE's tools build the structure - the program, then Greeting itself, created the ... |
| Chapter 8: greeting in three languages, built | Step 1: The program, hard-coding English | Choose Code > New Construct > Program… The EK9 IDE once this is done: Choose Code > New Construct > Program… Greet is the program's name. Choose Preview. The EK9 IDE just before choosing Preview: Greet is the program's name The preview shows Greet about to be written. Choose Apply. The EK9 IDE ... |
| Chapter 8: greeting in three languages, built | Step 2: welcome - the real message | Select the hard-coded greeting, right-click it and choose Localisation ▸ Extract to Localized Text…. Name the method welcome; type Greeting as the text type - new, so the dialog offers its first locale (en); name english as the text variable - not declared yet, the tool declares it for you. The ... |
| Chapter 8: greeting in three languages, built | Step 3: Adding French | Choose Code > Localisation > Add Locale… The EK9 IDE once this is done: Choose Code > Localisation > Add Locale… Adding French, cloned from en - a stub, //AI: translate the message, waits where the real words go. Type fr as the new locale - en is already chosen to clone from, the only locale so ... |
| Chapter 8: greeting in three languages, built | Step 4: Adding German | Choose Code > Localisation > Add Locale… The EK9 IDE once this is done: Choose Code > Localisation > Add Locale… Adding German, cloned from en the same way. Type de as the new locale - en is already chosen to clone from, the only locale so far. Choose Preview. The EK9 IDE just before choosing ... |
| Chapter 8: greeting in three languages, built | Step 5: Greeting in every language | Three languages now exist; Greet still only greets in English. Select the english line and type the French and German greetings after it, each from its own accessor - Greeting("fr") and Greeting("de"). The EK9 IDE once this is done: Three languages now exist; Greet still only greets in English |
| Chapter 8: greeting in three languages, built | Step 6: Run it | Choose Run > Run Program… The EK9 IDE once this is done: Choose Run > Run Program… The project's only program is already chosen. Choose Run. Ada is welcomed three times, once per language. Choose Close. The EK9 IDE just before choosing Close: Ada is welcomed three times, once per language |
| Chapter 8: greeting in three languages, built | The result | Greetings.ek9 now reads exactly as chapter 8 of Getting Started with EK9 shows it: a Greeting text type with one welcome message in three languages, and a program that asks for each language by name. The tools wrote the structure - the program, the type, the english accessor, two more locales - ... |
| Chapter 8: greeting in three languages, built | Where this lesson comes from | For AI assistants - the MCP tool ek9_add_program, ek9_extract_to_localized_text, ek9_edit_localized_text. |
| Chapter 8: choosing a language, built | Chapter 8: choosing a language, built | Greetings said a language by name. Real programs let the person choose: Greet takes the language as an argument, asks for the Greeting in that language, and keeps the answer only if the language really exists - a language nobody wrote text for falls back to English, instead of failing. The IDE's ... |
| Chapter 8: choosing a language, built | Step 1: The program, hard-coding English | Choose Code > New Construct > Program… The EK9 IDE once this is done: Choose Code > New Construct > Program… Greet is the program's name. EK9 parses the text on the command line into its parameter. Add one parameter, requestedLang of type String. Choose Preview. The EK9 IDE just before choosing ... |
| Chapter 8: choosing a language, built | Step 2: welcome - the real message | Select the hard-coded greeting, right-click it and choose Localisation ▸ Extract to Localized Text…. Name the method welcome; type Greeting as the text type - new, so the dialog offers its first locale (en); name greeter as the text variable. The Parameters table shows me - retype it to name, ... |
| Chapter 8: choosing a language, built | Step 3: Adding French | Choose Code > Localisation > Add Locale… The EK9 IDE once this is done: Choose Code > Localisation > Add Locale… Adding French, cloned from en - a stub waits where the real words go. Type fr as the new locale - en is already chosen to clone from, the only locale so far. Choose Preview. The EK9 ... |
| Chapter 8: choosing a language, built | Step 4: Adding German | Choose Code > Localisation > Add Locale… The EK9 IDE once this is done: Choose Code > Localisation > Add Locale… Adding German, cloned from en the same way. Type de as the new locale - en is already chosen to clone from, the only locale so far. Choose Preview. The EK9 IDE just before choosing ... |
| Chapter 8: choosing a language, built | Step 5: Let the person choose | greeter is still always English. Select the greeter line and type the choice: chosen asks for the requested language, and greeter keeps chosen only if it is set (chosen?), else Greeting("en"). The EK9 IDE once this is done: greeter is still always English |
| Chapter 8: choosing a language, built | Step 6: Run it, with a language | Choose Run > Run Program… The EK9 IDE once this is done: Choose Run > Run Program… Type fr into Arguments (space-separated), then choose Run. The EK9 IDE just before choosing Run: Type fr into Arguments (space-separated), then choose Run Ada is greeted in French - Bonjour, Ada ! Choose Close. The ... |
| Chapter 8: choosing a language, built | The result | Greet.ek9 now reads exactly as chapter 8 of Getting Started with EK9 shows it: the language comes from the command line, Greeting(requestedLang) asks for it, and chosen? keeps it only when a text type really speaks it - otherwise the greeting falls back to English. The tools wrote the program, ... |
| Chapter 8: choosing a language, built | Where this lesson comes from | For AI assistants - the MCP tool ek9_add_program, ek9_extract_to_localized_text, ek9_edit_localized_text. |
| Chapter 8: a language from the environment, built | Chapter 8: a language from the environment, built | A program can learn its language from the machine it runs on. EnvGreet reads the APP_LANG environment variable, asks for the Greeting in that language, and keeps the answer only if the language exists - an unset variable, or a language nobody wrote, falls back to English. The IDE's tools build ... |
| Chapter 8: a language from the environment, built | Step 1: The program, hard-coding English | Choose Code > New Construct > Program… The EK9 IDE once this is done: Choose Code > New Construct > Program… EnvGreet is the program's name. Choose Preview. The EK9 IDE just before choosing Preview: EnvGreet is the program's name The preview shows EnvGreet about to be written. Choose Apply. The ... |
| Chapter 8: a language from the environment, built | Step 2: welcome - the real message | Select the hard-coded greeting, right-click it and choose Localisation ▸ Extract to Localized Text…. Name the method welcome; type Greeting as the text type - new, so the dialog offers its first locale (en); name greeter as the text variable. The Parameters table shows me - retype it to name, ... |
| Chapter 8: a language from the environment, built | Step 3: Adding French | Choose Code > Localisation > Add Locale… The EK9 IDE once this is done: Choose Code > Localisation > Add Locale… Adding French, cloned from en - a stub waits where the real words go. Type fr as the new locale - en is already chosen to clone from, the only locale so far. Choose Preview. The EK9 ... |
| Chapter 8: a language from the environment, built | Step 4: Adding German | Choose Code > Localisation > Add Locale… The EK9 IDE once this is done: Choose Code > Localisation > Add Locale… Adding German, cloned from en the same way. Type de as the new locale - en is already chosen to clone from, the only locale so far. Choose Preview. The EK9 IDE just before choosing ... |
| Chapter 8: a language from the environment, built | Step 5: Read the language from the environment | greeter is still always English. Select the greeter line and type the lookup: EnvVars().get("APP_LANG") is the requested language, chosen asks for it, and greeter keeps chosen only if it is set (chosen?), else Greeting("en"). The EK9 IDE once this is done: greeter is still always English |
| Chapter 8: a language from the environment, built | Step 6: Run it, APP_LANG not set | Choose Run > Run Program… The EK9 IDE once this is done: Choose Run > Run Program… The project's only program is already chosen. Choose Run. APP_LANG is not set, so chosen is unset and the greeting falls back to English: Hello, Ada! Choose Close. The EK9 IDE just before choosing Close: APP_LANG ... |
| Chapter 8: a language from the environment, built | Step 7: Run it, APP_LANG=fr | Choose Run > Configurations… The EK9 IDE once this is done: Choose Run > Configurations… Choose + New Configuration… - the project's program is already the one it will belong to. Name it In French, and into Environment type APP_LANG=fr - the one field with anywhere to put it. Choose Create. The ... |
| Chapter 8: a language from the environment, built | The result | EnvGreet.ek9 now reads exactly as chapter 8 of Getting Started with EK9 shows it: the language is read from the APP_LANG environment variable, so the same program greets in English when it is unset and in French when a run configuration sets it. The tools wrote the program, the Greeting type and ... |
| Chapter 8: a language from the environment, built | Where this lesson comes from | For AI assistants - the MCP tool ek9_add_program, ek9_extract_to_localized_text, ek9_edit_localized_text. |
| Chapter 8: a price and a date, localised | Chapter 8: a price and a date, localised | Translation is more than words: a price and a date are written differently in every country. In a text method the name locale is the locale being spoken, and locale.format and locale.mediumFormat write a Money or a Date its way. The IDE's tools build the program, the OrderText type (its Money and ... |
| Chapter 8: a price and a date, localised | Step 1: The program, with a total and a date | Choose Code > New Construct > Program… The EK9 IDE once this is done: Choose Code > New Construct > Program… Show is the program's name. Choose Preview. The EK9 IDE just before choosing Preview: Show is the program's name The preview shows Show about to be written. Choose Apply. The EK9 IDE just ... |
| Chapter 8: a price and a date, localised | Step 2: confirmation - the real message | Select the sentence, right-click it and choose Localisation ▸ Extract to Localized Text…. Name the method confirmation; type OrderText as the text type - new, so the dialog offers its first locale: en_GB; name order as the text variable. The Parameters table already shows total and arrival with ... |
| Chapter 8: a price and a date, localised | Step 3: Let the locale write the numbers | The English sentence prints the Money and the Date in their default form. Select it and retype it to ask locale to write each: locale.format(total) and locale.mediumFormat(arrival). Saves when typed. The EK9 IDE once this is done: The English sentence prints the Money and the Date in their ... |
| Chapter 8: a price and a date, localised | Step 4: Adding French (France) | Choose Code > Localisation > Add Locale… The EK9 IDE once this is done: Choose Code > Localisation > Add Locale… Adding French as France writes it, cloned from en_GB - a stub waits where the real words go. Type fr_FR as the new locale - en_GB is already chosen to clone from, the only locale so ... |
| Chapter 8: a price and a date, localised | Step 5: Adding German (Germany) | Choose Code > Localisation > Add Locale… The EK9 IDE once this is done: Choose Code > Localisation > Add Locale… Adding German as Germany writes it, cloned from en_GB the same way. Type de_DE as the new locale - en_GB is already chosen to clone from, the only locale so far. Choose Preview. The ... |
| Chapter 8: a price and a date, localised | Step 6: Every locale | Three locales now exist; Show still only prints the British one. Replace order <- OrderText("en_GB") with a loop over all three locales, and re-indent the println inside it. The EK9 IDE once this is done: Three locales now exist; Show still only prints the British one |
| Chapter 8: a price and a date, localised | Step 7: Run it | Choose Run > Run Program… The EK9 IDE once this is done: Choose Run > Run Program… The project's only program is already chosen. Choose Run. The same total and date, written three ways: €1,234.56 in Britain, 1 234,56 € in France and 1.234,56 € in Germany. Choose Close. The EK9 IDE just before ... |
| Chapter 8: a price and a date, localised | The result | Order.ek9 now reads exactly as chapter 8 of Getting Started with EK9 shows it: one OrderText message in three locales, each asking its own locale to write the Money and the Date - so the same total reads €1,234.56 in Britain and 1.234,56 € in Germany with no formatting code in the program. The ... |
| Chapter 8: a price and a date, localised | Where this lesson comes from | For AI assistants - the MCP tool ek9_add_program, ek9_extract_to_localized_text, ek9_edit_localized_text. |
| Chapter 8: a text type, built | Chapter 8: a text type, built | Chapter 8 is about keeping translations INSIDE the language, where the compiler can see them. Party is a text type speaking three languages for one birthday message; the IDE's own tools build its structure - the program, then Party itself (created the moment it is first needed), then a new locale ... |
| Chapter 8: a text type, built | Step 1: The program, hard-coding English | Choose Code > New Construct > Program… The EK9 IDE once this is done: Choose Code > New Construct > Program… Show is the program's name. Choose Preview. The EK9 IDE just before choosing Preview: Show is the program's name The preview shows Show about to be written. Choose Apply. The EK9 IDE just ... |
| Chapter 8: a text type, built | Step 2: announce - the real message | Select the hard-coded greeting, right-click it and choose Localisation ▸ Extract to Localized Text…. Name the method announce; type Party as the text type - new, so the dialog offers where to create it (this file, already filled in) and its first locale (en); name party as the text variable - not ... |
| Chapter 8: a text type, built | Step 3: Adding French | Choose Code > Localisation > Add Locale… The EK9 IDE once this is done: Choose Code > Localisation > Add Locale… Adding French, cloned from en - a stub, //AI: translate the message, waits where the real words go. Type fr as the new locale - en is already chosen to clone from, the only locale so ... |
| Chapter 8: a text type, built | Step 4: Adding German | Choose Code > Localisation > Add Locale… The EK9 IDE once this is done: Choose Code > Localisation > Add Locale… Adding German, cloned from en the same way. Type de as the new locale - en is already chosen to clone from, the only locale so far. Choose Preview. The EK9 IDE just before choosing ... |
| Chapter 8: a text type, built | Step 5: Every language | Three languages now exist; Show still only ever greets in English. Replace party <- Party("en") with a loop over all three, and re-indent the println inside it. The EK9 IDE once this is done: Three languages now exist; Show still only ever greets in English |
| Chapter 8: a text type, built | Step 6: Run it | Choose Run > Run Program… The EK9 IDE once this is done: Choose Run > Run Program… The project's only program is already chosen. Choose Run. Sam's birthday is announced three times, once per language. Choose Close. The EK9 IDE just before choosing Close: Sam's birthday is announced three times, ... |
| Chapter 8: a text type, built | The result | Birthday.ek9 now reads exactly as chapter 8 of Getting Started with EK9 shows it: a text type the tools built - including the new Party type and party's own declaration, both from one Extract to Localized Text call - with each locale's wording typed by hand, the one thing no tool can write. ... |
| Chapter 8: a text type, built | Where this lesson comes from | For AI assistants - the MCP tool ek9_add_program, ek9_extract_to_localized_text, ek9_edit_localized_text. |
| Chapter 9: collections, asked about | Chapter 9: collections, asked about | Chapter 9 meets EK9's two core collections: the List, an ordered sequence, and the Dict, a set of key to value pairs. Basket shops from a List against a Dict of prices - getOrDefault's own unset Money() tells a missing price apart from a free one, so the total stays honest and what is not stocked ... |
| Chapter 9: collections, asked about | Step 1: The program | Choose Code > New Construct > Program… The EK9 IDE once this is done: Choose Code > New Construct > Program… Basket is the program's name. Choose Preview. The EK9 IDE just before choosing Preview: Basket is the program's name The preview shows Basket about to be written. Choose Apply. The EK9 IDE ... |
| Chapter 9: collections, asked about | Step 2: Ask: /q 129 | Type /q 129 into the input bar above the editor and choose -> to send it - a direct lookup, by the question's own number, into the Answers tab. The EK9 IDE once this is done: Type /q 129 into the input bar above the editor and choose -> to send it - a direct lookup, by the question's own number, ... |
| Chapter 9: collections, asked about | Step 3: Read Effective API: List | Select basket, on the line that declares it, then choose Analyse ▸ Effective API: cursor-anchored, the same way chapter 7 read a Dimension and chapter 11 read a Result before them. The EK9 IDE once this is done: Select basket, on the line that declares it, then choose Analyse ▸ Effective API The ... |
| Chapter 9: collections, asked about | Step 4: Read Effective API: Dict | Select prices, on the line that declares it, then choose Analyse ▸ Effective API again - the same pane, a different type. The EK9 IDE once this is done: Select prices, on the line that declares it, then choose Analyse ▸ Effective API again - the same pane, a different type Dict of (String, ... |
| Chapter 9: collections, asked about | Step 5: Run it | Choose Run > Run Program… The EK9 IDE once this is done: Choose Run > Run Program… The project's only program is already chosen. Choose Run. Apples: £0.35, Bread: £1.10 and Milk: £0.85, Total: £2.30 - then Not available: ["Kiwi", "Mango"], the two the shop does not stock. Choose Close. The EK9 ... |
| Chapter 9: collections, asked about | The result | Basket.ek9 now reads exactly as chapter 9 of Getting Started with EK9 shows it: prices looked up with getOrDefault's own unset Money() default, so what the shop does not stock is told apart from what costs nothing. /q 129 then answered the same getOrDefault question from the Q&A corpus, and ... |
| Chapter 9: collections, asked about | Where this lesson comes from | Answers - ek9 -q and the IDE's Answers tab: 129.For AI assistants - the MCP tool ek9_add_program, ek9_ask, ek9_query_effective_api. |
| Chapter 9: a list, a dict and JSON | Chapter 9: a list, a dict and JSON | A collection holds other values, and chapter 9 asks the question beginners trip over: is an EMPTY collection missing? It is not - an empty List is set, with nothing in it - while a Dict that lacks a key answers with an UNSET value, never a made-up zero. This small program shows each in turn, with ... |
| Chapter 9: a list, a dict and JSON | Step 1: The program, and a list | Choose Code > New Construct > Program… The EK9 IDE once this is done: Choose Code > New Construct > Program… Show is the program's name. Choose Preview. The EK9 IDE just before choosing Preview: Show is the program's name The preview shows Show about to be written. Choose Apply. The EK9 IDE just ... |
| Chapter 9: a list, a dict and JSON | Step 2: A Dict, and a miss | Select the last println and type the Dict section after it: prices with two entries, and getOrDefault asked for a key that is there and one that is not. The default is an unset Integer(), not 0. The EK9 IDE once this is done: Select the last println and type the Dict section after it |
| Chapter 9: a list, a dict and JSON | Step 3: A collection as JSON | Select the last println and type the closing line: the $$ operator turns any collection into JSON. The EK9 IDE once this is done: Select the last println and type the closing line |
| Chapter 9: a list, a dict and JSON | Step 4: Run it | Choose Run > Run Program… The EK9 IDE once this is done: Choose Run > Run Program… The project's only program is already chosen. Choose Run. New list set? true items: 0, then the two items, Bread costs 110, and Cheese has no price - the miss is unset, not free. Choose Close. The EK9 IDE just ... |
| Chapter 9: a list, a dict and JSON | Step 5: Ask: /q 1019 | Type /q 1019 into the input bar above the editor and choose -> to send it - a direct lookup, by the question's own number, into the Answers tab. The EK9 IDE once this is done: Type /q 1019 into the input bar above the editor and choose -> to send it - a direct lookup, by the question's own ... |
| Chapter 9: a list, a dict and JSON | The result | Collections.ek9 now reads exactly as chapter 9 of Getting Started with EK9 shows it: an empty list that is set, a Dict whose missing key comes back unset rather than as a made-up zero, and a collection printed as JSON. The IDE's tool made the program; the three sections were typed, one at a time, ... |
| Chapter 9: a list, a dict and JSON | Where this lesson comes from | Answers - ek9 -q and the IDE's Answers tab: 1019.For AI assistants - the MCP tool ek9_add_program, ek9_ask. |
| Chapter 9: how a collection's type is worked out | Chapter 9: how a collection's type is worked out | You never wrote 'List of String' in chapter 9's first example: EK9 looked at the values and found the one type they all fit. This small program shows that for strings, whole numbers and decimals, then the one time you MUST name the type - an empty list, which has no values to look at - and what a ... |
| Chapter 9: how a collection's type is worked out | Step 1: The program, and three inferred lists | Choose Code > New Construct > Program… The EK9 IDE once this is done: Choose Code > New Construct > Program… Inference is the program's name. Choose Preview. The EK9 IDE just before choosing Preview: Inference is the program's name The preview shows Inference about to be written. Choose Apply. ... |
| Chapter 9: how a collection's type is worked out | Step 2: An empty list must say its type | Select the last println and type the empty list after it: nothing in it to infer from, so List() of Float says the type. The EK9 IDE once this is done: Select the last println and type the empty list after it |
| Chapter 9: how a collection's type is worked out | Step 3: Walking a Dict | Select the last println and type the Dict after it: a loop over a Dict gives each entry, with a key() and a value(). The EK9 IDE once this is done: Select the last println and type the Dict after it |
| Chapter 9: how a collection's type is worked out | Step 4: Run it | Choose Run > Run Program… The EK9 IDE once this is done: Choose Run > Run Program… The project's only program is already chosen. Choose Run. The three lists, then scores set? true items: 0, then Ada is 36 and Grace is 45. Choose Close. The EK9 IDE just before choosing Close: The three lists, then ... |
| Chapter 9: how a collection's type is worked out | Step 5: Ask: /q 127 | Type /q 127 into the input bar above the editor and choose -> to send it - a direct lookup, by the question's own number, into the Answers tab. The EK9 IDE once this is done: Type /q 127 into the input bar above the editor and choose -> to send it - a direct lookup, by the question's own number, ... |
| Chapter 9: how a collection's type is worked out | The result | Inference.ek9 now reads exactly as chapter 9 of Getting Started with EK9 shows it: three lists whose types EK9 worked out from their values, an empty list that had to say its type, and a Dict walked key by key. The IDE's tool made the program; the three sections were typed and run together. /q ... |
| Chapter 9: how a collection's type is worked out | Where this lesson comes from | Answers - ek9 -q and the IDE's Answers tab: 127.For AI assistants - the MCP tool ek9_add_program, ek9_ask. |
| Chapter 9: where promotion comes from | Chapter 9: where promotion comes from | 5 is a whole number and addHalf wants a Float - yet addHalf(5) works. That is not a special rule in the compiler: Integer has a promotion operator, #^, whose job is to answer 'what wider type can I become?'. The IDE makes the function and the program; you type the logic, run it, then look at ... |
| Chapter 9: where promotion comes from | Step 1: addHalf - a function that wants a Float | Choose Code > New Construct > Function… The EK9 IDE once this is done: Choose Code > New Construct > Function… addHalf is the function's name. Add one parameter, x of type Float, set Returns to Float and tick pure. Choose Preview. The EK9 IDE just before choosing Preview: addHalf is the ... |
| Chapter 9: where promotion comes from | Step 2: The program, and #^ by hand | Choose Code > New Construct > Program… The EK9 IDE once this is done: Choose Code > New Construct > Program… Promotion is the program's name. Choose Preview. The EK9 IDE just before choosing Preview: Promotion is the program's name The preview shows Promotion about to be written. Choose Apply. ... |
| Chapter 9: where promotion comes from | Step 3: Promotion without being asked | Select the last println and type the calls after it: addHalf wants a Float and is given a 5 and a 2.5 - the 5 promotes by itself. The EK9 IDE once this is done: Select the last println and type the calls after it |
| Chapter 9: where promotion comes from | Step 4: Run it | Choose Run > Run Program… The EK9 IDE once this is done: Choose Run > Run Program… The project's only program is already chosen. Choose Run. 5 promoted with #^ is 5.0, addHalf(5) = 5.5 and addHalf(2.5) = 3.0 - the whole number became a Float for the call. Choose Close. The EK9 IDE just before ... |
| Chapter 9: where promotion comes from | Step 5: Read Effective API: Integer | Select whole, on the line that declares it, then choose Analyse ▸ Effective API. The EK9 IDE once this is done: Select whole, on the line that declares it, then choose Analyse ▸ Effective API The pane draws Integer's own surface. Among its Operators is #^ - the promotion operator the chapter ... |
| Chapter 9: where promotion comes from | The result | Promotion.ek9 now reads exactly as chapter 9 of Getting Started with EK9 shows it: a function that wants a Float, an Integer promoted to one by hand with #^, and the same promotion happening on its own at a call. The IDE's tools made the function and the program; the logic was typed and run. ... |
| Chapter 9: where promotion comes from | Where this lesson comes from | For AI assistants - the MCP tool ek9_new_construct, ek9_add_program, ek9_query_effective_api. |
| Chapter 9: a collection as JSON | Chapter 9: a collection as JSON | JSON is how programs hand data to each other, and EK9 gives every collection a one-character way to produce it: the $$ operator. The result is a JSON value you can read fields from, so the data is never trapped in text. The IDE makes the program's shell; you type the two sections, run them, then ... |
| Chapter 9: a collection as JSON | Step 1: The program, and a Dict as JSON | Choose Code > New Construct > Program… The EK9 IDE once this is done: Choose Code > New Construct > Program… Show is the program's name. Choose Preview. The EK9 IDE just before choosing Preview: Show is the program's name The preview shows Show about to be written. Choose Apply. The EK9 IDE just ... |
| Chapter 9: a collection as JSON | Step 2: Reading a field back | Select the last println and type the closing section: get reads the apple field back out of the JSON value. The EK9 IDE once this is done: Select the last println and type the closing section |
| Chapter 9: a collection as JSON | Step 3: Run it | Choose Run > Run Program… The EK9 IDE once this is done: Choose Run > Run Program… The project's only program is already chosen. Choose Run. The prices as JSON, {"apple": 35, "bread": 80}, then the apple field read back out: 35. Choose Close. The EK9 IDE just before choosing Close: The prices as ... |
| Chapter 9: a collection as JSON | Step 4: Ask: /q 189 | Type /q 189 into the input bar above the editor and choose -> to send it - a direct lookup, by the question's own number, into the Answers tab. The EK9 IDE once this is done: Type /q 189 into the input bar above the editor and choose -> to send it - a direct lookup, by the question's own number, ... |
| Chapter 9: a collection as JSON | Step 5: Read Effective API: JSON | Select asJson, on the line that declares it, then choose Analyse ▸ Effective API - the same pane chapter 9's Basket read for a List and a Dict. The EK9 IDE once this is done: Select asJson, on the line that declares it, then choose Analyse ▸ Effective API - the same pane chapter 9's Basket read ... |
| Chapter 9: a collection as JSON | The result | JsonTaste.ek9 now reads exactly as chapter 9 of Getting Started with EK9 shows it: a Dict of prices turned into JSON with $$, and one field read back out by name with get. The IDE's tool made the program; the two sections were typed and run. /q 189 and Analyse ▸ Effective API then showed where $$ ... |
| Chapter 9: a collection as JSON | Where this lesson comes from | Answers - ek9 -q and the IDE's Answers tab: 189.For AI assistants - the MCP tool ek9_add_program, ek9_ask, ek9_query_effective_api. |
| Chapter 10: guards, reshaped | Chapter 10: guards, reshaped | Chapter 10 is about guards: a value declared and checked in one breath, so code only runs once something is known to be set. Rather than type the guard directly, this lesson writes the plainer, two-statement form first - a declaration, then a separate check right after it, chapter 10's own ... |
| Chapter 10: guards, reshaped | Step 1: lookupName | Choose Code > New Construct > Function… The EK9 IDE once this is done: Choose Code > New Construct > Function… lookupName is the function's name - no parameters. Set Returns to String and tick pure. Choose Preview. The EK9 IDE just before choosing Preview: lookupName is the function's name - no ... |
| Chapter 10: guards, reshaped | Step 2: storedName | Choose Code > New Construct > Function… The EK9 IDE once this is done: Choose Code > New Construct > Function… storedName is the function's name. Set Returns to String and tick pure. Choose Preview. The EK9 IDE just before choosing Preview: storedName is the function's name The preview shows ... |
| Chapter 10: guards, reshaped | Step 3: messagePrefix | Choose Code > New Construct > Function… The EK9 IDE once this is done: Choose Code > New Construct > Function… messagePrefix is the function's name. Set Returns to String and tick pure. Choose Preview. The EK9 IDE just before choosing Preview: messagePrefix is the function's name The preview ... |
| Chapter 10: guards, reshaped | Step 4: Greet — a guard, twice | Choose Code > New Construct > Program… The EK9 IDE once this is done: Choose Code > New Construct > Program… Greet is the program's name. Choose Preview. The EK9 IDE just before choosing Preview: Greet is the program's name The preview shows Greet about to be written. Choose Apply. The EK9 IDE ... |
| Chapter 10: guards, reshaped | Step 5: GreetLongNames — a guard with a condition | Choose Code > New Construct > Program… The EK9 IDE once this is done: Choose Code > New Construct > Program… GreetLongNames is the program's name. Choose Preview. The EK9 IDE just before choosing Preview: GreetLongNames is the program's name The preview shows GreetLongNames about to be written. ... |
| Chapter 10: guards, reshaped | Step 6: Echo — the same guard in a 'while' | Choose Code > New Construct > Program… The EK9 IDE once this is done: Choose Code > New Construct > Program… Echo is the program's name. Choose Preview. The EK9 IDE just before choosing Preview: Echo is the program's name The preview shows Echo about to be written. Choose Apply. The EK9 IDE just ... |
| Chapter 10: guards, reshaped | Step 7: Numbered — the same guard before a 'for' | Choose Code > New Construct > Program… The EK9 IDE once this is done: Choose Code > New Construct > Program… Numbered is the program's name. Choose Preview. The EK9 IDE just before choosing Preview: Numbered is the program's name The preview shows Numbered about to be written. Choose Apply. The ... |
| Chapter 10: guards, reshaped | Step 8: Run it | Choose Run > Run Program… The EK9 IDE once this is done: Choose Run > Run Program… Choose Greet from the list, then choose Run. Hello, Ada - lookupName() gave nothing, so its guard never ran; storedName() gave Ada, so its guard did. Choose Close. The EK9 IDE just before choosing Close: Hello, Ada ... |
| Chapter 10: guards, reshaped | The result | Guards.ek9 now reads exactly as chapter 10 of Getting Started with EK9 shows it: three functions a program can ask for a name, and four programs that each declare one, check it is set, and act on it - written here plainer first, a declaration then a separate check right after it - and Lift into ... |
| Chapter 10: guards, reshaped | Where this lesson comes from | For AI assistants - the MCP tool ek9_new_construct, ek9_add_program, ek9_apply_guard_pattern. |
| Chapter 10: three ways to default a name, built | Chapter 10: three ways to default a name, built | Sometimes a value is simply not there, and you want a default. Chapter 10 gives three answers that read from explicit to terse: check then assign, assign only if unset (:=?), and the coalescing expression (?:). The IDE's tools build the constant, the function and the three programs, and Wrap with ... |
| Chapter 10: three ways to default a name, built | Step 1: A name for the default | Choose Code > New Construct > Constant… The EK9 IDE once this is done: Choose Code > New Construct > Constant… DefaultName is the constant's name and "Friend" its value - a literal in the Value field, from which the type is inferred. Type both and choose Preview. The EK9 IDE just before choosing ... |
| Chapter 10: three ways to default a name, built | Step 2: lookupName - a name that may be unset | Choose Code > New Construct > Function… The EK9 IDE once this is done: Choose Code > New Construct > Function… lookupName is the function's name - no parameters, set Returns to String and tick pure. Choose Preview. The EK9 IDE just before choosing Preview: lookupName is the function's name - no ... |
| Chapter 10: three ways to default a name, built | Step 3: Step 1 - check, then assign | Choose Code > New Construct > Program… The EK9 IDE once this is done: Choose Code > New Construct > Program… PlainDefault is the program's name. Choose Preview. The EK9 IDE just before choosing Preview: PlainDefault is the program's name The preview shows PlainDefault about to be written. Choose ... |
| Chapter 10: three ways to default a name, built | Step 4: Step 2 - assign only if unset | Choose Code > New Construct > Program… The EK9 IDE once this is done: Choose Code > New Construct > Program… GuardedDefault is the program's name. Choose Preview. The EK9 IDE just before choosing Preview: GuardedDefault is the program's name The preview shows GuardedDefault about to be written. ... |
| Chapter 10: three ways to default a name, built | Step 5: Step 3 - an expression | Choose Code > New Construct > Program… The EK9 IDE once this is done: Choose Code > New Construct > Program… CoalescingDefault is the program's name. Choose Preview. The EK9 IDE just before choosing Preview: CoalescingDefault is the program's name The preview shows CoalescingDefault about to be ... |
| Chapter 10: three ways to default a name, built | Step 6: Run it | Choose Run > Run Program… The EK9 IDE once this is done: Choose Run > Run Program… Choose CoalescingDefault from the list, then choose Run. The EK9 IDE just before choosing Run: Choose CoalescingDefault from the list, then choose Run Hello, Friend - lookupName() gave nothing, so the default stood ... |
| Chapter 10: three ways to default a name, built | Step 7: Ask: /q 1059 | Type /q 1059 into the input bar above the editor and choose -> to send it - a direct lookup, by the question's own number, into the Answers tab. The EK9 IDE once this is done: Type /q 1059 into the input bar above the editor and choose -> to send it - a direct lookup, by the question's own ... |
| Chapter 10: three ways to default a name, built | The result | Defaulting.ek9 now reads exactly as chapter 10 of Getting Started with EK9 shows it: one name that may be unset and three answers, each printing Hello, Friend - spelled out, assigned only if unset, and as a single expression. The constant, the function and the programs came from the New Construct ... |
| Chapter 10: three ways to default a name, built | Where this lesson comes from | Answers - ek9 -q and the IDE's Answers tab: 1059.For AI assistants - the MCP tool ek9_new_construct, ek9_add_program, ek9_insert_coalescing, ek9_ask. |
| Chapter 10: safe minimum and maximum, wrapped | Chapter 10: safe minimum and maximum, wrapped | Chapter 10's SafeMinMax asks three shops for a price - one never replies, so its value is unset - and finds the cheapest and dearest with <? and >?, which pass over an unset operand. The IDE writes the program's shell and wraps each plain expression into its chain; you type the draft. To play it ... |
| Chapter 10: safe minimum and maximum, wrapped | Step 1: A plain draft | Choose Code > New Construct > Program… The EK9 IDE once this is done: Choose Code > New Construct > Program… Show is the program's name. Choose Preview. The EK9 IDE just before choosing Preview: Show is the program's name The preview shows Show about to be written. Choose Apply. The EK9 IDE just ... |
| Chapter 10: safe minimum and maximum, wrapped | Step 2: A chain of <?, wrapped twice | Select shopA on the cheapest line and wrap it with <? shopB - the lesser of the two, the set one when only one is. The EK9 IDE once this is done: Select shopA on the cheapest line and wrap it with <? shopB - the lesser of the two, the set one when only one is Choose <?, type shopB as the right ... |
| Chapter 10: safe minimum and maximum, wrapped | Step 3: A chain of >?, in one wrap | Select shopA on the dearest line and wrap it with >? and a right operand that is already a chain, shopB >? shopC - the greater of all three, written in one step. The EK9 IDE once this is done: Select shopA on the dearest line and wrap it with >? and a right operand that is already a chain, shopB ... |
| Chapter 10: safe minimum and maximum, wrapped | Step 4: Every value unset | Select Integer() on the noQuotes line and wrap it with <? Integer() - only when EVERY value is unset is the answer unset. The EK9 IDE once this is done: Select Integer() on the noQuotes line and wrap it with <? Integer() - only when EVERY value is unset is the answer unset Choose <?, type ... |
| Chapter 10: safe minimum and maximum, wrapped | Step 5: Run it | Choose Run > Run Program… The EK9 IDE once this is done: Choose Run > Run Program… The project's only program is already chosen. Choose Run. cheapest quote: 9 - dearest quote: 12: the unset shopB is passed over - and no quotes at all -> set? false, the one case where every value is unset. Choose ... |
| Chapter 10: safe minimum and maximum, wrapped | The result | SafeMinMax.ek9 now reads exactly as chapter 10 of Getting Started with EK9 shows it: the cheapest and dearest of three quotes, one unset, each a chain of <? or >? that skips the unset one - and answers unset only when every value is. Wrap with coalescing… built each chain from a plain draft: pick ... |
| Chapter 10: safe minimum and maximum, wrapped | Where this lesson comes from | For AI assistants - the MCP tool ek9_add_program, ek9_insert_coalescing. |
| Chapter 10: a for loop that gives a value, built | Chapter 10: a for loop that gives a value, built | Chapter 10 says control flow can give a value back. A for loop is the plainest case: it declares a result with <- rtn, adds to it on every pass, and total receives the finished rtn - assigned once, never reassigned, which is what pure code needs. The IDE makes the program's shell; you type the ... |
| Chapter 10: a for loop that gives a value, built | Step 1: The program | Choose Code > New Construct > Program… The EK9 IDE once this is done: Choose Code > New Construct > Program… Sum is the program's name. Choose Preview. The EK9 IDE just before choosing Preview: Sum is the program's name The preview shows Sum about to be written. Choose Apply. The EK9 IDE just ... |
| Chapter 10: a for loop that gives a value, built | Step 2: What the loop is | Select the Sum() line, and above it type the comment saying what kind of loop this is. Saves when typed. The EK9 IDE once this is done: Select the Sum() line, and above it type the comment saying what kind of loop this is |
| Chapter 10: a for loop that gives a value, built | Step 3: Run it | Choose Run > Run Program… The EK9 IDE once this is done: Choose Run > Run Program… The project's only program is already chosen. Choose Run. Total is 15 - one plus two plus three plus four plus five, handed back by the loop itself. Choose Close. The EK9 IDE just before choosing Close: Total is 15 ... |
| Chapter 10: a for loop that gives a value, built | Step 4: Ask: /q 80 | Type /q 80 into the input bar above the editor and choose -> to send it - a direct lookup, by the question's own number, into the Answers tab. The EK9 IDE once this is done: Type /q 80 into the input bar above the editor and choose -> to send it - a direct lookup, by the question's own number, ... |
| Chapter 10: a for loop that gives a value, built | The result | ForExpression.ek9 now reads exactly as chapter 10 of Getting Started with EK9 shows it: a for loop that hands back a value, so total is assigned once, from the loop itself, instead of being declared and then changed. The IDE's tool made the program; the loop was typed and run. /q 80 then answered ... |
| Chapter 10: a for loop that gives a value, built | Where this lesson comes from | Answers - ek9 -q and the IDE's Answers tab: 80.For AI assistants - the MCP tool ek9_add_program, ek9_ask. |
| Chapter 11: an Optional, built | Chapter 11: an Optional, built | Chapter 11's Phone looks a name up in a small phone book. A name that is not there is not an error - it is just no answer - so lookupNumber returns an Optional of String: a box that holds a number or holds nothing, and the compiler refuses a get() that skips the check. The IDE's tools make the ... |
| Chapter 11: an Optional, built | Step 1: lookupNumber — a pure function returning Optional | Choose Code > New Construct > Function… The EK9 IDE once this is done: Choose Code > New Construct > Function… lookupNumber is the function's name. Add one parameter, name of type String, set Returns to Optional of String, and tick pure. Choose Preview. The EK9 IDE just before choosing Preview: ... |
| Chapter 11: an Optional, built | Step 2: Only when the name is there, with Surround With | Put the caret on the rtn line, right-click - or choose Refactor > Refactor This… - and choose Surround With ▸ if .... The EK9 IDE once this is done: Put the caret on the rtn line, right-click - or choose Refactor > Refactor This… - and choose Surround With ▸ if ... Select the stub, from ... |
| Chapter 11: an Optional, built | Step 3: The program | Choose Code > New Construct > Program… The EK9 IDE once this is done: Choose Code > New Construct > Program… Phone is the program's name. Choose Preview. The EK9 IDE just before choosing Preview: Phone is the program's name The preview shows Phone about to be written. Choose Apply. The EK9 IDE ... |
| Chapter 11: an Optional, built | Step 4: Read Optional's effective API | Select ada, on the line that declares it, then choose Analyse ▸ Effective API. The EK9 IDE once this is done: Select ada, on the line that declares it, then choose Analyse ▸ Effective API The pane draws Optional of String's own surface: its Constructors, then its Methods and Operators, each ... |
| Chapter 11: an Optional, built | Step 5: Run it | Choose Run > Run Program… The EK9 IDE once this is done: Choose Run > Run Program… The project's only program is already chosen. Choose Run. Ada: 0100 111, then No number for Zara - the second lookup came back empty, and the program said so instead of reading nothing. Choose Close. The EK9 IDE ... |
| Chapter 11: an Optional, built | The result | Phone.ek9 now reads exactly as chapter 11 of Getting Started with EK9 shows it: a pure function that hands back an Optional - set when the name is in the book, empty when it is not - and a program that only reads a number after asking if one is there. Surround With ▸ if folded the lookup itself ... |
| Chapter 11: an Optional, built | Where this lesson comes from | For AI assistants - the MCP tool ek9_new_construct, ek9_surround_with, ek9_add_program, ek9_query_effective_api. |
| Chapter 11: Optional and Result, built | Chapter 11: Optional and Result, built | Chapter 11 meets two small containers for uncertainty: Optional, a box that holds a value or none, and Result, a box that holds success or an error. Divide asks safeDivide for a / b and gets back a Result of (Integer, String) rather than a runtime exception - isOk()/ok() on success, ... |
| Chapter 11: Optional and Result, built | Step 1: safeDivide — a pure function returning Result | Choose Code > New Construct > Function… The EK9 IDE once this is done: Choose Code > New Construct > Function… safeDivide is the function's name. Add the parameters a of type Integer and b of type Integer, set Returns to Result of (Integer, String) and tick pure. Choose Preview. The EK9 IDE just ... |
| Chapter 11: Optional and Result, built | Step 2: Divide by zero, with Surround With | Put the caret on the division line, right-click - or choose Refactor > Refactor This… - and choose Surround With ▸ if ... else. The EK9 IDE once this is done: Put the caret on the division line, right-click - or choose Refactor > Refactor This… - and choose Surround With ▸ if .. Select the stub, ... |
| Chapter 11: Optional and Result, built | Step 3: The program | Choose Code > New Construct > Program… The EK9 IDE once this is done: Choose Code > New Construct > Program… Div is the program's name. Choose Preview. The EK9 IDE just before choosing Preview: Div is the program's name The preview shows Div about to be written. Choose Apply. The EK9 IDE just ... |
| Chapter 11: Optional and Result, built | Step 4: Read Result's effective API | Select good, on the line that declares it, then choose Analyse ▸ Effective API: cursor-anchored, the same way Pipeline read chapter 12's stream before it ran. The EK9 IDE once this is done: Select good, on the line that declares it, then choose Analyse ▸ Effective API The pane draws Result of ... |
| Chapter 11: Optional and Result, built | Step 5: Run it | Choose Run > Run Program… The EK9 IDE once this is done: Choose Run > Run Program… The project's only program is already chosen. Choose Run. Answer: 5, then Cannot: cannot divide by zero - the first call succeeded, the second was refused before it ever divided. Choose Close. The EK9 IDE just ... |
| Chapter 11: Optional and Result, built | The result | Divide.ek9 now reads exactly as chapter 11 of Getting Started with EK9 shows it: a pure function that returns a Result rather than risk a division by zero, and a program that only ever reads it after checking which it got. Surround With folded the division itself under an if ... else head before ... |
| Chapter 11: Optional and Result, built | Where this lesson comes from | For AI assistants - the MCP tool ek9_new_construct, ek9_surround_with, ek9_add_program, ek9_query_effective_api. |
| Chapter 12: a pipeline, built | Chapter 12: a pipeline, built | Chapter 12 meets the stream: a pipeline of small stages joined by |, each with one job - filter keeps some values, map changes every one, and the pipeline ends by printing or collecting a result. Numbers keeps the even numbers from 1 to 6, doubles them, and prints what is left - the chapter's own ... |
| Chapter 12: a pipeline, built | Step 1: isEven — a pure function | Choose Code > New Construct > Function… The EK9 IDE once this is done: Choose Code > New Construct > Function… isEven is the function's name. Add one parameter, n of type Integer, set Returns to Boolean, and tick pure. Choose Preview. The EK9 IDE just before choosing Preview: isEven is the ... |
| Chapter 12: a pipeline, built | Step 2: doubleIt — a pure function | Choose Code > New Construct > Function… The EK9 IDE once this is done: Choose Code > New Construct > Function… doubleIt is the function's name. Add one parameter, n of type Integer, set Returns to Integer, and tick pure, as isEven's were. Choose Preview. The EK9 IDE just before choosing Preview: ... |
| Chapter 12: a pipeline, built | Step 3: The program | Choose Code > New Construct > Program… The EK9 IDE once this is done: Choose Code > New Construct > Program… Numbers is the program's name. Choose Preview. The EK9 IDE just before choosing Preview: Numbers is the program's name The preview shows Numbers about to be written. Choose Apply. The EK9 ... |
| Chapter 12: a pipeline, built | Step 4: Read the pipeline | Put the caret anywhere on the pipeline line - between for and > stdout - then choose Analyse ▸ Pipeline: cursor-anchored, the same way Flow Analysis and Effective API read the construct the caret sits in. The EK9 IDE once this is done: Put the caret anywhere on the pipeline line - between for and ... |
| Chapter 12: a pipeline, built | Step 5: Run it | Choose Run > Run Program… The EK9 IDE once this is done: Choose Run > Run Program… The project's only program is already chosen. Choose Run. 4, then 8, then 12 - the even numbers from 1 to 6, each doubled by the time the pipeline reached stdout. Choose Close. The EK9 IDE just before choosing ... |
| Chapter 12: a pipeline, built | The result | Numbers.ek9 now reads exactly as chapter 12 of Getting Started with EK9 shows it: two pure functions and the pipeline that filters, doubles and prints with them. Analyse ▸ Pipeline decomposed that pipeline stage by stage before it ran - the same decomposition ek9_query_pipeline answers for an AI ... |
| Chapter 12: a pipeline, built | Where this lesson comes from | For AI assistants - the MCP tool ek9_new_construct, ek9_add_program, ek9_query_pipeline. |
| Chapter 12: a pipeline, and its tests, built | Chapter 12: a pipeline, and its tests, built | Chapter 12 puts the shopping basket from Collections into a pipeline: price each name, drop the ones the shop does not stock, add up the rest - and then tests every stage and the whole. The IDE makes each function's signature and each test's shell; you type what no tool can write: the price list, ... |
| Chapter 12: a pipeline, and its tests, built | Step 1: priceOf — a price list lookup | Choose Code > New Construct > Function… The EK9 IDE once this is done: Choose Code > New Construct > Function… priceOf is the function's name. Add one parameter, item of type String, set Returns to Money, and tick pure. Choose Preview. The EK9 IDE just before choosing Preview: priceOf is the ... |
| Chapter 12: a pipeline, and its tests, built | Step 2: isAvailable — is there a price | Choose Code > New Construct > Function… The EK9 IDE once this is done: Choose Code > New Construct > Function… isAvailable is the function's name. Add one parameter, price of type Money, set Returns to Boolean, and tick pure. Choose Preview. The EK9 IDE just before choosing Preview: isAvailable ... |
| Chapter 12: a pipeline, and its tests, built | Step 3: basketTotal — the pipeline | Choose Code > New Construct > Function… The EK9 IDE once this is done: Choose Code > New Construct > Function… basketTotal is the function's name. Add one parameter, items of type List of String, set Returns to Money, and tick pure. Choose Preview. The EK9 IDE just before choosing Preview: ... |
| Chapter 12: a pipeline, and its tests, built | Step 4: The tests' file | Open shop/dev/tests.ek9 - already there, with just its own module line. The EK9 IDE once this is done: Open shop/dev/tests.ek9 - already there, with just its own module line Select the module line, and below it type a references block bringing in the three functions, in alphabetical order. Saves ... |
| Chapter 12: a pipeline, and its tests, built | Step 5: PriceOfTest | Choose Code > New Construct > Test… The EK9 IDE once this is done: Choose Code > New Construct > Test… PriceOfTest is the test's name. Choose Preview. The EK9 IDE just before choosing Preview: PriceOfTest is the test's name The preview shows PriceOfTest about to be written, marked @Test, with a ... |
| Chapter 12: a pipeline, and its tests, built | Step 6: MissingPriceTest | Choose Code > New Construct > Test… The EK9 IDE once this is done: Choose Code > New Construct > Test… MissingPriceTest is the test's name. Choose Preview. The EK9 IDE just before choosing Preview: MissingPriceTest is the test's name The preview shows MissingPriceTest about to be written, marked ... |
| Chapter 12: a pipeline, and its tests, built | Step 7: IsAvailableTest | Choose Code > New Construct > Test… The EK9 IDE once this is done: Choose Code > New Construct > Test… IsAvailableTest is the test's name. Choose Preview. The EK9 IDE just before choosing Preview: IsAvailableTest is the test's name The preview shows IsAvailableTest about to be written, marked ... |
| Chapter 12: a pipeline, and its tests, built | Step 8: BasketTotalTest — the whole pipeline | Choose Code > New Construct > Test… The EK9 IDE once this is done: Choose Code > New Construct > Test… BasketTotalTest is the test's name. Choose Preview. The EK9 IDE just before choosing Preview: BasketTotalTest is the test's name The preview shows BasketTotalTest about to be written, marked ... |
| Chapter 12: a pipeline, and its tests, built | Step 9: Run the tests | Run ▸ Run Tests (⌘T) runs every @Test in the project, all four, and reports pass or fail - the same as ek9 -t at the command line. Choose Run Tests. The EK9 IDE once this is done: Run ▸ Run Tests (⌘T) runs every @Test in the project, all four, and reports pass or fail - the same as ek9 -t at the ... |
| Chapter 12: a pipeline, and its tests, built | The result | shop.ek9 and shop/dev/tests.ek9 now read exactly as chapter 12 of Getting Started with EK9 shows them: three pure functions, the last a stream pipeline, and four @Test programs - one for each stage and one for the stages together. ek9_new_construct and ek9_add_program are what an AI assistant ... |
| Chapter 12: a pipeline, and its tests, built | Where this lesson comes from | For AI assistants - the MCP tool ek9_new_construct, ek9_add_program, ek9_run_tests. |
| Chapter 13: data, an object and a function, built | Chapter 13: data, an object and a function, built | Chapter 13 sets out three ways to build: a record for data, a class for an object that looks after its data, and a function for behaviour with no state. This lesson builds one of each, side by side in one file, and a program that uses all three. The IDE's tools make each shell and signature; what ... |
| Chapter 13: data, an object and a function, built | Step 1: Data: a record | Choose Code > New Construct > Record… The EK9 IDE once this is done: Choose Code > New Construct > Record… Point is the record's name. Add x and y, both Float, each starting at 0.0 - a record is just named data. Choose Preview. The EK9 IDE just before choosing Preview: Point is the record's name ... |
| Chapter 13: data, an object and a function, built | Step 2: An object: a class | Choose Code > New Construct > Class… The EK9 IDE once this is done: Choose Code > New Construct > Class… Counter is the class's name. Closed is already selected - EK9's default. Choose Preview. The EK9 IDE just before choosing Preview: Counter is the class's name The preview shows Counter about ... |
| Chapter 13: data, an object and a function, built | Step 3: Behaviour: a function | Choose Code > New Construct > Function… The EK9 IDE once this is done: Choose Code > New Construct > Function… add is the function's name. Add the parameters a of type Integer and b of type Integer, set Returns to Integer and tick pure. Choose Preview. The EK9 IDE just before choosing Preview: ... |
| Chapter 13: data, an object and a function, built | Step 4: One program, all three | Choose Code > New Construct > Program… The EK9 IDE once this is done: Choose Code > New Construct > Program… Show is the program's name. Choose Preview. The EK9 IDE just before choosing Preview: Show is the program's name The preview shows Show about to be written. Choose Apply. The EK9 IDE just ... |
| Chapter 13: data, an object and a function, built | Step 5: Run it | Choose Run > Run Program… The EK9 IDE once this is done: Choose Run > Run Program… The project's only program is already chosen. Choose Run. Point (3.0, 4.0), Count 2, Add 5 - the record, the class and the function, each doing its own job. Choose Close. The EK9 IDE just before choosing Close: ... |
| Chapter 13: data, an object and a function, built | The result | ThreeWays.ek9 now reads exactly as chapter 13 of Getting Started with EK9 shows it: data, an object and a behaviour of its own, side by side in one file and used by one program - built by the tools, logic you typed. ek9_new_construct made the record, class, function and program shells; ... |
| Chapter 13: data, an object and a function, built | Where this lesson comes from | For AI assistants - the MCP tool ek9_new_construct, ek9_add_operator, ek9_add_field, ek9_add_method, ek9_add_program. |
| Chapter 14: a record, built | Chapter 14: a record, built | Chapter 14 gives a point on a grid, x and y, its own record: built complete in one step, or blank and filled in afterwards, then compared and printed. The IDE's own tools make the structure - the record, each field's declaration, both constructors' whole signatures, moveTo's whole signature - so ... |
| Chapter 14: a record, built | Step 1: A record, with its fields | Choose Code > New Construct > Record… The EK9 IDE once this is done: Choose Code > New Construct > Record… Coord is the record's name. Add x and y, both Integer, each given a starting Value of Integer() - a freshly made but unset Integer - so the record needs no constructor of its own yet. Choose ... |
| Chapter 14: a record, built | Step 2: Building it blank, then complete — and its logic | Right-click the Coord line and choose Add Constructor > No-Arg (default, pure) - the compiler's own standard version, which leaves every field unset. The EK9 IDE once this is done: Right-click the Coord line and choose Add Constructor > No-Arg (default, pure) - the compiler's own standard ... |
| Chapter 14: a record, built | Step 3: moveTo — and its logic | Choose Code > New Construct > Function… The EK9 IDE once this is done: Choose Code > New Construct > Function… moveTo is the function's name. It fills in a blank Coord afterwards: it changes the Coord it is given, it does not hand one back. Add the parameters point of type Coord, toX of type ... |
| Chapter 14: a record, built | Step 4: operator $ — and its logic, then default <=> | Right-click the Coord line and choose Add Operator > $ (string) > skeleton. The EK9 IDE once this is done: Right-click the Coord line and choose Add Operator > $ (string) > skeleton Select the stub line and type $'s own text form - just the two numbers in parentheses, no type name. Saves when ... |
| Chapter 14: a record, built | Step 5: The program — and its logic | Choose Code > New Construct > Program… The EK9 IDE once this is done: Choose Code > New Construct > Program… Show is the program's name. Choose Preview. The EK9 IDE just before choosing Preview: Show is the program's name The preview shows Show about to be written. Choose Apply. The EK9 IDE just ... |
| Chapter 14: a record, built | Step 6: Run it | Choose Run > Run Program… The EK9 IDE once this is done: Choose Run > Run Program… The project's only program is already chosen. Choose Run. origin = (2, 3), its x is 2 - origin == twin? true, origin == faraway? false - a blank Coord is made (set? false), then after moveTo: (5, 6) (set? true). ... |
| Chapter 14: a record, built | The result | Coord.ek9 now reads exactly as chapter 14 of Getting Started with EK9 shows it: a record built either complete (Coord(2, 3)) or blank and filled in later (Coord(), then moveTo) - built by the tools, logic you typed. ek9_new_construct, ek9_add_field, ek9_add_constructor and ek9_add_operator - ... |
| Chapter 14: a record, built | Where this lesson comes from | For AI assistants - the MCP tool ek9_new_construct, ek9_add_constructor, ek9_add_operator, ek9_add_program. |
| Chapter 14: an enumeration, built | Chapter 14: an enumeration, built | Chapter 14 makes an enumeration: Day, a fixed set of named values that comes with printing, comparing and build-from-text for free - then a kindOf function that switches on it, and a Week program that prints every day. The IDE's own tools make the structure - the enumeration and its seven values ... |
| Chapter 14: an enumeration, built | Step 1: An enumeration | Choose Code > New Construct > Type > Enumeration… The EK9 IDE once this is done: Choose Code > New Construct > Type > Enumeration… Day is the enumeration's name. Add each of the seven days as a value, in order - Monday through Sunday. Choose Preview. The EK9 IDE just before choosing Preview: Day ... |
| Chapter 14: an enumeration, built | Step 2: kindOf — and its logic | Choose Code > New Construct > Function… The EK9 IDE once this is done: Choose Code > New Construct > Function… kindOf is the function's name. Add one parameter, day of type Day, set Returns to String, and tick pure. Choose Preview. The EK9 IDE just before choosing Preview: kindOf is the ... |
| Chapter 14: an enumeration, built | Step 3: The program — and its logic | Choose Code > New Construct > Program… The EK9 IDE once this is done: Choose Code > New Construct > Program… Week is the program's name. Choose Preview. The EK9 IDE just before choosing Preview: Week is the program's name The preview shows Week about to be written. Choose Apply. The EK9 IDE just ... |
| Chapter 14: an enumeration, built | Step 4: Run it | Choose Run > Run Program… The EK9 IDE once this is done: Choose Run > Run Program… The project's only program is already chosen. Choose Run. Monday is a weekday ... Saturday is a weekend ... Sunday is a weekend - kindOf answers for every day, and the switch never had to guess. Choose Close. The ... |
| Chapter 14: an enumeration, built | The result | Days.ek9 now reads exactly as chapter 14 of Getting Started with EK9 shows it: an enumeration the tools built in one call, with the function and program that use it, logic you typed. The same three tools - ek9_new_construct (twice: 'type'/'enumeration' and 'function') and ek9_add_program - are ... |
| Chapter 14: an enumeration, built | Where this lesson comes from | For AI assistants - the MCP tool ek9_new_construct, ek9_add_program. |
| Chapter 14: what an enumeration comes with, built | Chapter 14: what an enumeration comes with, built | An enumeration is more than a list of names. Day comes with printing, == and <, #< and #> for first and last, and a way to build one from text - none of them written by you. This lesson makes Day with the IDE's own tool, then types a Show program that tries each of them, including a text that ... |
| Chapter 14: what an enumeration comes with, built | Step 1: An enumeration | Choose Code > New Construct > Type > Enumeration… The EK9 IDE once this is done: Choose Code > New Construct > Type > Enumeration… Day is the enumeration's name. Add each of the seven days as a value, in order - Monday through Sunday. Choose Preview. The EK9 IDE just before choosing Preview: Day ... |
| Chapter 14: what an enumeration comes with, built | Step 2: The program — and what it tries | Choose Code > New Construct > Program… The EK9 IDE once this is done: Choose Code > New Construct > Program… Show is the program's name. Choose Preview. The EK9 IDE just before choosing Preview: Show is the program's name The preview shows Show about to be written. Choose Apply. The EK9 IDE just ... |
| Chapter 14: what an enumeration comes with, built | Step 3: Run it | Choose Run > Run Program… The EK9 IDE once this is done: Choose Run > Run Program… The project's only program is already chosen. Choose Run. as text: Monday and Wednesday, equality false, Monday before Wednesday, first day Monday and last day Sunday, Friday built from text and set - and ... |
| Chapter 14: what an enumeration comes with, built | The result | DayOperators.ek9 now reads exactly as chapter 14 of Getting Started with EK9 shows it: an enumeration the tool built in one call, and a program that tries everything an enumeration brings without a line written for it - a string form, equality, order, first and last, and a day built from text ... |
| Chapter 14: what an enumeration comes with, built | Where this lesson comes from | For AI assistants - the MCP tool ek9_new_construct, ek9_add_program. |
| Chapter 15: a range and a pattern, built | Chapter 15: a range and a pattern, built | Chapter 15's DrivingAge limited an Integer to a range. Rules shows the other two kinds of rule - a Float held between 0.0 and 1.0, and a String that must match a pattern - each made by the same dialog. To play it in the IDE: Help > Lessons > Getting Started with EK9…, or ek9 -ide -lesson ... |
| Chapter 15: a range and a pattern, built | Step 1: A Float kept in a range | Choose Code > New Construct > Type > Constrained… The EK9 IDE once this is done: Choose Code > New Construct > Type > Constrained… Ratio is the type's name. Choose Float as its base type - the Constraint field's hint changes to a range - and type >= 0.0 and <= 1.0 into it. Choose Preview. The EK9 ... |
| Chapter 15: a range and a pattern, built | Step 2: A String that must match a pattern | Choose Code > New Construct > Type > Constrained… The EK9 IDE once this is done: Choose Code > New Construct > Type > Constrained… Email is the type's name. Choose String as its base type - now the hint offers a pattern or a length - and type matches /^[a-z]+@[a-z]+$/ into the Constraint field. ... |
| Chapter 15: a range and a pattern, built | Step 3: The program | Choose Code > New Construct > Program… The EK9 IDE once this is done: Choose Code > New Construct > Program… Show is the program's name. Choose Preview. The EK9 IDE just before choosing Preview: Show is the program's name The preview shows Show about to be written. Choose Apply. The EK9 IDE just ... |
| Chapter 15: a range and a pattern, built | Step 4: Run it | Choose Run > Run Program… The EK9 IDE once this is done: Choose Run > Run Program… The project's only program is already chosen. Choose Run. ratio 0.5, too big accepted? false - email ok? true, capitals ok? false: 1.5 is outside 0.0 to 1.0 and a capital letter breaks the pattern, so both are ... |
| Chapter 15: a range and a pattern, built | The result | Rules.ek9 now reads exactly as chapter 15 of Getting Started with EK9 shows it: two constrained types - a Float range and a String pattern - made by one dialog, the Constraint field changing its hint to suit the base type, with only the program's body typed. ek9_new_construct (type, constrained) ... |
| Chapter 15: a range and a pattern, built | Where this lesson comes from | For AI assistants - the MCP tool ek9_new_construct, ek9_add_program. |
| Chapter 15: a constrained type, built | Chapter 15: a constrained type, built | Chapter 15 makes a constrained type: DrivingAge, an Integer narrowed to values 16 to 100 - not any Integer, but one the rule holds to, the same 'illegal states unrepresentable' idea an enumeration gives a fixed set of names. Then a verdict function that takes a DrivingAge, and a Show program that ... |
| Chapter 15: a constrained type, built | Step 1: A constrained type | Choose Code > New Construct > Type > Constrained… The EK9 IDE once this is done: Choose Code > New Construct > Type > Constrained… DrivingAge is the constrained type's name. Choose Integer as its base type, then type its rule, >= 16 and <= 100, into the Constraint field. Choose Preview. The EK9 ... |
| Chapter 15: a constrained type, built | Step 2: verdict — and its logic | Choose Code > New Construct > Function… The EK9 IDE once this is done: Choose Code > New Construct > Function… verdict is the function's name. Add one parameter, age of type DrivingAge, and set Returns to String. Choose Preview. The EK9 IDE just before choosing Preview: verdict is the function's ... |
| Chapter 15: a constrained type, built | Step 3: The program — and its logic | Choose Code > New Construct > Program… The EK9 IDE once this is done: Choose Code > New Construct > Program… Show is the program's name. Choose Preview. The EK9 IDE just before choosing Preview: Show is the program's name The preview shows Show about to be written. Choose Apply. The EK9 IDE just ... |
| Chapter 15: a constrained type, built | Step 4: Run it | Choose Run > Run Program… The EK9 IDE once this is done: Choose Run > Run Program… The project's only program is already chosen. Choose Run. 17 is a valid driving age, with next year printing 18 - then 20 is accepted, but 9 and 133 are both rejected as out of range. Choose Close. The EK9 IDE just ... |
| Chapter 15: a constrained type, built | The result | DrivingAge.ek9 now reads exactly as chapter 15 of Getting Started with EK9 shows it: a constrained type the tool built in one call - a base type and a range rule - with the function and program that use it, logic you typed. The same three tools - ek9_new_construct (twice: 'type'/'constrained' and ... |
| Chapter 15: a constrained type, built | Where this lesson comes from | For AI assistants - the MCP tool ek9_new_construct, ek9_add_program. |
| Chapter 15: promoting a constrained type, built | Chapter 15: promoting a constrained type, built | A DrivingAge is an Integer inside a rule. Sometimes other code just wants the plain Integer, and #^ promotes the one to the other - a fresh copy that leaves the rule behind, so changing it never changes the DrivingAge. The IDE's tools make the type and the function that wants an Integer; you type ... |
| Chapter 15: promoting a constrained type, built | Step 1: A constrained type | Choose Code > New Construct > Type > Constrained… The EK9 IDE once this is done: Choose Code > New Construct > Type > Constrained… DrivingAge is the constrained type's name. Choose Integer as its base type, then type its rule, >= 16 and <= 100, into the Constraint field. Choose Preview. The EK9 ... |
| Chapter 15: promoting a constrained type, built | Step 2: takesInteger — wants a plain Integer | Choose Code > New Construct > Function… The EK9 IDE once this is done: Choose Code > New Construct > Function… takesInteger is the function's name. Add one parameter, n of type Integer, and set Returns to Integer. Choose Preview. The EK9 IDE just before choosing Preview: takesInteger is the ... |
| Chapter 15: promoting a constrained type, built | Step 3: The program — promoting with #^ | Choose Code > New Construct > Program… The EK9 IDE once this is done: Choose Code > New Construct > Program… Show is the program's name. Choose Preview. The EK9 IDE just before choosing Preview: Show is the program's name The preview shows Show about to be written. Choose Apply. The EK9 IDE just ... |
| Chapter 15: promoting a constrained type, built | Step 4: Run it | Choose Run > Run Program… The EK9 IDE once this is done: Choose Run > Run Program… The project's only program is already chosen. Choose Run. age stays 17 while plain is now 22 - the copy changed, the DrivingAge did not - and takesInteger(#^ age) gives 18. Choose Close. The EK9 IDE just before ... |
| Chapter 15: promoting a constrained type, built | The result | Promotion.ek9 now reads exactly as chapter 15 of Getting Started with EK9 shows it: a constrained type and a function that takes a plain Integer, both made by the tools, and a program that promotes a DrivingAge with #^ - a separate copy that can change freely while the DrivingAge stays as it was. ... |
| Chapter 15: promoting a constrained type, built | Where this lesson comes from | For AI assistants - the MCP tool ek9_new_construct, ek9_add_program. |
| Chapter 15: stepping a constrained type, built | Chapter 15: stepping a constrained type, built | A constrained type keeps the operators of the type under it. DrivingAge is an Integer narrowed to 16 to 100, so ++ and -- still work on it - and the result is still a DrivingAge. The IDE's tool makes the type, base and rule, in one call; you type the program that steps one up and down. To play it ... |
| Chapter 15: stepping a constrained type, built | Step 1: A constrained type | Choose Code > New Construct > Type > Constrained… The EK9 IDE once this is done: Choose Code > New Construct > Type > Constrained… DrivingAge is the constrained type's name. Choose Integer as its base type, then type its rule, >= 16 and <= 100, into the Constraint field. Choose Preview. The EK9 ... |
| Chapter 15: stepping a constrained type, built | Step 2: The program — stepping with ++ and -- | Choose Code > New Construct > Program… The EK9 IDE once this is done: Choose Code > New Construct > Program… Show is the program's name. Choose Preview. The EK9 IDE just before choosing Preview: Show is the program's name The preview shows Show about to be written. Choose Apply. The EK9 IDE just ... |
| Chapter 15: stepping a constrained type, built | Step 3: Run it | Choose Run > Run Program… The EK9 IDE once this is done: Choose Run > Run Program… The project's only program is already chosen. Choose Run. after ++ : 18 and still set, then after two -- : 16 - the value moved in place and stayed a DrivingAge throughout. Choose Close. The EK9 IDE just before ... |
| Chapter 15: stepping a constrained type, built | The result | Increment.ek9 now reads exactly as chapter 15 of Getting Started with EK9 shows it: a constrained type the tool built in one call, and a program that steps a DrivingAge up and down with ++ and -- - each change in place, and the value still a DrivingAge, still inside its rule. The EK9 IDE when the ... |
| Chapter 15: stepping a constrained type, built | Where this lesson comes from | For AI assistants - the MCP tool ek9_new_construct, ek9_add_program. |
| Chapter 16: a class, built | Chapter 16: a class, built | Chapter 16 builds a class: Counter, counting ticks, and the program that runs it three times. The IDE's own tools make the structure - the class, the field's declaration, each method's whole signature, the program's shell - so what is left to type is only the logic no tool can write: what tick ... |
| Chapter 16: a class, built | Step 1: A class | Choose Code > New Construct > Class… The EK9 IDE once this is done: Choose Code > New Construct > Class… Counter is the class's name. Closed is already selected - EK9's default: a class is closed to extension unless it says 'as open' or 'as abstract'. Choose Preview. The EK9 IDE just before ... |
| Chapter 16: a class, built | Step 2: A field | Right-click the Counter line and choose Add Field… The EK9 IDE once this is done: Right-click the Counter line and choose Add Field… Type count as Integer: 0 - a field, its type, and the value it starts with. Choose OK. The EK9 IDE just before choosing OK: Type count as Integer The preview shows ... |
| Chapter 16: a class, built | Step 3: tick — and its logic | Right-click the Counter line and choose Add Method… The EK9 IDE once this is done: Right-click the Counter line and choose Add Method… tick is the method's name. It changes count, so it is not pure. Choose Apply. The EK9 IDE just before choosing Apply: tick is the method's name Select the stub, ... |
| Chapter 16: a class, built | Step 4: total — and its logic | Right-click the Counter line and choose Add Method… The EK9 IDE once this is done: Right-click the Counter line and choose Add Method… total is the method's name. total only reads count, it changes nothing. Set Return type to Integer and tick pure. Choose Apply. The EK9 IDE just before choosing ... |
| Chapter 16: a class, built | Step 5: The program | Choose Code > New Construct > Program… The EK9 IDE once this is done: Choose Code > New Construct > Program… Show is the program's name. No application, no parameters, nothing injected: the plain shape every Getting Started program starts from. Choose Preview. The EK9 IDE just before choosing ... |
| Chapter 16: a class, built | Step 6: Run it | Choose Run > Run Program… The EK9 IDE once this is done: Choose Run > Run Program… The project's only program is already chosen. Choose Run. clicks so far: 3 - tick() ran three times, and total() reads count back as an Integer. Choose Close. The EK9 IDE just before choosing Close: clicks so far |
| Chapter 16: a class, built | The result | Counter.ek9 now reads exactly as chapter 16 of Getting Started with EK9 shows it: a class the tools built, logic you typed. The same four tools - ek9_new_construct, ek9_add_field, ek9_add_method, ek9_add_program - are what an AI assistant calls to do the same thing. The EK9 IDE when the lesson ... |
| Chapter 16: a class, built | Where this lesson comes from | For AI assistants - the MCP tool ek9_new_construct, ek9_add_field, ek9_add_method, ek9_add_program. |
| Chapter 16: a class that hands out a copy, built | Chapter 16: a class that hands out a copy, built | Chapter 16's ScoreBoard keeps a list of scores and the best so far, and answers summary() with a Summary record that holds copies - so a snapshot never changes behind your back. The IDE's tools make the record, the class, its fields and both methods' signatures; you type only the logic. To play ... |
| Chapter 16: a class that hands out a copy, built | Step 1: A record for the figures | Choose Code > New Construct > Record… The EK9 IDE once this is done: Choose Code > New Construct > Record… Summary is the record's name. Add count and best, both Integer, each starting at Integer(). Choose Preview. The EK9 IDE just before choosing Preview: Summary is the record's name The preview ... |
| Chapter 16: a class that hands out a copy, built | Step 2: A class | Choose Code > New Construct > Class… The EK9 IDE once this is done: Choose Code > New Construct > Class… ScoreBoard is the class's name. Choose Preview. The EK9 IDE just before choosing Preview: ScoreBoard is the class's name The preview shows ScoreBoard about to be written, in a defines class ... |
| Chapter 16: a class that hands out a copy, built | Step 3: Two fields | Right-click the ScoreBoard line and choose Add Field… The EK9 IDE once this is done: Right-click the ScoreBoard line and choose Add Field… Type scores as List of Integer: List() of Integer - a List of Integer, empty to start with. Choose OK. The EK9 IDE just before choosing OK: Type scores as ... |
| Chapter 16: a class that hands out a copy, built | Step 4: add — a method with a parameter | Right-click the ScoreBoard line and choose Add Method… The EK9 IDE once this is done: Right-click the ScoreBoard line and choose Add Method… add is the method's name. It changes the board, so it is not pure. Add one parameter, points of type Integer. Choose Apply. The EK9 IDE just before choosing ... |
| Chapter 16: a class that hands out a copy, built | Step 5: summary — a copy, not a view | Right-click the ScoreBoard line and choose Add Method… The EK9 IDE once this is done: Right-click the ScoreBoard line and choose Add Method… summary is the method's name. It only reads. Set Return type to Summary and tick pure. Choose Apply. The EK9 IDE just before choosing Apply: summary is the ... |
| Chapter 16: a class that hands out a copy, built | Step 6: The program | Choose Code > New Construct > Program… The EK9 IDE once this is done: Choose Code > New Construct > Program… Show is the program's name. Choose Preview. The EK9 IDE just before choosing Preview: Show is the program's name The preview shows Show about to be written. Choose Apply. The EK9 IDE just ... |
| Chapter 16: a class that hands out a copy, built | Step 7: Run it | Choose Run > Run Program… The EK9 IDE once this is done: Choose Run > Run Program… The project's only program is already chosen. Choose Run. snapshot after two: 2 scores, best 70 - then, after a third score, the snapshot is unchanged while the live summary reads 3 scores, best 90. Choose Close. ... |
| Chapter 16: a class that hands out a copy, built | The result | ScoreBoard.ek9 now reads exactly as chapter 16 of Getting Started with EK9 shows it: a class that hands out a Summary - a record built from copies of its figures - so a snapshot taken early is unchanged by later scores. The tools wrote the structure; the logic is what you typed. ... |
| Chapter 16: a class that hands out a copy, built | Where this lesson comes from | For AI assistants - the MCP tool ek9_new_construct, ek9_add_constructor, ek9_add_operator, ek9_add_field, ek9_add_method, ek9_add_program. |
| Chapter 16: a class that needs an owner, built | Chapter 16: a class that needs an owner, built | Chapter 16's Account is a class that must have an owner: there is no sensible starting value for one, so the no-argument constructor is sealed off and the only way to make an Account is to name its owner. The IDE's tools make the class, its fields' shape, the sealed constructor and each method's ... |
| Chapter 16: a class that needs an owner, built | Step 1: A class | Choose Code > New Construct > Class… The EK9 IDE once this is done: Choose Code > New Construct > Class… Account is the class's name. Choose Preview. The EK9 IDE just before choosing Preview: Account is the class's name The preview shows Account about to be written. Choose Apply. The EK9 IDE just ... |
| Chapter 16: a class that needs an owner, built | Step 2: A field with a starting value | Right-click the Account line and choose Add Field… The EK9 IDE once this is done: Right-click the Account line and choose Add Field… Type balance as Integer: 0 - a balance can sensibly start at zero. Choose OK. The EK9 IDE just before choosing OK: Type balance as Integer The preview shows balance ... |
| Chapter 16: a class that needs an owner, built | Step 3: Sealing the no-argument constructor | Right-click the Account line and choose Add Constructor > Private No-Arg (default, pure) - the compiler's own no-argument constructor, but private: nothing outside Account can call it. The EK9 IDE once this is done: Right-click the Account line and choose Add Constructor > Private No-Arg ... |
| Chapter 16: a class that needs an owner, built | Step 4: A field with no starting value — and its constructor | An owner has no sensible starting value, so owner is declared as String? - a slot that stays empty until something is assigned. Type it, with its comment, straight under the class name. The file now has an error: nothing sets owner yet. Saves when typed. The EK9 IDE once this is done: An owner ... |
| Chapter 16: a class that needs an owner, built | Step 5: deposit — a method with a parameter | Right-click the Account line and choose Add Method… The EK9 IDE once this is done: Right-click the Account line and choose Add Method… deposit is the method's name. It changes balance, so it is not pure. Add one parameter, amount of type Integer. Choose Apply. The EK9 IDE just before choosing ... |
| Chapter 16: a class that needs an owner, built | Step 6: statement | Right-click the Account line and choose Add Method… The EK9 IDE once this is done: Right-click the Account line and choose Add Method… statement is the method's name. It only reads. Set Return type to String and tick pure. Choose Apply. The EK9 IDE just before choosing Apply: statement is the ... |
| Chapter 16: a class that needs an owner, built | Step 7: The program | Choose Code > New Construct > Program… The EK9 IDE once this is done: Choose Code > New Construct > Program… Show is the program's name. Choose Preview. The EK9 IDE just before choosing Preview: Show is the program's name The preview shows Show about to be written. Choose Apply. The EK9 IDE just ... |
| Chapter 16: a class that needs an owner, built | Step 8: Run it | Choose Run > Run Program… The EK9 IDE once this is done: Choose Run > Run Program… The project's only program is already chosen. Choose Run. Sam has 100 - account set? true: two deposits of 30 and 70, and an Account that exists only because it has an owner. Choose Close. The EK9 IDE just before ... |
| Chapter 16: a class that needs an owner, built | The result | Account.ek9 now reads exactly as chapter 16 of Getting Started with EK9 shows it: a class that can never exist without an owner, built by the tools, with only the logic and the one field no tool may write alone typed. ek9_new_construct, ek9_add_field, ek9_add_constructor, ek9_add_method and ... |
| Chapter 16: a class that needs an owner, built | Where this lesson comes from | For AI assistants - the MCP tool ek9_new_construct, ek9_add_field, ek9_add_constructor, ek9_add_method, ek9_add_program. |
| Chapter 17: an abstract type and its subtypes, built | Chapter 17: an abstract type and its subtypes, built | Chapter 17 builds a type hierarchy: Shape, an abstract contract with no body of its own, and two subtypes - Circle and Rectangle - that each complete it in their own way. The IDE's own tools make the structure - the constant, the abstract class and its two abstract methods, each subtype's field, ... |
| Chapter 17: an abstract type and its subtypes, built | Step 1: A constant | Choose Code > New Construct > Constant… The EK9 IDE once this is done: Choose Code > New Construct > Constant… PI is the constant's name and 3.14159 its value - a literal in the Value field, from which the type is inferred. Type both and choose Preview. The EK9 IDE just before choosing Preview: ... |
| Chapter 17: an abstract type and its subtypes, built | Step 2: An abstract type | Choose Code > New Construct > Class… The EK9 IDE once this is done: Choose Code > New Construct > Class… Shape is the class's name. Shape is a contract, not a thing: it will declare what a shape must answer, never how. Choose Abstract under Extensibility. Choose Preview. The EK9 IDE just before ... |
| Chapter 17: an abstract type and its subtypes, built | Step 3: Circle — a subtype | Choose Code > New Construct > Class… The EK9 IDE once this is done: Choose Code > New Construct > Class… Circle is the class's name. It completes the contract Shape names, and need not be extended further. Type Shape into Extends. Choose Preview. The EK9 IDE just before choosing Preview: Circle ... |
| Chapter 17: an abstract type and its subtypes, built | Step 4: Rectangle — another subtype | Choose Code > New Construct > Class… The EK9 IDE once this is done: Choose Code > New Construct > Class… Rectangle is the class's name. Shape is the same Extends as Circle's. Type Shape into Extends. Choose Preview. The EK9 IDE just before choosing Preview: Rectangle is the class's name The ... |
| Chapter 17: an abstract type and its subtypes, built | Step 5: The program | Choose Code > New Construct > Program… The EK9 IDE once this is done: Choose Code > New Construct > Program… Show is the program's name. Choose Preview. The EK9 IDE just before choosing Preview: Show is the program's name The preview shows Show about to be written. Choose Apply. The EK9 IDE just ... |
| Chapter 17: an abstract type and its subtypes, built | Step 6: Run it | Choose Run > Run Program… The EK9 IDE once this is done: Choose Run > Run Program… The project's only program is already chosen. Choose Run. a circle has area 12.56636 then a rectangle has area 12.0 - one loop, one call to area() each time, and the right formula runs for each shape without ever ... |
| Chapter 17: an abstract type and its subtypes, built | The result | Shapes.ek9 now reads exactly as chapter 17 of Getting Started with EK9 shows it: an abstract Shape the tools built with two abstract methods and no body to type, two subtypes each with its own field, constructor and overrides, and a program that holds both in one List of Shape - logic you typed. ... |
| Chapter 17: an abstract type and its subtypes, built | Where this lesson comes from | For AI assistants - the MCP tool ek9_new_construct, ek9_add_field, ek9_add_constructor, ek9_add_method, ek9_add_program. |
| Chapter 17: a family of records, built | Chapter 17: a family of records, built | Chapter 17's Contacts shows polymorphism with records: Contact says every contact can print itself but not how; Email and Phone each say how. The IDE builds the records, the operators' shapes and the constructors; you type only what no tool can. To play it in the IDE: Help > Lessons > Getting ... |
| Chapter 17: a family of records, built | Step 1: An abstract record with an abstract operator | Choose Code > New Construct > Record… The EK9 IDE once this is done: Choose Code > New Construct > Record… Contact is the record's name. A record that is abstract needs no fields. Choose Abstract under Extensibility. Choose Preview. The EK9 IDE just before choosing Preview: Contact is the ... |
| Chapter 17: a family of records, built | Step 2: Email — extends it | Choose Code > New Construct > Record… The EK9 IDE once this is done: Choose Code > New Construct > Record… Email is the record's name. Type Contact into Extends. The Fields table holds address of type String, starting at String(). Choose Preview. The EK9 IDE just before choosing Preview: Email is ... |
| Chapter 17: a family of records, built | Step 3: Phone — extends it too | Choose Code > New Construct > Record… The EK9 IDE once this is done: Choose Code > New Construct > Record… Phone is the record's name. Contact is the parent again. Type Contact into Extends. The Fields table holds number of type String, starting at String(). Choose Preview. The EK9 IDE just ... |
| Chapter 17: a family of records, built | Step 4: One list, two kinds | Choose Code > New Construct > Program… The EK9 IDE once this is done: Choose Code > New Construct > Program… Show is the program's name. Choose Preview. The EK9 IDE just before choosing Preview: Show is the program's name The preview shows Show about to be written. Choose Apply. The EK9 IDE just ... |
| Chapter 17: a family of records, built | Step 5: Run it | Choose Run > Run Program… The EK9 IDE once this is done: Choose Run > Run Program… The project's only program is already chosen. Choose Run. email sam@example.com, then phone 555-0100 - one List of Contact, each element printing itself its own way. Choose Close. The EK9 IDE just before choosing ... |
| Chapter 17: a family of records, built | The result | Contacts.ek9 now reads exactly as chapter 17 of Getting Started with EK9 shows it: Contact is an abstract record whose $ every subtype must supply, and one List of Contact holds an Email and a Phone that each print their own way. New Construct ▸ Record… with an Extends: parent wrote each ... |
| Chapter 17: a family of records, built | Where this lesson comes from | For AI assistants - the MCP tool ek9_new_construct, ek9_add_operator, ek9_add_constructor, ek9_add_program. |
| Chapter 18: traits that build on a trait, built | Chapter 18: traits that build on a trait, built | Chapter 18's Animals mixes behaviour into animals with traits: Named says every trait-bearing thing has a name; Swimmer, Flyer and Walker each build on Named and add one ability; Penguin, Duck and Crocodile take the ones that suit them. The IDE builds each construct and wires the traits; you type ... |
| Chapter 18: traits that build on a trait, built | Step 1: A trait with an abstract method | Choose Code > New Construct > Trait… The EK9 IDE once this is done: Choose Code > New Construct > Trait… Named is the trait's name. Choose Preview. The EK9 IDE just before choosing Preview: Named is the trait's name The preview shows Named about to be written. Choose Apply. The EK9 IDE just ... |
| Chapter 18: traits that build on a trait, built | Step 2: Traits that adopt a trait | Choose Code > New Construct > Trait… The EK9 IDE once this is done: Choose Code > New Construct > Trait… Swimmer is the trait's name. Choose Preview. The EK9 IDE just before choosing Preview: Swimmer is the trait's name The preview shows Swimmer about to be written. Choose Apply. The EK9 IDE just ... |
| Chapter 18: traits that build on a trait, built | Step 3: An abstract class | Choose Code > New Construct > Class… The EK9 IDE once this is done: Choose Code > New Construct > Class… Animal is the class's name. Choose Abstract under Extensibility. Choose Preview. The EK9 IDE just before choosing Preview: Animal is the class's name The preview shows Animal as abstract. ... |
| Chapter 18: traits that build on a trait, built | Step 4: Bird and Reptile | Choose Code > New Construct > Class… The EK9 IDE once this is done: Choose Code > New Construct > Class… Bird is the class's name. Type Animal into Extends. Choose Abstract under Extensibility. Choose Preview. The EK9 IDE just before choosing Preview: Bird is the class's name The preview shows ... |
| Chapter 18: traits that build on a trait, built | Step 5: Penguin — a class with two traits | Choose Code > New Construct > Class… The EK9 IDE once this is done: Choose Code > New Construct > Class… Penguin is the class's name. Type Bird into Extends. Choose Preview. The EK9 IDE just before choosing Preview: Penguin is the class's name The preview shows Penguin extends Bird, with the ... |
| Chapter 18: traits that build on a trait, built | Step 6: Duck — three traits | Choose Code > New Construct > Class… The EK9 IDE once this is done: Choose Code > New Construct > Class… Duck is the class's name. Type Bird into Extends. Choose Preview. The EK9 IDE just before choosing Preview: Duck is the class's name The preview shows Duck extends Bird, with the override its ... |
| Chapter 18: traits that build on a trait, built | Step 7: Crocodile | Choose Code > New Construct > Class… The EK9 IDE once this is done: Choose Code > New Construct > Class… Crocodile is the class's name. Type Reptile into Extends. Choose Preview. The EK9 IDE just before choosing Preview: Crocodile is the class's name The preview shows Crocodile extends Reptile, ... |
| Chapter 18: traits that build on a trait, built | Step 8: The program | Choose Code > New Construct > Program… The EK9 IDE once this is done: Choose Code > New Construct > Program… Show is the program's name. Choose Preview. The EK9 IDE just before choosing Preview: Show is the program's name The preview shows Show about to be written. Choose Apply. The EK9 IDE just ... |
| Chapter 18: traits that build on a trait, built | Step 9: Run it | Choose Run > Run Program… The EK9 IDE once this is done: Choose Run > Run Program… The project's only program is already chosen. Choose Run. The penguin (a bird) flies through the water on stubby wings and walks on land - the duck swims, flies and walks - then the penguin and the crocodile each ... |
| Chapter 18: traits that build on a trait, built | The result | Animals.ek9 now reads exactly as chapter 18 of Getting Started with EK9 shows it: behaviour mixed into animals from three traits that each build on Named, with Animal's own branch of the family alongside. Adopt Trait… on a trait's name line wrote 'with trait of Named' and no stubs - a trait ... |
| Chapter 18: traits that build on a trait, built | Where this lesson comes from | For AI assistants - the MCP tool ek9_new_construct, ek9_add_method, ek9_adopt_trait, ek9_add_operator, ek9_add_program. |
| Chapter 18: traits and delegation, built | Chapter 18: traits and delegation, built | Chapter 18 builds a trait, View, with no state of its own - and two classes that take it on two different ways: Home implements it, Framed delegates to a field it holds. The IDE's own tools make the structure - the trait's shell, each method's whole signature, the trait adoption itself, the ... |
| Chapter 18: traits and delegation, built | Step 1: A trait | Choose Code > New Construct > Trait… The EK9 IDE once this is done: Choose Code > New Construct > Trait… View is the trait's name. Choose Preview. The EK9 IDE just before choosing Preview: View is the trait's name The preview shows View about to be written - a shell, nothing inside it yet. Choose ... |
| Chapter 18: traits and delegation, built | Step 2: Home — implementing it | Choose Code > New Construct > Class… The EK9 IDE once this is done: Choose Code > New Construct > Class… Home is the class's name. Choose Preview. The EK9 IDE just before choosing Preview: Home is the class's name The preview shows Home about to be written. Choose Apply. The EK9 IDE just before ... |
| Chapter 18: traits and delegation, built | Step 3: Framed — the field and delegation | Choose Code > New Construct > Class… The EK9 IDE once this is done: Choose Code > New Construct > Class… Framed is the class's name. Choose Preview. The EK9 IDE just before choosing Preview: Framed is the class's name The preview shows Framed about to be written. Choose Apply. The EK9 IDE just ... |
| Chapter 18: traits and delegation, built | Step 4: Framed — construction and body | Select the stub, from Framed() as pure down to this.inner :=? inner, and type Framed's real one: a renamed parameter, viewToWrap, a require guard, and the assignment it guards. Saves when typed. The EK9 IDE once this is done: Select the stub, from Framed() as pure down to this.inner :=? inner, ... |
| Chapter 18: traits and delegation, built | Step 5: The program | Choose Code > New Construct > Program… The EK9 IDE once this is done: Choose Code > New Construct > Program… Show is the program's name. Choose Preview. The EK9 IDE just before choosing Preview: Show is the program's name The preview shows Show about to be written. Choose Apply. The EK9 IDE just ... |
| Chapter 18: traits and delegation, built | Step 6: Run it | Choose Run > Run Program… The EK9 IDE once this is done: Choose Run > Run Program… The project's only program is already chosen. Choose Run. title: Home, body: *** Welcome *** - title passes straight through the delegation, body is wrapped. Choose Close. The EK9 IDE just before choosing Close: title |
| Chapter 18: traits and delegation, built | The result | Delegate.ek9 now reads exactly as chapter 18 of Getting Started with EK9 shows it: a trait the tools built, Home implementing it and Framed delegating to a field it holds, logic you typed. The same tools - ek9_new_construct, ek9_add_method, ek9_adopt_trait, ek9_add_field, ek9_add_constructor, ... |
| Chapter 18: traits and delegation, built | Where this lesson comes from | For AI assistants - the MCP tool ek9_new_construct, ek9_add_method, ek9_adopt_trait, ek9_add_field, ek9_add_constructor, ek9_add_operator, ek9_add_program. |
| Chapter 18: two traits, one method, built | Chapter 18: two traits, one method, built | Chapter 18's TraitClash asks what happens when two traits both declare the same method. Priced says lowCost is true, Monitored says it is false - and a Widget that wants both cannot have both. EK9 never picks a winner: the Widget must write its own lowCost and say what it means. The order matters ... |
| Chapter 18: two traits, one method, built | Step 1: Priced — lowCost is true | Choose Code > New Construct > Trait… The EK9 IDE once this is done: Choose Code > New Construct > Trait… Priced is the trait's name. Choose Preview. The EK9 IDE just before choosing Preview: Priced is the trait's name The preview shows Priced about to be written. Choose Apply. The EK9 IDE just ... |
| Chapter 18: two traits, one method, built | Step 2: Monitored — lowCost is false | Choose Code > New Construct > Trait… The EK9 IDE once this is done: Choose Code > New Construct > Trait… Monitored is the trait's name. Choose Preview. The EK9 IDE just before choosing Preview: Monitored is the trait's name The preview shows Monitored about to be written. Choose Apply. The EK9 ... |
| Chapter 18: two traits, one method, built | Step 3: Widget — two traits, one lowCost | Choose Code > New Construct > Trait… The EK9 IDE once this is done: Choose Code > New Construct > Trait… Widget is the trait's name. Choose Preview. The EK9 IDE just before choosing Preview: Widget is the trait's name The preview shows Widget about to be written. Choose Apply. The EK9 IDE just ... |
| Chapter 18: two traits, one method, built | Step 4: Gadget | Choose Code > New Construct > Class… The EK9 IDE once this is done: Choose Code > New Construct > Class… Gadget is the class's name. Choose Preview. The EK9 IDE just before choosing Preview: Gadget is the class's name The preview shows Gadget. Choose Apply. The EK9 IDE just before choosing Apply: ... |
| Chapter 18: two traits, one method, built | Step 5: The program | Choose Code > New Construct > Program… The EK9 IDE once this is done: Choose Code > New Construct > Program… Show is the program's name. Choose Preview. The EK9 IDE just before choosing Preview: Show is the program's name The preview shows Show about to be written. Choose Apply. The EK9 IDE just ... |
| Chapter 18: two traits, one method, built | Step 6: Run it | Choose Run > Run Program… The EK9 IDE once this is done: Choose Run > Run Program… The project's only program is already chosen. Choose Run. lowCost? true - Gadget takes Widget's lowCost, and Widget chose Priced's. Choose Close. The EK9 IDE just before choosing Close: lowCost? true - Gadget takes ... |
| Chapter 18: two traits, one method, built | The result | TraitClash.ek9 now reads exactly as chapter 18 of Getting Started with EK9 shows it: two traits that disagree about lowCost, a Widget that says which it means by writing its own and naming Priced's, and a Gadget that simply takes Widget. EK9 never picks a winner for you - leave the override out ... |
| Chapter 18: two traits, one method, built | Where this lesson comes from | For AI assistants - the MCP tool ek9_new_construct, ek9_add_method, ek9_adopt_trait, ek9_add_program. |
| Chapter 18: a sealed family, built | Chapter 18: a sealed family, built | Chapter 18 ends by sealing a family: Payment may be implemented by Card and Cash and by nothing else. The IDE builds the trait, the two classes and the sealing; what is typed is the logic no tool can write. Sealing lists types that already exist, so it comes after them. To play it in the IDE: ... |
| Chapter 18: a sealed family, built | Step 1: A trait, and its abstract method | Choose Code > New Construct > Trait… The EK9 IDE once this is done: Choose Code > New Construct > Trait… Payment is the trait's name. Choose Preview. The EK9 IDE just before choosing Preview: Payment is the trait's name The preview shows Payment about to be written. Choose Apply. The EK9 IDE just ... |
| Chapter 18: a sealed family, built | Step 2: Card | Choose Code > New Construct > Class… The EK9 IDE once this is done: Choose Code > New Construct > Class… Card is the class's name. Choose Preview. The EK9 IDE just before choosing Preview: Card is the class's name The preview shows Card about to be written. Choose Apply. The EK9 IDE just before ... |
| Chapter 18: a sealed family, built | Step 3: Cash | Choose Code > New Construct > Class… The EK9 IDE once this is done: Choose Code > New Construct > Class… Cash is the class's name. Choose Preview. The EK9 IDE just before choosing Preview: Cash is the class's name The preview shows Cash about to be written. Choose Apply. The EK9 IDE just before ... |
| Chapter 18: a sealed family, built | Step 4: Sealing the family | Right-click the Payment line and choose Change Modifier > Seal Type… The EK9 IDE once this is done: Right-click the Payment line and choose Change Modifier > Seal Type… Card and Cash are already ticked - every existing implementor must stay listed. Choose Preview. The preview shows Payment ... |
| Chapter 18: a sealed family, built | Step 5: The program | Choose Code > New Construct > Program… The EK9 IDE once this is done: Choose Code > New Construct > Program… Show is the program's name. Choose Preview. The EK9 IDE just before choosing Preview: Show is the program's name The preview shows Show about to be written. Choose Apply. The EK9 IDE just ... |
| Chapter 18: a sealed family, built | Step 6: Run it | Choose Run > Run Program… The EK9 IDE once this is done: Choose Run > Run Program… The project's only program is already chosen. Choose Run. amount 100 - the Payment is a Card, and only a Card or a Cash can ever be one. Choose Close. The EK9 IDE just before choosing Close: amount 100 - the ... |
| Chapter 18: a sealed family, built | The result | AllowOnly.ek9 now reads exactly as chapter 18 of Getting Started with EK9 shows it: Payment is a closed family - exactly Card and Cash - and the compiler will refuse a third. Seal Type had to come last, because it lists types that must already exist; Unseal Type and Add to Allowlist… sit beside ... |
| Chapter 18: a sealed family, built | Where this lesson comes from | For AI assistants - the MCP tool ek9_new_construct, ek9_add_method, ek9_adopt_trait, ek9_add_operator, ek9_seal_type, ek9_add_program. |
| Chapter 19: a component, built | Chapter 19: a component, built | Chapter 19 builds a component: Pricing, an interface hiding the types that work out a price - a TaxTable class and a basePrice function - behind ONE method, totalPrice. The program depends on Pricing alone; it never mentions TaxTable or basePrice. The IDE's own tools make the structure - each ... |
| Chapter 19: a component, built | Step 1: TaxTable — and surcharge | Choose Code > New Construct > Class… The EK9 IDE once this is done: Choose Code > New Construct > Class… TaxTable is the class's name. It is a helper behind the interface, never mentioned by the program. Choose Preview. The EK9 IDE just before choosing Preview: TaxTable is the class's name The ... |
| Chapter 19: a component, built | Step 2: basePrice | Choose Code > New Construct > Function… The EK9 IDE once this is done: Choose Code > New Construct > Function… basePrice is the function's name. Set Returns to Money. Choose Preview. The EK9 IDE just before choosing Preview: basePrice is the function's name The preview shows basePrice about to be ... |
| Chapter 19: a component, built | Step 3: Pricing — the interface | Choose Code > New Construct > Component… The EK9 IDE once this is done: Choose Code > New Construct > Component… Pricing is the component's name. It is the interface everything else hides behind. Choose Abstract under Extensibility. Choose Preview. The EK9 IDE just before choosing Preview: ... |
| Chapter 19: a component, built | Step 4: StandardPricing — and its logic | Choose Code > New Construct > Component… The EK9 IDE once this is done: Choose Code > New Construct > Component… StandardPricing is the component's name. It completes the interface Pricing names. Type Pricing into Extends. Choose Preview. The EK9 IDE just before choosing Preview: StandardPricing ... |
| Chapter 19: a component, built | Step 5: The program | Choose Code > New Construct > Program… The EK9 IDE once this is done: Choose Code > New Construct > Program… Show is the program's name. Choose Preview. The EK9 IDE just before choosing Preview: Show is the program's name The preview shows Show about to be written. Choose Apply. The EK9 IDE just ... |
| Chapter 19: a component, built | Step 6: Run it | Choose Run > Run Program… The EK9 IDE once this is done: Choose Run > Run Program… The project's only program is already chosen. Choose Run. total price: 12.00#GBP - the base price plus the surcharge, worked out behind the Pricing interface the program never looks past. Choose Close. The EK9 IDE ... |
| Chapter 19: a component, built | The result | Pricing.ek9 now reads exactly as chapter 19 of Getting Started with EK9 shows it: a component hiding a class and a function behind an interface, logic you typed - StandardPricing's override arriving WITH the component itself, the moment its Extends names Pricing. The same tools - ... |
| Chapter 19: a component, built | Where this lesson comes from | For AI assistants - the MCP tool ek9_new_construct, ek9_add_method, ek9_add_program. |
| Chapter 20: a generic type, read | Chapter 20: a generic type, read | Chapter 20 names something you have been using since Collections without the word: List of String, Dict of (String, Integer), Optional and Result are all GENERIC - one definition with a gap, filled in when you use it. Show builds a List of String and a List of Integer side by side, then a Dict ... |
| Chapter 20: a generic type, read | Step 1: The program | Choose Code > New Construct > Program… The EK9 IDE once this is done: Choose Code > New Construct > Program… Show is the program's name. Choose Preview. The EK9 IDE just before choosing Preview: Show is the program's name The preview shows Show about to be written. Choose Apply. The EK9 IDE just ... |
| Chapter 20: a generic type, read | Step 2: Read names's Type Hierarchy | Select names, on the line that declares it, then choose Analyse ▸ Type Hierarchy: cursor-anchored, the same way Effective API reads the type under the caret. The EK9 IDE once this is done: Select names, on the line that declares it, then choose Analyse ▸ Type Hierarchy The pane draws two boxes: ... |
| Chapter 20: a generic type, read | Step 3: Read primes's Effective API | Select primes, on the line that declares it, then choose Analyse ▸ Effective API: the SAME pane Divide's Result read in chapter 11. The EK9 IDE once this is done: Select primes, on the line that declares it, then choose Analyse ▸ Effective API Above the sections, extends Any reads the same line ... |
| Chapter 20: a generic type, read | Step 4: Run it | Choose Run > Run Program… The EK9 IDE once this is done: Choose Run > Run Program… The project's only program is already chosen. Choose Run. names (List of String): ["Ada", "Alan"], then primes (List of Integer): [2, 3], then Ada scored 90 - the Dict literal read back by its own key. Choose ... |
| Chapter 20: a generic type, read | The result | Generics.ek9 now reads exactly as chapter 20 of Getting Started with EK9 shows it: one List, filled with String then with Integer, and a Dict literal alongside it - the same generic family you have used since Collections, named. Analyse ▸ Type Hierarchy then read List of String's own place in the ... |
| Chapter 20: a generic type, read | Where this lesson comes from | For AI assistants - the MCP tool ek9_new_construct, ek9_add_program, ek9_query_type_hierarchy, ek9_query_effective_api. |
| Chapter 21: operators, built | Chapter 21: operators, built | Chapter 21 gives a small vector its own + (add two vectors) and $ (how it prints), then defaults the rest: <=> for comparison, ? for whether it is set. The IDE's own tools make the structure - the record, each field's declaration, the constructor's and +'s whole signature - so what is left to ... |
| Chapter 21: operators, built | Step 1: A record, with its fields | Choose Code > New Construct > Record… The EK9 IDE once this is done: Choose Code > New Construct > Record… Vec2 is the record's name. Add x and y, both Integer, each given a starting Value of Integer() - a freshly made but unset Integer - so the record needs no constructor of its own yet. Choose ... |
| Chapter 21: operators, built | Step 2: Its constructor — and its logic | Right-click the Vec2 line and choose Add Constructor > From All Fields (pure). The EK9 IDE once this is done: Right-click the Vec2 line and choose Add Constructor > From All Fields (pure) Select the stub, from Vec2() as pure down to its last assignment, and type the constructor's whole job: ... |
| Chapter 21: operators, built | Step 3: operator + — a custom operator, and its logic | Right-click the Vec2 line and choose Add Operator > Custom Operator… The EK9 IDE once this is done: Right-click the Vec2 line and choose Add Operator > Custom Operator… is not one of the eight operators with their own menu entry - type it here, in Custom Operator…'s one field. Choose OK. The EK9 ... |
| Chapter 21: operators, built | Step 4: operator $ — and its logic | Right-click the Vec2 line and choose Add Operator > $ (string) > skeleton. The EK9 IDE once this is done: Right-click the Vec2 line and choose Add Operator > $ (string) > skeleton Select the stub line and type $'s own text form - just the two numbers in parentheses, no type name. Saves when ... |
| Chapter 21: operators, built | Step 5: default operator <=> | Right-click the Vec2 line and choose Add Operator > <=> (compare) > default. The EK9 IDE once this is done: Right-click the Vec2 line and choose Add Operator > <=> (compare) > default |
| Chapter 21: operators, built | Step 6: The program | Choose Code > New Construct > Program… The EK9 IDE once this is done: Choose Code > New Construct > Program… Show is the program's name. Choose Preview. The EK9 IDE just before choosing Preview: Show is the program's name The preview shows Show about to be written. Choose Apply. The EK9 IDE just ... |
| Chapter 21: operators, built | Step 7: Run it | Choose Run > Run Program… The EK9 IDE once this is done: Choose Run > Run Program… The project's only program is already chosen. Choose Run. (1, 2) + (3, 4) = (4, 6) - a == twin? true, a == b? false. Choose Close. The EK9 IDE just before choosing Close: (1, 2) + (3, 4) = (4, 6) - a == twin? true, ... |
| Chapter 21: operators, built | The result | Vectors.ek9 now reads exactly as chapter 21 of Getting Started with EK9 shows it: a record with its own + and $, default operator <=> and ? for the rest - built by the tools, logic you typed. ek9_add_operator - called here through a new Custom Operator… dialog, the same door an AI assistant ... |
| Chapter 21: operators, built | Where this lesson comes from | For AI assistants - the MCP tool ek9_new_construct, ek9_add_constructor, ek9_add_operator, ek9_add_program. |
| Chapter 21: every other operator, in one step | Chapter 21: every other operator, in one step | Chapter 21's Release is a version number - a major and a minor - that has to print as 1.5 yet sort and compare like any value. One operator is written by hand; the rest come from a single default operator line. The IDE's tools write the record, the constructor's shell and both operators; you type ... |
| Chapter 21: every other operator, in one step | Step 1: A record | Choose Code > New Construct > Record… The EK9 IDE once this is done: Choose Code > New Construct > Record… Release is the record's name. Add major and minor, both Integer, each starting at Integer(). Choose Preview. The EK9 IDE just before choosing Preview: Release is the record's name The ... |
| Chapter 21: every other operator, in one step | Step 2: Its constructor | Right-click the Release line and choose Add Constructor > From All Fields (pure). The EK9 IDE once this is done: Right-click the Release line and choose Add Constructor > From All Fields (pure) Select the stub, from Release() as pure down to its last assignment, and type the constructor the book ... |
| Chapter 21: every other operator, in one step | Step 3: One operator by hand | Right-click the Release line and choose Add Operator > $ (string) > skeleton. The EK9 IDE once this is done: Right-click the Release line and choose Add Operator > $ (string) > skeleton Select the stub line and type $'s own text form - major, a dot, minor. Saves when typed. The EK9 IDE once this ... |
| Chapter 21: every other operator, in one step | Step 4: Every other operator, in one step | Right-click the Release line and choose Add Operator > default operator (all missing) - one bare 'default operator' line, and the compiler works out == <=> < <= > >= <> $$ and the rest from the two fields. The EK9 IDE once this is done: Right-click the Release line and choose Add Operator > ... |
| Chapter 21: every other operator, in one step | Step 5: The program | Choose Code > New Construct > Program… The EK9 IDE once this is done: Choose Code > New Construct > Program… Show is the program's name. Choose Preview. The EK9 IDE just before choosing Preview: Show is the program's name The preview shows Show about to be written. Choose Apply. The EK9 IDE just ... |
| Chapter 21: every other operator, in one step | Step 6: Run it | Choose Run > Run Program… The EK9 IDE once this is done: Choose Run > Run Program… The project's only program is already chosen. Choose Run. sorted: 1.5, 2.0, 2.3 - a < b? true, a > b? false, as text 1.5, and as JSON the record's own two fields: every one worked out from a single default ... |
| Chapter 21: every other operator, in one step | The result | Versions.ek9 now reads exactly as chapter 21 of Getting Started with EK9 shows it: a Release that prints as 1.5 because its $ is written by hand, and sorts, compares and turns to JSON because one bare 'default operator' line lets the compiler work the rest out from its two fields. Add Operator ▸ ... |
| Chapter 21: every other operator, in one step | Where this lesson comes from | For AI assistants - the MCP tool ek9_new_construct, ek9_add_constructor, ek9_add_operator, ek9_add_program. |
| Chapter 21: promotion, #^ | Chapter 21: promotion, #^ | An Integer becomes a Float wherever a Float is wanted - 7 becomes 7.0 - through an operator, #^ (promote). Chapter 21 gives a type of your own one too: a Celsius that promotes itself to a Fahrenheit Float. The IDE's tools make the structure - the record, its field, the constructor and each ... |
| Chapter 21: promotion, #^ | Step 1: A record, with its field | Choose Code > New Construct > Record… The EK9 IDE once this is done: Choose Code > New Construct > Record… Celsius is the record's name. Add degrees, a Float, given a starting Value of Float() - a freshly made but unset Float - so the record needs no constructor of its own yet. Choose Preview. ... |
| Chapter 21: promotion, #^ | Step 2: Its constructor — and its logic | Right-click the Celsius line and choose Add Constructor > From All Fields (pure). The EK9 IDE once this is done: Right-click the Celsius line and choose Add Constructor > From All Fields (pure) Select the stub, from Celsius() as pure down to its assignment, and type the constructor's whole job: ... |
| Chapter 21: promotion, #^ | Step 3: operator $ — and its logic | Right-click the Celsius line and choose Add Operator > $ (string) > skeleton. The EK9 IDE once this is done: Right-click the Celsius line and choose Add Operator > $ (string) > skeleton Select the stub line and type $'s own text form - the degrees and a C, no type name. Saves when typed. The EK9 ... |
| Chapter 21: promotion, #^ | Step 4: operator #^ — promotion, and its logic | Right-click the Celsius line and choose Add Operator > Custom Operator… The EK9 IDE once this is done: Right-click the Celsius line and choose Add Operator > Custom Operator… #^ is not one of the eight operators with their own menu entry - type it here, in Custom Operator…'s one field. Choose OK. ... |
| Chapter 21: promotion, #^ | Step 5: The program — two promotions | Choose Code > New Construct > Program… The EK9 IDE once this is done: Choose Code > New Construct > Program… Show is the program's name. Choose Preview. The EK9 IDE just before choosing Preview: Show is the program's name The preview shows Show about to be written. Choose Apply. The EK9 IDE just ... |
| Chapter 21: promotion, #^ | Step 6: Run it | Choose Run > Run Program… The EK9 IDE once this is done: Choose Run > Run Program… The project's only program is already chosen. Choose Run. 100.0C is 212.0F - Celsius's own #^ - and 7 promoted to 7.0, Integer's. Choose Close. The EK9 IDE just before choosing Close: 100.0C is 212.0F - Celsius's ... |
| Chapter 21: promotion, #^ | The result | Celsius.ek9 now reads exactly as chapter 21 of Getting Started with EK9 shows it: a record with its own $ and a #^ that promotes it to a Fahrenheit Float, and a program where a Celsius and an Integer are each promoted to a Float - one #^ step each, no casts. Built by the tools, logic you typed. ... |
| Chapter 21: promotion, #^ | Where this lesson comes from | For AI assistants - the MCP tool ek9_new_construct, ek9_add_constructor, ek9_add_operator, ek9_add_program. |
| Chapter 22: a notes-keeper with options, built | Chapter 22: a notes-keeper with options, built | Chapter 22's Notes keeps lines of text in a file, and takes its wishes from the command line: -a adds a note, -f names the file, -v says what it is doing. The program itself stays thin - it works out what was asked for, then two small functions do the work: readNotes and writeNotes. The IDE makes ... |
| Chapter 22: a notes-keeper with options, built | Step 1: readNotes — the file into a list | Choose Code > New Construct > Function… The EK9 IDE once this is done: Choose Code > New Construct > Function… readNotes is the function's name. Add one parameter, file of type TextFile, and set Returns to List of String. Choose Preview. The EK9 IDE just before choosing Preview: readNotes is the ... |
| Chapter 22: a notes-keeper with options, built | Step 2: writeNotes — the list into the file | Choose Code > New Construct > Function… The EK9 IDE once this is done: Choose Code > New Construct > Function… writeNotes is the function's name. Add the parameters file of type TextFile and notes of type List of String. Choose Preview. The EK9 IDE just before choosing Preview: writeNotes is the ... |
| Chapter 22: a notes-keeper with options, built | Step 3: The thin entry point | Choose Code > New Construct > Program… The EK9 IDE once this is done: Choose Code > New Construct > Program… Notes is the program's name. Add one parameter, argv of type List of String - the command line. Choose Preview. The EK9 IDE just before choosing Preview: Notes is the program's name The ... |
| Chapter 22: a notes-keeper with options, built | Step 4: Run it with an option | Choose Run > Run Program… The EK9 IDE once this is done: Choose Run > Run Program… Type -a milk into Arguments (space-separated), then choose Run. The EK9 IDE just before choosing Run: Type -a milk into Arguments (space-separated), then choose Run notes (1): and milk - the file was created, read ... |
| Chapter 22: a notes-keeper with options, built | The result | Notes.ek9 now reads exactly as chapter 22 of Getting Started with EK9 shows it: two small functions that read and write the file, and a thin program that works out what was asked for from -v, -f and -a and lets them do the work. New Construct made each shell - the program's argv parameter in the ... |
| Chapter 22: a notes-keeper with options, built | Where this lesson comes from | For AI assistants - the MCP tool ek9_new_construct, ek9_add_program, ek9_run_program. |
| Chapter 22: a program with arguments, built | Chapter 22: a program with arguments, built | Chapter 22 closes with a setting that cannot live in the code at all: a web address. NoteLink takes one typed argument, a note's number, and builds a link to it on a server named by the NOTES_SERVER environment variable - never written into the source. The IDE's own tools make the program's whole ... |
| Chapter 22: a program with arguments, built | Step 1: NoteLink — the program | Choose Code > New Construct > Program… The EK9 IDE once this is done: Choose Code > New Construct > Program… NoteLink is the program's name. Add one CLI parameter, noteNumber of type Integer - EK9 parses the text on the command line into it. Choose Preview. The EK9 IDE just before choosing ... |
| Chapter 22: a program with arguments, built | Step 2: Run it, with an argument | Choose Run > Run Program… The EK9 IDE once this is done: Choose Run > Run Program… Type 7 into Arguments (space-separated), then choose Run. The EK9 IDE just before choosing Run: Type 7 into Arguments (space-separated), then choose Run NOTES_SERVER is not set to a web address - nothing has given ... |
| Chapter 22: a program with arguments, built | Step 3: Run it again, from a saved configuration | Choose Run > Configurations… The EK9 IDE once this is done: Choose Run > Configurations… Choose + New Configuration… - NoteLink is already the program it will belong to. Name it With server, type 7 into Arguments, and into Environment type NOTES_SERVER=https://notes.example.com - the one field ... |
| Chapter 22: a program with arguments, built | The result | NoteLink.ek9 now reads exactly as chapter 22 of Getting Started with EK9 shows it: one program, one typed parameter, and a URL read from an environment variable rather than written into the code. Running it with just the argument shows NOTES_SERVER is not set; saving a run configuration through ... |
| Chapter 22: a program with arguments, built | Where this lesson comes from | For AI assistants - the MCP tool ek9_add_program, ek9_run_program. |
| Chapter 23: the game, built and played | Chapter 23: the game, built and played | Chapter 23 is the whole book in one program: a number-guessing game, built from a record, a class, six small functions and a thin program that ties them to the keyboard - the biggest example in the book. The IDE's own tools make the structure - every field's declaration, every constructor's and ... |
| Chapter 23: the game, built and played | Step 1: Score — a record, with its fields | Choose Code > New Construct > Record… The EK9 IDE once this is done: Choose Code > New Construct > Record… Score is the record's name. Add who (String) and attempts (Integer), each given a starting Value - String()/Integer(), a freshly made but unset value - so the record needs no constructor of ... |
| Chapter 23: the game, built and played | Step 2: Building a Score, blank then complete | Right-click the Score line and choose Add Constructor > No-Arg (default, pure) - a blank Score to fall back on. The EK9 IDE once this is done: Right-click the Score line and choose Add Constructor > No-Arg (default, pure) - a blank Score to fall back on Right-click the Score line again and choose ... |
| Chapter 23: the game, built and played | Step 3: Score's own operators | Right-click the Score line and choose Add Operator > $ (string) > skeleton. The EK9 IDE once this is done: Right-click the Score line and choose Add Operator > $ (string) > skeleton Select the stub line and type $'s own text form - the name, then the tries in parentheses. Saves when typed. The ... |
| Chapter 23: the game, built and played | Step 4: Game — a class, with its first fields | Choose Code > New Construct > Class… The EK9 IDE once this is done: Choose Code > New Construct > Class… Game is the class's name. Closed is already selected - EK9's default. Choose Preview. The EK9 IDE just before choosing Preview: Game is the class's name The preview shows Game about to be ... |
| Chapter 23: the game, built and played | Step 5: Building a Game, blank then complete | Right-click the Game line and choose Add Constructor > Private No-Arg (default, pure) - private, so nothing outside the class can build a half-made game. The EK9 IDE once this is done: Right-click the Game line and choose Add Constructor > Private No-Arg (default, pure) - private, so nothing ... |
| Chapter 23: the game, built and played | Step 6: guess — taking one guess | Right-click the Game line and choose Add Method… The EK9 IDE once this is done: Right-click the Game line and choose Add Method… guess is the method's name. It changes tries and solved, so it is not pure. Add one parameter, number of type Integer, set Return type to String. Choose Apply. The EK9 ... |
| Chapter 23: the game, built and played | Step 7: over, triesUsed and report | Right-click the Game line and choose Add Method… The EK9 IDE once this is done: Right-click the Game line and choose Add Method… over is the method's name. over only reads the game's state. Set Return type to Boolean and tick pure. Choose Apply. The EK9 IDE just before choosing Apply: over is the ... |
| Chapter 23: the game, built and played | Step 8: hint and rank — two pure functions | Choose Code > New Construct > Function… The EK9 IDE once this is done: Choose Code > New Construct > Function… hint is the function's name. Add the parameters secret of type Integer and guess of type Integer, set Returns to String and tick pure. Choose Preview. The EK9 IDE just before choosing ... |
| Chapter 23: the game, built and played | Step 9: The board helpers | Choose Code > New Construct > Function… The EK9 IDE once this is done: Choose Code > New Construct > Function… startingBoard is the function's name. Set Returns to List of Score. Choose Preview. The EK9 IDE just before choosing Preview: startingBoard is the function's name The preview shows ... |
| Chapter 23: the game, built and played | Step 10: playerName — reading the command line | Choose Code > New Construct > Function… The EK9 IDE once this is done: Choose Code > New Construct > Function… playerName is the function's name. Add one parameter, argv of type List of String, set Returns to String. Choose Preview. The EK9 IDE just before choosing Preview: playerName is the ... |
| Chapter 23: the game, built and played | Step 11: The program — a thin shell | Choose Code > New Construct > Program… The EK9 IDE once this is done: Choose Code > New Construct > Program… Guess is the program's name. Its CLI parameter goes in the same dialog's own parameters table. Add one parameter, argv of type List of String. Choose Preview. The EK9 IDE just before ... |
| Chapter 23: the game, built and played | Step 12: Playing it, through the debugger | Click the debug (bug) icon beside the Guess() line - no saved configuration exists for it yet. The EK9 IDE once this is done: Click the debug (bug) icon beside the Guess() line - no saved configuration exists for it yet Choose + New Configuration… - this run needs a fixed seed, which only a saved ... |
| Chapter 23: the game, built and played | The result | Guess.ek9 now builds, compiles and plays exactly as chapter 23 describes it: a Score record, a Game class, six small functions and the program that connects them to Stdin, OS().random and GetOpt - built by the tools, logic you typed - then played for real, through the debugger: a win in four ... |
| Chapter 23: the game, built and played | Where this lesson comes from | For AI assistants - the MCP tool ek9_new_construct, ek9_add_field, ek9_add_constructor, ek9_add_method, ek9_add_operator, ek9_add_program, ek9_debug_session. |
| Chapter 23: running the tests, and the Journal | Chapter 23: running the tests, and the Journal | Chapter 23 ends two ways: fifteen tests that cover the record, the class and the functions, and a game you can actually play. This lesson plays the first ending, and then looks inside the class those tests already exercised, through the Journal. To play it in the IDE: Help > Lessons > Getting ... |
| Chapter 23: running the tests, and the Journal | Step 1: Running the tests | Run ▸ Run Tests (⌘T) runs every @Test in the project - all fifteen of them - and reports pass or fail, the same as ek9 -t at the command line. Choose Run Tests. The EK9 IDE once this is done: Run ▸ Run Tests (⌘T) runs every @Test in the project - all fifteen of them - and reports pass or fail, ... |
| Chapter 23: running the tests, and the Journal | Step 2: The Journal | Choose Run > New Journal Investigation… The EK9 IDE once this is done: Choose Run > New Journal Investigation… The project has several programs - Guess, and every @Test. Choose WinningGame, watch Game.tries, and leave the input sets blank: WinningGame takes no arguments, so one line is one run ... |
| Chapter 23: running the tests, and the Journal | The result | All fifteen tests pass, covering everything but the interactive loop - and the Journal showed exactly what WinningGame's own asserts already proved: tries counted up, one for each guess, inside a class that was tested long before the program that uses it ever ran. |
| Chapter 23: running the tests, and the Journal | Where this lesson comes from | For AI assistants - the MCP tool ek9_run_tests, ek9_debug_inspect. |
| Chapter 24: settings, an Optional and a Result, built | Chapter 24: settings, an Optional and a Result, built | Chapter 24 starts from a start-up routine that reads settings. One lookup may find nothing, so it returns an Optional; one parse may fail and says why, so it returns a Result. The program then reads them four ways: a guard, getOrDefault, matched isOk/isError checks, and callbacks. Java's get() is ... |
| Chapter 24: settings, an Optional and a Result, built | Step 1: Constants | Choose Code > New Construct > Constant… The EK9 IDE once this is done: Choose Code > New Construct > Constant… LOWEST_PORT is the constant's name and 1024 its value - a literal in the Value field, from which the type is inferred. Type both and choose Preview. The EK9 IDE just before choosing ... |
| Chapter 24: settings, an Optional and a Result, built | Step 2: setting — a pure function | Choose Code > New Construct > Function… The EK9 IDE once this is done: Choose Code > New Construct > Function… setting is the function's name. Add the parameters settings of type Dict of (String, String) and key of type String, set Returns to Optional of String and tick pure. Choose Preview. The ... |
| Chapter 24: settings, an Optional and a Result, built | Step 3: parsePort — a pure function | Choose Code > New Construct > Function… The EK9 IDE once this is done: Choose Code > New Construct > Function… parsePort is the function's name. Add one parameter, text of type String, set Returns to Result of (Integer, String) and tick pure. Choose Preview. The EK9 IDE just before choosing ... |
| Chapter 24: settings, an Optional and a Result, built | Step 4: showPort — a function | Choose Code > New Construct > Function… The EK9 IDE once this is done: Choose Code > New Construct > Function… showPort is the function's name. Add one parameter, port of type Integer. Choose Preview. The EK9 IDE just before choosing Preview: showPort is the function's name The preview shows ... |
| Chapter 24: settings, an Optional and a Result, built | Step 5: showProblem — a function | Choose Code > New Construct > Function… The EK9 IDE once this is done: Choose Code > New Construct > Function… showProblem is the function's name. Add one parameter, problem of type String. Choose Preview. The EK9 IDE just before choosing Preview: showProblem is the function's name The preview ... |
| Chapter 24: settings, an Optional and a Result, built | Step 6: The program | Choose Code > New Construct > Program… The EK9 IDE once this is done: Choose Code > New Construct > Program… StartServer is the program's name. Choose Preview. The EK9 IDE just before choosing Preview: StartServer is the program's name The preview shows StartServer about to be written. Choose ... |
| Chapter 24: settings, an Optional and a Result, built | Step 7: Run it | Choose Run > Run Program… The EK9 IDE once this is done: Choose Run > Run Program… The project's only program is already chosen. Choose Run. host: example.org, region: eu-west-1, then port and retries each refused with its reason, backlog not configured, and finally listening on 8080 and cannot ... |
| Chapter 24: settings, an Optional and a Result, built | The result | SettingsLookup.ek9 now reads exactly as chapter 24 of EK9 in Depth shows it. Every get(), ok() and error() sits inside the check that proves it - the guard, isOk() and isError() - and the two callbacks, whenOk and whenError, take a plain function and call it only on the side that is set. The EK9 ... |
| Chapter 24: settings, an Optional and a Result, built | Where this lesson comes from | For AI assistants - the MCP tool ek9_new_construct, ek9_add_program. |
| Chapter 24: the third safe container, built | Chapter 24: the third safe container, built | Optional and Result are not the only containers the compiler polices: an Iterator is the third. next() without a hasNext() is the same error as a bare get(). This program reads one iterator in a while loop and another, empty one, in an if. The IDE writes the program's shell; you type the two ... |
| Chapter 24: the third safe container, built | Step 1: The program | Choose Code > New Construct > Program… The EK9 IDE once this is done: Choose Code > New Construct > Program… Iteration is the program's name. Choose Preview. The EK9 IDE just before choosing Preview: Iteration is the program's name The preview shows Iteration about to be written. Choose Apply. ... |
| Chapter 24: the third safe container, built | Step 2: Run it | Choose Run > Run Program… The EK9 IDE once this is done: Choose Run > Run Program… The project's only program is already chosen. Choose Run. red, green, blue, then nothing to read - the empty iterator never reached next(). Choose Close. The EK9 IDE just before choosing Close: red, green, blue, ... |
| Chapter 24: the third safe container, built | The result | Iteration.ek9 now reads exactly as chapter 24 of EK9 in Depth shows it. Each next() sits inside the hasNext() that proves it - the loop's head, and the if's - so the empty iterator reaches the else. The EK9 IDE when the lesson has finished |
| Chapter 24: the third safe container, built | Where this lesson comes from | For AI assistants - the MCP tool ek9_add_program. |
| Chapter 24: the four states of a Result, built | Chapter 24: the four states of a Result, built | If you know Rust, a Result is Ok or Err and 'not Ok' means Err. In EK9 a Result has four states - neither side set, ok only, error only, or both - so the else of isOk() proves nothing about error(). This program builds all four and prints what each reports; a small pure helper, orUnset, makes an ... |
| Chapter 24: the four states of a Result, built | Step 1: orUnset — a pure function | Choose Code > New Construct > Function… The EK9 IDE once this is done: Choose Code > New Construct > Function… orUnset is the function's name. Add one parameter, text of type String, set Returns to String and tick pure. Choose Preview. The EK9 IDE just before choosing Preview: orUnset is the ... |
| Chapter 24: the four states of a Result, built | Step 2: The program | Choose Code > New Construct > Program… The EK9 IDE once this is done: Choose Code > New Construct > Program… FourStates is the program's name. Choose Preview. The EK9 IDE just before choosing Preview: FourStates is the program's name The preview shows FourStates about to be written. Choose Apply. ... |
| Chapter 24: the four states of a Result, built | Step 3: Run it | Choose Run > Run Program… The EK9 IDE once this is done: Choose Run > Run Program… The project's only program is already chosen. Choose Run. Four lines for the four states, one line for the empty Optional against the full one, then 'before' and 'after' with nothing between them - the two prints ... |
| Chapter 24: the four states of a Result, built | The result | ResultStates.ek9 now reads exactly as chapter 24 of EK9 in Depth shows it. The first four lines are the four states, and the 'before' and 'after' lines show the cost: printing an unset String prints nothing at all, not even a newline. The EK9 IDE when the lesson has finished |
| Chapter 24: the four states of a Result, built | Where this lesson comes from | For AI assistants - the MCP tool ek9_new_construct, ek9_add_program. |
| Chapter 24: what keeps the proof, built | Chapter 24: what keeps the proof, built | The compiler lets a read stand where a check in the same block has proved it - and chapter 24 lists what keeps that proof: the right-hand side of an and, a nested if, a call that cannot reach the checked object, a parenthesised group. These are the shapes that compile; the chapter's error ... |
| Chapter 24: what keeps the proof, built | Step 1: A constant | Choose Code > New Construct > Constant… The EK9 IDE once this is done: Choose Code > New Construct > Constant… LIMIT is the constant's name and 3 its value - a literal in the Value field, from which the type is inferred. Type both and choose Preview. The EK9 IDE just before choosing Preview: ... |
| Chapter 24: what keeps the proof, built | Step 2: attempts — a pure function | Choose Code > New Construct > Function… The EK9 IDE once this is done: Choose Code > New Construct > Function… attempts is the function's name. Set Returns to Optional of Integer and tick pure. Choose Preview. The EK9 IDE just before choosing Preview: attempts is the function's name The preview ... |
| Chapter 24: what keeps the proof, built | Step 3: answer — a pure function | Choose Code > New Construct > Function… The EK9 IDE once this is done: Choose Code > New Construct > Function… answer is the function's name. Set Returns to Result of (Integer, String) and tick pure. Choose Preview. The EK9 IDE just before choosing Preview: answer is the function's name The ... |
| Chapter 24: what keeps the proof, built | Step 4: flag — a pure function | Choose Code > New Construct > Function… The EK9 IDE once this is done: Choose Code > New Construct > Function… flag is the function's name. Set Returns to Boolean and tick pure. Choose Preview. The EK9 IDE just before choosing Preview: flag is the function's name The preview shows flag about to ... |
| Chapter 24: what keeps the proof, built | Step 5: note — a function | Choose Code > New Construct > Function… The EK9 IDE once this is done: Choose Code > New Construct > Function… note is the function's name. Add one parameter, text of type String. Choose Preview. The EK9 IDE just before choosing Preview: note is the function's name The preview shows note about to ... |
| Chapter 24: what keeps the proof, built | Step 6: describe — a pure function | Choose Code > New Construct > Function… The EK9 IDE once this is done: Choose Code > New Construct > Function… describe is the function's name. Add one parameter, candidate of type Integer, set Returns to String and tick pure. Choose Preview. The EK9 IDE just before choosing Preview: describe is ... |
| Chapter 24: what keeps the proof, built | Step 7: The program | Choose Code > New Construct > Program… The EK9 IDE once this is done: Choose Code > New Construct > Program… SafeShapes is the program's name. Choose Preview. The EK9 IDE just before choosing Preview: SafeShapes is the program's name The preview shows SafeShapes about to be written. Choose Apply. ... |
| Chapter 24: what keeps the proof, built | Step 8: Run it | Choose Run > Run Program… The EK9 IDE once this is done: Choose Run > Run Program… The project's only program is already chosen. Choose Run. Seven lines: and 5, nested 5, the note's own line, after the call 5, attempt 5, grouped or 5, and a set Result proves ok 7. Choose Close. The EK9 IDE just ... |
| Chapter 24: what keeps the proof, built | The result | SafeShapes.ek9 now reads exactly as chapter 24 of EK9 in Depth shows it. note() is not pure, yet the proof survives the call to it, because it is never handed the Optional it could empty; hand it the Optional and the next get() would need a new check. The EK9 IDE when the lesson has finished |
| Chapter 24: what keeps the proof, built | Where this lesson comes from | For AI assistants - the MCP tool ek9_new_construct, ek9_add_program. |
| Chapter 25: one split, + and +=, built | Chapter 25: one split, + and +=, built | EK9 keeps the spelling of operators and removes the freedom: the set is closed, every signature is fixed, and every operator either mutates its receiver or does not. Chapter 25's OperatorSplit shows the split on one record, Credit: + computes a new value and must be pure, += changes the receiver ... |
| Chapter 25: one split, + and +=, built | Step 1: Credit — a record | Choose Code > New Construct > Record… The EK9 IDE once this is done: Choose Code > New Construct > Record… Credit is the record's name. The Fields table holds pence, starting at Integer(). A Type left blank is taken from the value. Choose Preview. The EK9 IDE just before choosing Preview: Credit ... |
| Chapter 25: one split, + and +=, built | Step 2: The program | Choose Code > New Construct > Program… The EK9 IDE once this is done: Choose Code > New Construct > Program… OperatorSplit is the program's name. Choose Preview. The EK9 IDE just before choosing Preview: OperatorSplit is the program's name The preview shows OperatorSplit about to be written. ... |
| Chapter 25: one split, + and +=, built | Step 3: Run it | Choose Run > Run Program… The EK9 IDE once this is done: Choose Run > Run Program… The project's only program is already chosen. Choose Run. sum 400p, deposit still 150p - then, after +=, deposit 400p. Choose Close. The EK9 IDE just before choosing Close: sum 400p, deposit still 150p - then, ... |
| Chapter 25: one split, + and +=, built | The result | OperatorSplit.ek9 now reads exactly as chapter 25 of EK9 in Depth shows it. The pure + left deposit alone; the += without pure changed it. Mark either one the other way round and the compiler refuses it (E07500, E07510). The EK9 IDE when the lesson has finished |
| Chapter 25: one split, + and +=, built | Where this lesson comes from | For AI assistants - the MCP tool ek9_new_construct, ek9_add_constructor, ek9_add_operator, ek9_add_program. |
| Chapter 25: what pure promises, built | Chapter 25: what pure promises, built | Chapter 25's PurityRules shows the pragmatic side of 'pure'. The rule is one-way: a pure function may call only pure code, but code that is not pure may call pure code freely - and a pure function may still print, because output is not the state purity protects. The IDE writes the four signatures ... |
| Chapter 25: what pure promises, built | Step 1: label — a pure function | Choose Code > New Construct > Function… The EK9 IDE once this is done: Choose Code > New Construct > Function… label is the function's name. Add one parameter, amount of type Float, set Returns to String and tick pure. Choose Preview. The EK9 IDE just before choosing Preview: label is the ... |
| Chapter 25: what pure promises, built | Step 2: receipt — a pure function | Choose Code > New Construct > Function… The EK9 IDE once this is done: Choose Code > New Construct > Function… receipt is the function's name. Add one parameter, amount of type Float, set Returns to String and tick pure. Choose Preview. The EK9 IDE just before choosing Preview: receipt is the ... |
| Chapter 25: what pure promises, built | Step 3: announce — a pure function | Choose Code > New Construct > Function… The EK9 IDE once this is done: Choose Code > New Construct > Function… announce is the function's name. Add one parameter, text of type String and tick pure. Choose Preview. The EK9 IDE just before choosing Preview: announce is the function's name The ... |
| Chapter 25: what pure promises, built | Step 4: audit — a function | Choose Code > New Construct > Function… The EK9 IDE once this is done: Choose Code > New Construct > Function… audit is the function's name. Add one parameter, text of type String. Choose Preview. The EK9 IDE just before choosing Preview: audit is the function's name The preview shows audit about ... |
| Chapter 25: what pure promises, built | Step 5: The program | Choose Code > New Construct > Program… The EK9 IDE once this is done: Choose Code > New Construct > Program… PurityRules is the program's name. Choose Preview. The EK9 IDE just before choosing Preview: PurityRules is the program's name The preview shows PurityRules about to be written. Choose ... |
| Chapter 25: what pure promises, built | Step 6: Run it | Choose Run > Run Program… The EK9 IDE once this is done: Choose Run > Run Program… The project's only program is already chosen. Choose Run. Total GBP 12.5, the two announcements, then false: the two GUIDs differ. Choose Close. The EK9 IDE just before choosing Close: Total GBP 12.5, the two ... |
| Chapter 25: what pure promises, built | The result | PurityRules.ek9 now reads exactly as chapter 25 of EK9 in Depth shows it. announce is pure and prints; audit is not pure and calls it; and GUID() is a pure constructor that still gives two different values - pure here means no side effects on your state, not 'the same answer every time'. The EK9 ... |
| Chapter 25: what pure promises, built | Where this lesson comes from | For AI assistants - the MCP tool ek9_new_construct, ek9_add_program. |
| Chapter 25: copy, merge and replace, built | Chapter 25: copy, merge and replace, built | Three mutating operators move one object's state into another: :=: copies, :~: merges and :^: replaces. In Java that is a clone, a merge helper and a setter loop; here they are operators, and for a type of your own the merge and the replace are always yours to write. Chapter 25's CopyMergeReplace ... |
| Chapter 25: copy, merge and replace, built | Step 1: Profile — a record | Choose Code > New Construct > Record… The EK9 IDE once this is done: Choose Code > New Construct > Record… Profile is the record's name. The Fields table holds name, starting at String(); email, starting at String(); theme, starting at String(). A Type left blank is taken from the value. Choose ... |
| Chapter 25: copy, merge and replace, built | Step 2: shown — a pure function | Choose Code > New Construct > Function… The EK9 IDE once this is done: Choose Code > New Construct > Function… shown is the function's name. Add one parameter, text of type String, set Returns to String and tick pure. Choose Preview. The EK9 IDE just before choosing Preview: shown is the ... |
| Chapter 25: copy, merge and replace, built | Step 3: The program | Choose Code > New Construct > Program… The EK9 IDE once this is done: Choose Code > New Construct > Program… CopyMergeReplace is the program's name. Choose Preview. The EK9 IDE just before choosing Preview: CopyMergeReplace is the program's name The preview shows CopyMergeReplace about to be ... |
| Chapter 25: copy, merge and replace, built | Step 4: Run it | Choose Run > Run Program… The EK9 IDE once this is done: Choose Run > Run Program… The project's only program is already chosen. Choose Run. copied Steve steve@example.org dark; merged the same, the patch could not overwrite; filled Steve limb@example.org light, the gaps were filled; replaced ... |
| Chapter 25: copy, merge and replace, built | The result | CopyMergeReplace.ek9 now reads exactly as chapter 25 of EK9 in Depth shows it. Merging into a full profile changed nothing, merging into a partial one filled only its gaps, and replace let what the patch had set win - three different answers from three operators on the same fields. The EK9 IDE ... |
| Chapter 25: copy, merge and replace, built | Where this lesson comes from | For AI assistants - the MCP tool ek9_new_construct, ek9_add_operator, ek9_add_program. |
| Chapter 25: one object, two names, built | Chapter 25: one object, two names, built | Chapter 25 starts with a fact Java and C# readers expect to be the other way round: in EK9 a variable assigned from another is a second NAME for the same object, and an operator such as ++ or += changes that object in place. This program shows it with an Integer and a List, and shows ... |
| Chapter 25: one object, two names, built | Step 1: The program | Choose Code > New Construct > Program… The EK9 IDE once this is done: Choose Code > New Construct > Program… Aliasing is the program's name. Choose Preview. The EK9 IDE just before choosing Preview: Aliasing is the program's name The preview shows Aliasing about to be written. Choose Apply. The ... |
| Chapter 25: one object, two names, built | Step 2: Run it | Choose Run > Run Program… The EK9 IDE once this is done: Choose Run > Run Program… The project's only program is already chosen. Choose Run. count 11 sameObject 11, then count 12 independent 11, then the List with Ann and Bo through both of its names. Choose Close. The EK9 IDE just before ... |
| Chapter 25: one object, two names, built | The result | Aliasing.ek9 now reads exactly as chapter 25 of EK9 in Depth shows it. count++ moved sameObject too, because they were one object; Integer(count) made an independent copy that the next count++ left alone; and += grew both names of the List. The EK9 IDE when the lesson has finished |
| Chapter 25: one object, two names, built | Where this lesson comes from | For AI assistants - the MCP tool ek9_add_program. |
| Chapter 25: a copy that shares, built | Chapter 25: a copy that shares, built | If you come from Java you expect primitives to copy and objects to share. EK9 has one case: every value is an object, and a copy copies what each field holds - so a field that holds a List holds the SAME List afterwards. Chapter 25's ShallowCopy shows it on a Team and then on a plain List. The ... |
| Chapter 25: a copy that shares, built | Step 1: Team — a record | Choose Code > New Construct > Record… The EK9 IDE once this is done: Choose Code > New Construct > Record… Team is the record's name. The Fields table holds name, starting at String(); members, starting at List() of String. A Type left blank is taken from the value. Choose Preview. The EK9 IDE ... |
| Chapter 25: a copy that shares, built | Step 2: The program | Choose Code > New Construct > Program… The EK9 IDE once this is done: Choose Code > New Construct > Program… ShallowCopy is the program's name. Choose Preview. The EK9 IDE just before choosing Preview: ShallowCopy is the program's name The preview shows ShallowCopy about to be written. Choose ... |
| Chapter 25: a copy that shares, built | Step 3: Run it | Choose Run > Run Program… The EK9 IDE once this is done: Choose Run > Run Program… The project's only program is already chosen. Choose Run. original and copy both show Ann, Bo and Cy - they share the members List - while the plain List copy stayed at Di and Ed when the roster gained Flo. Choose ... |
| Chapter 25: a copy that shares, built | The result | ShallowCopy.ek9 now reads exactly as chapter 25 of EK9 in Depth shows it. No operator or constructor needed a typed line: the constructor and both defaults came whole from the tools. The copy of the Team grew with the original, because its members field refers to the same List; the copy of the ... |
| Chapter 25: a copy that shares, built | Where this lesson comes from | For AI assistants - the MCP tool ek9_new_construct, ek9_add_constructor, ek9_add_operator, ek9_add_program. |
| Chapter 25: the re-point head, built | Chapter 25: the re-point head, built | Volume 1's guards declare a variable (<-) or fill an unset one (:=?). Chapter 25's ThenGuard adds the re-point head: := gives an EXISTING variable a new value, and 'then' names the check that decides whether the block runs - a re-point checks nothing by itself. The get() inside the condition is ... |
| Chapter 25: the re-point head, built | Step 1: A constant | Choose Code > New Construct > Constant… The EK9 IDE once this is done: Choose Code > New Construct > Constant… WARM is the constant's name and 18 its value - a literal in the Value field, from which the type is inferred. Type both and choose Preview. The EK9 IDE just before choosing Preview: WARM ... |
| Chapter 25: the re-point head, built | Step 2: reading — a pure function | Choose Code > New Construct > Function… The EK9 IDE once this is done: Choose Code > New Construct > Function… reading is the function's name. Add the parameters readings of type Dict of (String, Integer) and station of type String, set Returns to Optional of Integer and tick pure. Choose ... |
| Chapter 25: the re-point head, built | Step 3: The program | Choose Code > New Construct > Program… The EK9 IDE once this is done: Choose Code > New Construct > Program… ThenGuard is the program's name. Choose Preview. The EK9 IDE just before choosing Preview: ThenGuard is the program's name The preview shows ThenGuard about to be written. Choose Apply. ... |
| Chapter 25: the re-point head, built | Step 4: Run it | Choose Run > Run Program… The EK9 IDE once this is done: Choose Run > Run Program… The project's only program is already chosen. Choose Run. roof is warm: 21, cellar is not warm, attic: no reading, and finally that latest is set: false. Choose Close. The EK9 IDE just before choosing Close: roof ... |
| Chapter 25: the re-point head, built | The result | ThenGuard.ek9 now reads exactly as chapter 25 of EK9 in Depth shows it. The three ifs are the three outcomes - warm, present but not warm, and absent - and the last line shows the variable the guards assigned is still there afterwards, now unset. The EK9 IDE when the lesson has finished |
| Chapter 25: the re-point head, built | Where this lesson comes from | For AI assistants - the MCP tool ek9_new_construct, ek9_add_program. |
| Chapter 26: nine pure shapes, built | Chapter 26: nine pure shapes, built | In Java you pick Predicate or declare a @FunctionalInterface; here you do neither. Chapter 26's PureShapes writes nine plain pure functions and then names, for each, the type the compiler synthesised from its shape - Supplier, Consumer, Predicate, UnaryOperator, Comparator and the rest. The IDE ... |
| Chapter 26: nine pure shapes, built | Step 1: defaultGreeting — a pure function | Choose Code > New Construct > Function… The EK9 IDE once this is done: Choose Code > New Construct > Function… defaultGreeting is the function's name. Set Returns to String and tick pure. Choose Preview. The EK9 IDE just before choosing Preview: defaultGreeting is the function's name The preview ... |
| Chapter 26: nine pure shapes, built | Step 2: show — a pure function | Choose Code > New Construct > Function… The EK9 IDE once this is done: Choose Code > New Construct > Function… show is the function's name. Add one parameter, text of type String and tick pure. Choose Preview. The EK9 IDE just before choosing Preview: show is the function's name The preview shows ... |
| Chapter 26: nine pure shapes, built | Step 3: showPair — a pure function | Choose Code > New Construct > Function… The EK9 IDE once this is done: Choose Code > New Construct > Function… showPair is the function's name. Add the parameters text of type String and n of type Integer and tick pure. Choose Preview. The EK9 IDE just before choosing Preview: showPair is the ... |
| Chapter 26: nine pure shapes, built | Step 4: isEven — a pure function | Choose Code > New Construct > Function… The EK9 IDE once this is done: Choose Code > New Construct > Function… isEven is the function's name. Add one parameter, n of type Integer, set Returns to Boolean and tick pure. Choose Preview. The EK9 IDE just before choosing Preview: isEven is the ... |
| Chapter 26: nine pure shapes, built | Step 5: doubled — a pure function | Choose Code > New Construct > Function… The EK9 IDE once this is done: Choose Code > New Construct > Function… doubled is the function's name. Add one parameter, n of type Integer, set Returns to Integer and tick pure. Choose Preview. The EK9 IDE just before choosing Preview: doubled is the ... |
| Chapter 26: nine pure shapes, built | Step 6: describe — a pure function | Choose Code > New Construct > Function… The EK9 IDE once this is done: Choose Code > New Construct > Function… describe is the function's name. Add one parameter, n of type Integer, set Returns to String and tick pure. Choose Preview. The EK9 IDE just before choosing Preview: describe is the ... |
| Chapter 26: nine pure shapes, built | Step 7: byLength — a pure function | Choose Code > New Construct > Function… The EK9 IDE once this is done: Choose Code > New Construct > Function… byLength is the function's name. Add the parameters first of type String and second of type String, set Returns to Integer and tick pure. Choose Preview. The EK9 IDE just before choosing ... |
| Chapter 26: nine pure shapes, built | Step 8: longerThan — a pure function | Choose Code > New Construct > Function… The EK9 IDE once this is done: Choose Code > New Construct > Function… longerThan is the function's name. Add the parameters text of type String and limit of type Integer, set Returns to Boolean and tick pure. Choose Preview. The EK9 IDE just before ... |
| Chapter 26: nine pure shapes, built | Step 9: tagged — a pure function | Choose Code > New Construct > Function… The EK9 IDE once this is done: Choose Code > New Construct > Function… tagged is the function's name. Add the parameters text of type String and n of type Integer, set Returns to String and tick pure. Choose Preview. The EK9 IDE just before choosing ... |
| Chapter 26: nine pure shapes, built | Step 10: The program | Choose Code > New Construct > Program… The EK9 IDE once this is done: Choose Code > New Construct > Program… PureShapes is the program's name. Choose Preview. The EK9 IDE just before choosing Preview: PureShapes is the program's name The preview shows PureShapes about to be written. Choose Apply. ... |
| Chapter 26: nine pure shapes, built | Step 11: Run it | Choose Run > Run Program… The EK9 IDE once this is done: Choose Run > Run Program… The project's only program is already chosen. Choose Run. hello, show: consumed, width=3, isEven(4) true, doubled(21) 42, number 3, byLength 1, longerThan true, item#9, and the words sorted by length: a, bb, ccc. ... |
| Chapter 26: nine pure shapes, built | The result | PureShapes.ek9 now reads exactly as chapter 26 of EK9 in Depth shows it. Nothing in the nine functions mentions Predicate or Comparator - the variable's type names what the compiler worked out, and the function goes in by name. byLength even sorts the List as it is, a Comparator the stream ... |
| Chapter 26: nine pure shapes, built | Where this lesson comes from | For AI assistants - the MCP tool ek9_new_construct, ek9_add_program. |
| Chapter 26: the impure twins, built | Chapter 26: the impure twins, built | Purity forks the hierarchy. Chapter 26's ImpureTwins writes the same shapes as PureShapes but leaves 'pure' off, and the compiler gives them a second family of types - Producer, Acceptor, Assessor, Routine and their Bi- forms - which Java has no equivalent of. The IDE writes the nine signatures ... |
| Chapter 26: the impure twins, built | Step 1: nextTicket — a function | Choose Code > New Construct > Function… The EK9 IDE once this is done: Choose Code > New Construct > Function… nextTicket is the function's name. Set Returns to Integer. Choose Preview. The EK9 IDE just before choosing Preview: nextTicket is the function's name The preview shows nextTicket about ... |
| Chapter 26: the impure twins, built | Step 2: audit — a function | Choose Code > New Construct > Function… The EK9 IDE once this is done: Choose Code > New Construct > Function… audit is the function's name. Add one parameter, text of type String. Choose Preview. The EK9 IDE just before choosing Preview: audit is the function's name The preview shows audit about ... |
| Chapter 26: the impure twins, built | Step 3: auditPair — a function | Choose Code > New Construct > Function… The EK9 IDE once this is done: Choose Code > New Construct > Function… auditPair is the function's name. Add the parameters text of type String and n of type Integer. Choose Preview. The EK9 IDE just before choosing Preview: auditPair is the function's name ... |
| Chapter 26: the impure twins, built | Step 4: looksEven — a function | Choose Code > New Construct > Function… The EK9 IDE once this is done: Choose Code > New Construct > Function… looksEven is the function's name. Add one parameter, n of type Integer, set Returns to Boolean. Choose Preview. The EK9 IDE just before choosing Preview: looksEven is the function's name ... |
| Chapter 26: the impure twins, built | Step 5: bump — a function | Choose Code > New Construct > Function… The EK9 IDE once this is done: Choose Code > New Construct > Function… bump is the function's name. Add one parameter, n of type Integer, set Returns to Integer. Choose Preview. The EK9 IDE just before choosing Preview: bump is the function's name The ... |
| Chapter 26: the impure twins, built | Step 6: labelled — a function | Choose Code > New Construct > Function… The EK9 IDE once this is done: Choose Code > New Construct > Function… labelled is the function's name. Add one parameter, n of type Integer, set Returns to String. Choose Preview. The EK9 IDE just before choosing Preview: labelled is the function's name ... |
| Chapter 26: the impure twins, built | Step 7: longerThan — a function | Choose Code > New Construct > Function… The EK9 IDE once this is done: Choose Code > New Construct > Function… longerThan is the function's name. Add the parameters text of type String and limit of type Integer, set Returns to Boolean. Choose Preview. The EK9 IDE just before choosing Preview: ... |
| Chapter 26: the impure twins, built | Step 8: tagged — a function | Choose Code > New Construct > Function… The EK9 IDE once this is done: Choose Code > New Construct > Function… tagged is the function's name. Add the parameters text of type String and n of type Integer, set Returns to String. Choose Preview. The EK9 IDE just before choosing Preview: tagged is ... |
| Chapter 26: the impure twins, built | Step 9: byLength — a function | Choose Code > New Construct > Function… The EK9 IDE once this is done: Choose Code > New Construct > Function… byLength is the function's name. Add the parameters first of type String and second of type String, set Returns to Integer. Choose Preview. The EK9 IDE just before choosing Preview: ... |
| Chapter 26: the impure twins, built | Step 10: The program | Choose Code > New Construct > Program… The EK9 IDE once this is done: Choose Code > New Construct > Program… ImpureTwins is the program's name. Choose Preview. The EK9 IDE just before choosing Preview: ImpureTwins is the program's name The preview shows ImpureTwins about to be written. Choose ... |
| Chapter 26: the impure twins, built | Step 11: Run it | Choose Run > Run Program… The EK9 IDE once this is done: Choose Run > Run Program… The project's only program is already chosen. Choose Run. 7, audit: accepted, audit height=4, looksEven(5) false, bump(1) 2, number 4, longerThan true, item#9, byLength 1, then the evens [2, 4] and the words sorted ... |
| Chapter 26: the impure twins, built | The result | ImpureTwins.ek9 now reads exactly as chapter 26 of EK9 in Depth shows it. Same bodies, no 'as pure', and a different type for every variable: an Assessor is not a Predicate. The two pipelines at the end show the stream verbs filter by and sort by accept the impure twins too. The EK9 IDE when the ... |
| Chapter 26: the impure twins, built | Where this lesson comes from | For AI assistants - the MCP tool ek9_new_construct, ek9_add_program. |
| Chapter 26: your own function type, built | Chapter 26: your own function type, built | Three parameters match no row of the library's table, so no Predicate or BiFunction fits - but an abstract function is a function type you write yourself. Chapter 26's OwnFunctionType declares limit() as pure abstract, a concrete clamp that is limit, and apply, which takes any function declared ... |
| Chapter 26: your own function type, built | Step 1: limit — a pure function | Choose Code > New Construct > Function… The EK9 IDE once this is done: Choose Code > New Construct > Function… limit is the function's name. Add the parameters n of type Integer, low of type Integer and high of type Integer, set Returns to Integer, tick pure and as abstract - a function type: a ... |
| Chapter 26: your own function type, built | Step 2: clamp — a pure function | Choose Code > New Construct > Function… The EK9 IDE once this is done: Choose Code > New Construct > Function… clamp is the function's name. Add the parameters n of type Integer, low of type Integer and high of type Integer, set Returns to Integer, type limit into Extends and tick pure. Choose ... |
| Chapter 26: your own function type, built | Step 3: apply — a pure function | Choose Code > New Construct > Function… The EK9 IDE once this is done: Choose Code > New Construct > Function… apply is the function's name. Add one parameter, rule of type limit, set Returns to Integer and tick pure. Choose Preview. The EK9 IDE just before choosing Preview: apply is the ... |
| Chapter 26: your own function type, built | Step 4: The program | Choose Code > New Construct > Program… The EK9 IDE once this is done: Choose Code > New Construct > Program… OwnFunctionType is the program's name. Choose Preview. The EK9 IDE just before choosing Preview: OwnFunctionType is the program's name The preview shows OwnFunctionType about to be ... |
| Chapter 26: your own function type, built | Step 5: Run it | Choose Run > Run Program… The EK9 IDE once this is done: Choose Run > Run Program… The project's only program is already chosen. Choose Run. 10 twice - clamp(15, 1, 10) called directly and through apply - then that the function held as an Any is set: true. Choose Close. The EK9 IDE just before ... |
| Chapter 26: your own function type, built | The result | OwnFunctionType.ek9 now reads exactly as chapter 26 of EK9 in Depth shows it. limit is a type with a name, apply takes any function that is limit, and the last lines show every function can still be held as an Any - set, though an Any cannot be called. The EK9 IDE when the lesson has finished |
| Chapter 26: your own function type, built | Where this lesson comes from | For AI assistants - the MCP tool ek9_new_construct, ek9_add_program. |
| Chapter 26: an abstract function as a contract, built | Chapter 26: an abstract function as a contract, built | The same device writes a family of interchangeable rules. Chapter 26's TaxRules declares taxRule as an abstract function - a net price in, a gross price back - three concrete rules that are taxRule, and ruleFor, a pure function that returns whichever rule a category needs. The IDE writes the ... |
| Chapter 26: an abstract function as a contract, built | Step 1: Constants | Choose Code > New Construct > Constant… The EK9 IDE once this is done: Choose Code > New Construct > Constant… STANDARD_RATE is the constant's name and 0.2 its value - a literal in the Value field, from which the type is inferred. Type both and choose Preview. The EK9 IDE just before choosing ... |
| Chapter 26: an abstract function as a contract, built | Step 2: taxRule — a pure function | Choose Code > New Construct > Function… The EK9 IDE once this is done: Choose Code > New Construct > Function… taxRule is the function's name. Add one parameter, net of type Float, tick pure and as abstract - a function type: a contract with no body. An abstract function has no stub: after the ... |
| Chapter 26: an abstract function as a contract, built | Step 3: standardRate — a pure function | Choose Code > New Construct > Function… The EK9 IDE once this is done: Choose Code > New Construct > Function… standardRate is the function's name. Add one parameter, net of type Float, set Returns to Float, type taxRule into Extends and tick pure. Choose Preview. The EK9 IDE just before choosing ... |
| Chapter 26: an abstract function as a contract, built | Step 4: reducedRate — a pure function | Choose Code > New Construct > Function… The EK9 IDE once this is done: Choose Code > New Construct > Function… reducedRate is the function's name. Add one parameter, net of type Float, set Returns to Float, type taxRule into Extends and tick pure. Choose Preview. The EK9 IDE just before choosing ... |
| Chapter 26: an abstract function as a contract, built | Step 5: zeroRate — a pure function | Choose Code > New Construct > Function… The EK9 IDE once this is done: Choose Code > New Construct > Function… zeroRate is the function's name. Add one parameter, net of type Float, set Returns to Float, type taxRule into Extends and tick pure. Choose Preview. The EK9 IDE just before choosing ... |
| Chapter 26: an abstract function as a contract, built | Step 6: ruleFor — a pure function | Choose Code > New Construct > Function… The EK9 IDE once this is done: Choose Code > New Construct > Function… ruleFor is the function's name. Add one parameter, category of type String, set Returns to String and tick pure. The tool cannot start a taxRule return - a function type has no value to ... |
| Chapter 26: an abstract function as a contract, built | Step 7: The program | Choose Code > New Construct > Program… The EK9 IDE once this is done: Choose Code > New Construct > Program… ShopTill is the program's name. Choose Preview. The EK9 IDE just before choosing Preview: ShopTill is the program's name The preview shows ShopTill about to be written. Choose Apply. The ... |
| Chapter 26: an abstract function as a contract, built | Step 8: Run it | Choose Run > Run Program… The EK9 IDE once this is done: Choose Run > Run Program… The project's only program is already chosen. Choose Run. food: 105.0, book: 100.0, lamp: 120.0 - the three rules at work - and through UnaryOperator: 105.0. Choose Close. The EK9 IDE just before choosing Close: food |
| Chapter 26: an abstract function as a contract, built | The result | TaxRules.ek9 now reads exactly as chapter 26 of EK9 in Depth shows it. The caller applies whichever rule it was handed - dynamic selection by a function value, with no class involved - and because taxRule is pure with a Float in and a Float out, reducedRate is also accepted as a UnaryOperator of ... |
| Chapter 26: an abstract function as a contract, built | Where this lesson comes from | For AI assistants - the MCP tool ek9_new_construct, ek9_add_program. |
| Chapter 28: one data set, every verb, built | Chapter 28: one data set, every verb, built | Chapter 28 uses one data set - eight orders, each a customer, a product and an amount - to use every stream verb once: sort, tee, group, map, flatten, tail, skip, reject, uniq, the two sinks, join, split and call. The IDE writes the constants, the Order record with its constructor and $, and the ... |
| Chapter 28: one data set, every verb, built | Step 1: Constants | Choose Code > New Construct > Constant… The EK9 IDE once this is done: Choose Code > New Construct > Constant… LARGE_ORDER is the constant's name and 100.0 its value - a literal in the Value field, from which the type is inferred. Type both and choose Preview. The EK9 IDE just before choosing ... |
| Chapter 28: one data set, every verb, built | Step 2: Order — a record | Choose Code > New Construct > Record… The EK9 IDE once this is done: Choose Code > New Construct > Record… Order is the record's name. The Fields table holds customer, starting at String(); product, starting at String(); amount, starting at Float(). A Type left blank is taken from the value. ... |
| Chapter 28: one data set, every verb, built | Step 3: byCustomerThenAmount — a pure function | Choose Code > New Construct > Function… The EK9 IDE once this is done: Choose Code > New Construct > Function… byCustomerThenAmount is the function's name. Add the parameters first of type Order and second of type Order, set Returns to Integer and tick pure. Choose Preview. The EK9 IDE just ... |
| Chapter 28: one data set, every verb, built | Step 4: byAmountDescending — a pure function | Choose Code > New Construct > Function… The EK9 IDE once this is done: Choose Code > New Construct > Function… byAmountDescending is the function's name. Add the parameters first of type Order and second of type Order, set Returns to Integer and tick pure. Choose Preview. The EK9 IDE just before ... |
| Chapter 28: one data set, every verb, built | Step 5: customerOf — a pure function | Choose Code > New Construct > Function… The EK9 IDE once this is done: Choose Code > New Construct > Function… customerOf is the function's name. Add one parameter, order of type Order, set Returns to String and tick pure. Choose Preview. The EK9 IDE just before choosing Preview: customerOf is ... |
| Chapter 28: one data set, every verb, built | Step 6: productOf — a pure function | Choose Code > New Construct > Function… The EK9 IDE once this is done: Choose Code > New Construct > Function… productOf is the function's name. Add one parameter, order of type Order, set Returns to String and tick pure. Choose Preview. The EK9 IDE just before choosing Preview: productOf is the ... |
| Chapter 28: one data set, every verb, built | Step 7: amountOf — a pure function | Choose Code > New Construct > Function… The EK9 IDE once this is done: Choose Code > New Construct > Function… amountOf is the function's name. Add one parameter, order of type Order, set Returns to Float and tick pure. Choose Preview. The EK9 IDE just before choosing Preview: amountOf is the ... |
| Chapter 28: one data set, every verb, built | Step 8: isLarge — a pure function | Choose Code > New Construct > Function… The EK9 IDE once this is done: Choose Code > New Construct > Function… isLarge is the function's name. Add one parameter, order of type Order, set Returns to Boolean and tick pure. Choose Preview. The EK9 IDE just before choosing Preview: isLarge is the ... |
| Chapter 28: one data set, every verb, built | Step 9: addAmounts — a pure function | Choose Code > New Construct > Function… The EK9 IDE once this is done: Choose Code > New Construct > Function… addAmounts is the function's name. Add the parameters first of type Float and second of type Float, set Returns to Float and tick pure. Choose Preview. The EK9 IDE just before choosing ... |
| Chapter 28: one data set, every verb, built | Step 10: topOfGroup — a pure function | Choose Code > New Construct > Function… The EK9 IDE once this is done: Choose Code > New Construct > Function… topOfGroup is the function's name. Add one parameter, group of type List of Order, set Returns to List of Order and tick pure. Choose Preview. The EK9 IDE just before choosing Preview: ... |
| Chapter 28: one data set, every verb, built | Step 11: isDayHeader — a pure function | Choose Code > New Construct > Function… The EK9 IDE once this is done: Choose Code > New Construct > Function… isDayHeader is the function's name. Add one parameter, line of type String, set Returns to Boolean and tick pure. Choose Preview. The EK9 IDE just before choosing Preview: isDayHeader is ... |
| Chapter 28: one data set, every verb, built | Step 12: daySummary — a pure function | Choose Code > New Construct > Function… The EK9 IDE once this is done: Choose Code > New Construct > Function… daySummary is the function's name. Add one parameter, lines of type List of String, set Returns to String and tick pure. Choose Preview. The EK9 IDE just before choosing Preview: ... |
| Chapter 28: one data set, every verb, built | Step 13: summaryLine — a pure function | Choose Code > New Construct > Function… The EK9 IDE once this is done: Choose Code > New Construct > Function… summaryLine is the function's name. Set Returns to String, tick pure and as abstract - a function type: a contract with no body. Choose Preview. The EK9 IDE just before choosing Preview: ... |
| Chapter 28: one data set, every verb, built | Step 14: The program | Choose Code > New Construct > Program… The EK9 IDE once this is done: Choose Code > New Construct > Program… OrderReport is the program's name. Choose Preview. The EK9 IDE just before choosing Preview: OrderReport is the program's name The preview shows OrderReport about to be written. Choose ... |
| Chapter 28: one data set, every verb, built | Step 15: Run it | Choose Run > Run Program… The EK9 IDE once this is done: Choose Run > Run Program… The project's only program is already chosen. Choose Run. Top orders per customer, then the three smallest and all but the first in customer order, the small-order products before and after the large ones were ... |
| Chapter 28: one data set, every verb, built | The result | OrderPipelines.ek9 now reads exactly as chapter 28 of EK9 in Depth shows it. Every function in it is small and pure, so the verbs can be moved around freely, and the abstract summaryLine is what let the two dynamic functions at the end be elements of a stream that call runs in order. The EK9 IDE ... |
| Chapter 28: one data set, every verb, built | Where this lesson comes from | For AI assistants - the MCP tool ek9_new_construct, ek9_add_constructor, ek9_add_operator, ek9_add_program. |
| Chapter 28: replace or append, built | Chapter 28: replace or append, built | In the stream sinks, > REPLACES what the target holds and >> ADDS to it - on a List, a Set, a Dict, and on a file, where > clobbers and >> appends. A replace is all or nothing: the pipeline fills a fresh collection and swaps it in only when the stream has finished. Chapter 28's ReplaceOrAppend ... |
| Chapter 28: replace or append, built | Step 1: A constant | Choose Code > New Construct > Constant… The EK9 IDE once this is done: Choose Code > New Construct > Constant… BAD_NUMBER is the constant's name and 3 its value - a literal in the Value field, from which the type is inferred. Type both and choose Preview. The EK9 IDE just before choosing Preview: ... |
| Chapter 28: replace or append, built | Step 2: checked — a function | Choose Code > New Construct > Function… The EK9 IDE once this is done: Choose Code > New Construct > Function… checked is the function's name. Add one parameter, number of type Integer, set Returns to String. Choose Preview. The EK9 IDE just before choosing Preview: checked is the function's name ... |
| Chapter 28: replace or append, built | Step 3: The program | Choose Code > New Construct > Program… The EK9 IDE once this is done: Choose Code > New Construct > Program… ReplaceOrAppend is the program's name. Choose Preview. The EK9 IDE just before choosing Preview: ReplaceOrAppend is the program's name The preview shows ReplaceOrAppend about to be ... |
| Chapter 28: replace or append, built | Step 4: Run it | Choose Run > Run Program… The EK9 IDE once this is done: Choose Run > Run Program… The project's only program is already chosen. Choose Run. after >: q and r; after >>: q, r and s; the failed pipeline leaves kept still holding old; and the sorted scores 10, 20, 30. Choose Close. The EK9 IDE just ... |
| Chapter 28: replace or append, built | The result | SinkReplaceAppend.ek9 now reads exactly as chapter 28 of EK9 in Depth shows it. checked() throws on the third item, so the > into kept never swapped its fresh collection in and kept still holds old; and sorting a List back into itself is allowed because the pipeline reads it before the swap. The ... |
| Chapter 28: replace or append, built | Where this lesson comes from | For AI assistants - the MCP tool ek9_new_construct, ek9_add_program. |
| Chapter 28: JSON as a sink, built | Chapter 28: JSON as a sink, built | JSON follows the same two rules as the collections: > replaces an array target's items, >> adds to them, and collect as JSON makes a fresh array. Chapter 28's OrdersAsJson turns Order records into JSON with $$, the serialising operator, which the record asks for with default operator $$. The IDE ... |
| Chapter 28: JSON as a sink, built | Step 1: A constant | Choose Code > New Construct > Constant… The EK9 IDE once this is done: Choose Code > New Construct > Constant… LARGE_ORDER is the constant's name and 100.0 its value - a literal in the Value field, from which the type is inferred. Type both and choose Preview. The EK9 IDE just before choosing ... |
| Chapter 28: JSON as a sink, built | Step 2: Order — a record | Choose Code > New Construct > Record… The EK9 IDE once this is done: Choose Code > New Construct > Record… Order is the record's name. The Fields table holds customer, starting at String(); product, starting at String(); amount, starting at Float(). A Type left blank is taken from the value. ... |
| Chapter 28: JSON as a sink, built | Step 3: isLarge — a pure function | Choose Code > New Construct > Function… The EK9 IDE once this is done: Choose Code > New Construct > Function… isLarge is the function's name. Add one parameter, order of type Order, set Returns to Boolean and tick pure. Choose Preview. The EK9 IDE just before choosing Preview: isLarge is the ... |
| Chapter 28: JSON as a sink, built | Step 4: asJson — a pure function | Choose Code > New Construct > Function… The EK9 IDE once this is done: Choose Code > New Construct > Function… asJson is the function's name. Add one parameter, order of type Order, set Returns to JSON and tick pure. Choose Preview. The EK9 IDE just before choosing Preview: asJson is the ... |
| Chapter 28: JSON as a sink, built | Step 5: The program | Choose Code > New Construct > Program… The EK9 IDE once this is done: Choose Code > New Construct > Program… OrdersAsJson is the program's name. Choose Preview. The EK9 IDE just before choosing Preview: OrdersAsJson is the program's name The preview shows OrdersAsJson about to be written. Choose ... |
| Chapter 28: JSON as a sink, built | Step 6: Run it | Choose Run > Run Program… The EK9 IDE once this is done: Choose Run > Run Program… The project's only program is already chosen. Choose Run. The array after >> holds bob's and cy's large orders; after > it holds only ada's; then all three orders pretty-printed as JSON. Choose Close. The EK9 IDE ... |
| Chapter 28: JSON as a sink, built | The result | JsonSink.ek9 now reads exactly as chapter 28 of EK9 in Depth shows it. The target's shape decided what pouring meant: the empty array gathered the large orders with >>, then > replaced them with the small ones, and collect as JSON made a third, fresh array. The EK9 IDE when the lesson has finished |
| Chapter 28: JSON as a sink, built | Where this lesson comes from | For AI assistants - the MCP tool ek9_new_construct, ek9_add_constructor, ek9_add_operator, ek9_add_program. |
| Chapter 28: async is a stage, built | Chapter 28: async is a stage, built | Put async in a pipeline whose elements are functions and each one is called concurrently. Chapter 28's AsyncLookups declares one abstract function, priceLookup, four lookups that are priceLookup, and a program that sends them through async three ways. The IDE writes the function type and the four ... |
| Chapter 28: async is a stage, built | Step 1: priceLookup — a function | Choose Code > New Construct > Function… The EK9 IDE once this is done: Choose Code > New Construct > Function… priceLookup is the function's name. Set Returns to String and tick as abstract - a function type: a contract with no body. Choose Preview. The EK9 IDE just before choosing Preview: ... |
| Chapter 28: async is a stage, built | Step 2: lookupKeyboard — a function | Choose Code > New Construct > Function… The EK9 IDE once this is done: Choose Code > New Construct > Function… lookupKeyboard is the function's name. Set Returns to String, type priceLookup into Extends. Choose Preview. The EK9 IDE just before choosing Preview: lookupKeyboard is the function's ... |
| Chapter 28: async is a stage, built | Step 3: lookupMonitor — a function | Choose Code > New Construct > Function… The EK9 IDE once this is done: Choose Code > New Construct > Function… lookupMonitor is the function's name. Set Returns to String, type priceLookup into Extends. Choose Preview. The EK9 IDE just before choosing Preview: lookupMonitor is the function's name ... |
| Chapter 28: async is a stage, built | Step 4: lookupMouse — a function | Choose Code > New Construct > Function… The EK9 IDE once this is done: Choose Code > New Construct > Function… lookupMouse is the function's name. Set Returns to String, type priceLookup into Extends. Choose Preview. The EK9 IDE just before choosing Preview: lookupMouse is the function's name The ... |
| Chapter 28: async is a stage, built | Step 5: lookupLaptop — a function | Choose Code > New Construct > Function… The EK9 IDE once this is done: Choose Code > New Construct > Function… lookupLaptop is the function's name. Set Returns to String, type priceLookup into Extends. Choose Preview. The EK9 IDE just before choosing Preview: lookupLaptop is the function's name ... |
| Chapter 28: async is a stage, built | Step 6: The program | Choose Code > New Construct > Program… The EK9 IDE once this is done: Choose Code > New Construct > Program… AsyncLookups is the program's name. Choose Preview. The EK9 IDE just before choosing Preview: AsyncLookups is the program's name The preview shows AsyncLookups about to be written. Choose ... |
| Chapter 28: async is a stage, built | Step 7: Run it | Choose Run > Run Program… The EK9 IDE once this is done: Choose Run > Run Program… The project's only program is already chosen. Choose Run. The four lookups in the order they finished - which can differ from run to run - then the same four sorted, then the first two started, sorted: keyboard ... |
| Chapter 28: async is a stage, built | The result | AsyncLookups.ek9 now reads exactly as chapter 28 of EK9 in Depth shows it. async is a stage in the pipeline, not a thread you manage: the first block's order is whichever call finished first, sort puts an order back, and head 2 after async starts only two calls. The EK9 IDE when the lesson has ... |
| Chapter 28: async is a stage, built | Where this lesson comes from | For AI assistants - the MCP tool ek9_new_construct, ek9_add_program. |
| Chapter 29: the parent's version on purpose, built | Chapter 29: the parent's version on purpose, built | A dispatcher chooses a handler by the run-time type of its argument; an ordinary override chooses by the receiver. Chapter 29 ends on the reverse of both: a subclass that deliberately reaches the PARENT's version with super. Account is open, SavingsAccount extends it, and each override calls the ... |
| Chapter 29: the parent's version on purpose, built | Step 1: Account — a class | Choose Code > New Construct > Class… The EK9 IDE once this is done: Choose Code > New Construct > Class… Account is the class's name. Choose Open under Extensibility - a class is closed to extension unless it says so. Choose Preview. The EK9 IDE just before choosing Preview: Account is the ... |
| Chapter 29: the parent's version on purpose, built | Step 2: SavingsAccount — a class | Choose Code > New Construct > Class… The EK9 IDE once this is done: Choose Code > New Construct > Class… SavingsAccount is the class's name. Type Account into Extends. Choose Preview. The EK9 IDE just before choosing Preview: SavingsAccount is the class's name The preview shows SavingsAccount ... |
| Chapter 29: the parent's version on purpose, built | Step 3: The program | Choose Code > New Construct > Program… The EK9 IDE once this is done: Choose Code > New Construct > Program… SuperCalls is the program's name. Choose Preview. The EK9 IDE just before choosing Preview: SuperCalls is the program's name The preview shows SuperCalls about to be written. Choose Apply. ... |
| Chapter 29: the parent's version on purpose, built | Step 4: Run it | Choose Run > Run Program… The EK9 IDE once this is done: Choose Run > Run Program… The project's only program is already chosen. Choose Run. Ada holds 120.00#GBP; Bob holds 800.00#GBP at 3.5% - twice, because asAccount is the same object seen through its parent type, and the override still runs; ... |
| Chapter 29: the parent's version on purpose, built | The result | SuperCall.ek9 now reads exactly as chapter 29 of EK9 in Depth shows it. SavingsAccount's constructor hands holder and balance up with super(...) and keeps only the rate for itself; its describe adds to the parent's text, and its monthlyCharge scales the parent's charge by zero. The EK9 IDE when ... |
| Chapter 29: the parent's version on purpose, built | Where this lesson comes from | For AI assistants - the MCP tool ek9_new_construct, ek9_add_field, ek9_add_constructor, ek9_add_method, ek9_add_program. |
| Chapter 30: a generic cache over two types, built | Chapter 30: a generic cache over two types, built | A cache is the smallest realistic generic type with TWO type parameters: LruCache of type (K, V) is written once over a key type and a value type, and keeps a Dict of entries and a List that records recency. It must compare, store and evict without knowing either. The IDE writes the constant, the ... |
| Chapter 30: a generic cache over two types, built | Step 1: A constant | Choose Code > New Construct > Constant… The EK9 IDE once this is done: Choose Code > New Construct > Constant… DEFAULT_CAPACITY is the constant's name and 3 its value - a literal in the Value field, from which the type is inferred. Type both and choose Preview. The EK9 IDE just before choosing ... |
| Chapter 30: a generic cache over two types, built | Step 2: LruCache — a generic class of two type parameters | Choose Code > New Construct > Class… The EK9 IDE once this is done: Choose Code > New Construct > Class… LruCache is the class's name. Tick Generic and give the type parameters K, V. The Fields table holds capacity of type Integer, starting at DEFAULT_CAPACITY; entries of type Dict of (K, V), ... |
| Chapter 30: a generic cache over two types, built | Step 3: The program | Choose Code > New Construct > Program… The EK9 IDE once this is done: Choose Code > New Construct > Program… CacheDemo is the program's name. Choose Preview. The EK9 IDE just before choosing Preview: CacheDemo is the program's name The preview shows CacheDemo about to be written. Choose Apply. ... |
| Chapter 30: a generic cache over two types, built | Step 4: Run it | Choose Run > Run Program… The EK9 IDE once this is done: Choose Run > Run Program… The project's only program is already chosen. Choose Run. apple: 0.5, keys, oldest first: ["apple", "plum"], pear still cached: false, then the squares cache keeping only [4, 5, 6] and answering 5 squared: 25. ... |
| Chapter 30: a generic cache over two types, built | The result | LruCache.ek9 now reads exactly as chapter 30 of EK9 in Depth shows it. touch is private - the one method outside the cache's contract - and one definition served a cache of String and Money and a cache of Integer and Integer, each a type of its own. The EK9 IDE when the lesson has finished |
| Chapter 30: a generic cache over two types, built | Where this lesson comes from | Answers - ek9 -q and the IDE's Answers tab: 194, 196.For AI assistants - the MCP tool ek9_new_construct, ek9_add_method, ek9_add_program. |
| Chapter 30: a generic constrained by a trait, built | Chapter 30: a generic constrained by a trait, built | An unconstrained T is an Any: you can hold it and pass it, and little else. Ledger of type T constrain by Priced says every T must be a Priced, so the body may call price() on a T and compare two of them with >. The chapter's trait declares the ordering, and the compiler holds it to a standard - ... |
| Chapter 30: a generic constrained by a trait, built | Step 1: Priced — a trait whose ordering is total | Choose Code > New Construct > Trait… The EK9 IDE once this is done: Choose Code > New Construct > Trait… Priced is the trait's name. Choose Preview. The EK9 IDE just before choosing Preview: Priced is the trait's name The preview shows Priced about to be written. Choose Apply. The EK9 IDE just ... |
| Chapter 30: a generic constrained by a trait, built | Step 2: Ticket — a class that is Priced | Choose Code > New Construct > Class… The EK9 IDE once this is done: Choose Code > New Construct > Class… Ticket is the class's name. Choose Preview. The EK9 IDE just before choosing Preview: Ticket is the class's name The preview shows Ticket about to be written. Choose Apply. The EK9 IDE just ... |
| Chapter 30: a generic constrained by a trait, built | Step 3: Meal — another class that is Priced | Choose Code > New Construct > Class… The EK9 IDE once this is done: Choose Code > New Construct > Class… Meal is the class's name. Choose Preview. The EK9 IDE just before choosing Preview: Meal is the class's name The preview shows Meal about to be written. Choose Apply. The EK9 IDE just before ... |
| Chapter 30: a generic constrained by a trait, built | Step 4: Ledger — generic, but only over a Priced | Choose Code > New Construct > Class… The EK9 IDE once this is done: Choose Code > New Construct > Class… Ledger is the class's name. Tick Generic and give the type parameter T (constrain by Priced). The Fields table holds items of type List of T, starting at List(). Choose Preview. The EK9 IDE ... |
| Chapter 30: a generic constrained by a trait, built | Step 5: The program | Choose Code > New Construct > Program… The EK9 IDE once this is done: Choose Code > New Construct > Program… PricedLedgers is the program's name. Choose Preview. The EK9 IDE just before choosing Preview: PricedLedgers is the program's name The preview shows PricedLedgers about to be written. ... |
| Chapter 30: a generic constrained by a trait, built | Step 6: Run it | Choose Run > Run Program… The EK9 IDE once this is done: Choose Run > Run Program… The project's only program is already chosen. Choose Run. tickets total: 57.00#GBP, meals total: 58.00#GBP, then dearest meal: 31.00#GBP. Choose Close. The EK9 IDE just before choosing Close: tickets total |
| Chapter 30: a generic constrained by a trait, built | The result | PricedLedger.ek9 now reads exactly as chapter 30 of EK9 in Depth shows it. Ticket and Meal are unrelated classes that share one trait, and Ledger works for either - total() calls price() and dearest() compares with >, both of which the constraint put in reach of every T. Ledger of Ticket and ... |
| Chapter 30: a generic constrained by a trait, built | Where this lesson comes from | Answers - ek9 -q and the IDE's Answers tab: 195.For AI assistants - the MCP tool ek9_new_construct, ek9_adopt_trait, ek9_add_field, ek9_add_constructor, ek9_add_method, ek9_add_program. |
| Chapter 30: the copy a generic asks every T for, built | Chapter 30: the copy a generic asks every T for, built | Chapter 30 starts with a Shelf that holds Books and is written once over any T, as Shelf of type T. Each filling, Shelf of Book, is a real type the compiler checks - its T is never erased to Object, as Java's is - and the template may only do to a T what every T can do. The IDE writes the Book ... |
| Chapter 30: the copy a generic asks every T for, built | Step 1: Book — an ordinary class | Choose Code > New Construct > Class… The EK9 IDE once this is done: Choose Code > New Construct > Class… Book is the class's name. Choose Preview. The EK9 IDE just before choosing Preview: Book is the class's name The preview shows Book about to be written. Choose Apply. The EK9 IDE just before ... |
| Chapter 30: the copy a generic asks every T for, built | Step 2: Shelf — a generic class | Choose Code > New Construct > Class… The EK9 IDE once this is done: Choose Code > New Construct > Class… Shelf is the class's name. Tick Generic and give the type parameter T. The Fields table holds items of type List of T, starting at List(). Choose Preview. The EK9 IDE just before choosing ... |
| Chapter 30: the copy a generic asks every T for, built | Step 3: The program | Choose Code > New Construct > Program… The EK9 IDE once this is done: Choose Code > New Construct > Program… Library is the program's name. Choose Preview. The EK9 IDE just before choosing Preview: Library is the program's name The preview shows Library about to be written. Choose Apply. The EK9 ... |
| Chapter 30: the copy a generic asks every T for, built | Step 4: Run it | Choose Run > Run Program… The EK9 IDE once this is done: Choose Run > Run Program… The project's only program is already chosen. Choose Run. on the shelf: 2, then first title: Emma. Choose Close. The EK9 IDE just before choosing Close: on the shelf |
| Chapter 30: the copy a generic asks every T for, built | The result | Shelf.ek9 now reads exactly as chapter 30 of EK9 in Depth shows it. A generic class must say how it is built both empty and from one T, and the copy it makes of the item - T(item) - is why Book has a copy constructor: the template asks every T for one. The EK9 IDE when the lesson has finished |
| Chapter 30: the copy a generic asks every T for, built | Where this lesson comes from | Answers - ek9 -q and the IDE's Answers tab: 194.For AI assistants - the MCP tool ek9_new_construct, ek9_add_field, ek9_add_constructor, ek9_add_method, ek9_add_program. |
| Chapter 30: a generic function and a function type, built | Chapter 30: a generic function and a function type, built | Chapter 30's generic functions: larger() of type T compares two values of whatever T is, and transformer() of type T as abstract is a function TYPE - a signature with no body that a dynamic function fills in. If you know Java, this is not a method with a type parameter: a generic function is a ... |
| Chapter 30: a generic function and a function type, built | Step 1: larger — a function | Choose Code > New Construct > Function… The EK9 IDE once this is done: Choose Code > New Construct > Function… larger is the function's name. Tick Generic and give one type parameter, T (no constraint). Add the parameters a of type T and b of type T, set Returns to T. Choose Preview. The EK9 IDE ... |
| Chapter 30: a generic function and a function type, built | Step 2: transformer — a function | Choose Code > New Construct > Function… The EK9 IDE once this is done: Choose Code > New Construct > Function… transformer is the function's name. Tick Generic and give one type parameter, T (no constraint). Add one parameter, item of type T, set Returns to T and tick as abstract - a function ... |
| Chapter 30: a generic function and a function type, built | Step 3: The program | Choose Code > New Construct > Program… The EK9 IDE once this is done: Choose Code > New Construct > Program… GenericFunctionDemo is the program's name. Choose Preview. The EK9 IDE just before choosing Preview: GenericFunctionDemo is the program's name The preview shows GenericFunctionDemo about ... |
| Chapter 30: a generic function and a function type, built | Step 4: Run it | Choose Run > Run Program… The EK9 IDE once this is done: Choose Run > Run Program… The project's only program is already chosen. Choose Run. larger of 21 and 42: 42, larger of pear and apple: pear, then HELLO! and doubled: 66. Choose Close. The EK9 IDE just before choosing Close: larger of 21 and 42 |
| Chapter 30: a generic function and a function type, built | The result | GenericFunctions.ek9 now reads exactly as chapter 30 of EK9 in Depth shows it. larger() of Integer and larger() of String are two functions made from one template, each checked when it is made; the two dynamic functions implement the abstract transformer for String and for Integer. The EK9 IDE ... |
| Chapter 30: a generic function and a function type, built | Where this lesson comes from | Answers - ek9 -q and the IDE's Answers tab: 58.For AI assistants - the MCP tool ek9_new_construct, ek9_add_program. |
| Chapter 30: a range over a type parameter, built | Chapter 30: a range over a type parameter, built | A range over a type parameter: countFromTo() of type T counts the steps from one T to another with a for ... in from ... to loop. A range needs <=>, a copy constructor and ++ on the type, so the template is checked for each T it is made for - Integer, Character and Date work; String, which has no ... |
| Chapter 30: a range over a type parameter, built | Step 1: countFromTo — a function | Choose Code > New Construct > Function… The EK9 IDE once this is done: Choose Code > New Construct > Function… countFromTo is the function's name. Tick Generic and give one type parameter, T (no constraint). Add the parameters from of type T and to of type T, set Returns to Integer. Choose ... |
| Chapter 30: a range over a type parameter, built | Step 2: The program | Choose Code > New Construct > Program… The EK9 IDE once this is done: Choose Code > New Construct > Program… RangeOverT is the program's name. Choose Preview. The EK9 IDE just before choosing Preview: RangeOverT is the program's name The preview shows RangeOverT about to be written. Choose Apply. ... |
| Chapter 30: a range over a type parameter, built | Step 3: Run it | Choose Run > Run Program… The EK9 IDE once this is done: Choose Run > Run Program… The project's only program is already chosen. Choose Run. 1 to 5: 5, a to e: 5 and March 2026: 31. Choose Close. The EK9 IDE just before choosing Close: 1 to 5 |
| Chapter 30: a range over a type parameter, built | The result | RangeOverT.ek9 now reads exactly as chapter 30 of EK9 in Depth shows it. One template counted integers, characters and days - a range that needs only the operators the loop uses, checked where T is filled in, not at the definition. The EK9 IDE when the lesson has finished |
| Chapter 30: a range over a type parameter, built | Where this lesson comes from | Answers - ek9 -q and the IDE's Answers tab: 58.For AI assistants - the MCP tool ek9_new_construct, ek9_add_program. |
| Chapter 30: a constrained type over a record, built | Chapter 30: a constrained type over a record, built | Volume 1's constrained types narrowed an Integer or a String. A constrained type may have a record as its base - here a Point, constrained by the record's own >, so a Point is in the quadrant when both coordinates exceed 0 - and an alias, Coord, is another name for the unconstrained Point. The ... |
| Chapter 30: a constrained type over a record, built | Step 1: Point — the record the constraint is over | Choose Code > New Construct > Record… The EK9 IDE once this is done: Choose Code > New Construct > Record… Point is the record's name. The Fields table holds x of type Integer, starting at Integer(); y of type Integer, starting at Integer(). Choose Preview. The EK9 IDE just before choosing ... |
| Chapter 30: a constrained type over a record, built | Step 2: The program | Choose Code > New Construct > Program… The EK9 IDE once this is done: Choose Code > New Construct > Program… ConstrainedRecord is the program's name. Choose Preview. The EK9 IDE just before choosing Preview: ConstrainedRecord is the program's name The preview shows ConstrainedRecord about to be ... |
| Chapter 30: a constrained type over a record, built | Step 3: Run it | Choose Run > Run Program… The EK9 IDE once this is done: Choose Run > Run Program… The project's only program is already chosen. Choose Run. Four lines: the accepted Point set true, the copy of it set true, the outside Point rejected (set false), and the alias holding it unconstrained. Choose ... |
| Chapter 30: a constrained type over a record, built | The result | ConstrainedRecord.ek9 now reads exactly as chapter 30 of EK9 in Depth shows it. Something built through PositiveQuadrant either satisfies > 0 or is unset - a Point outside the quadrant is rejected - while Coord, an alias, accepts any Point. The EK9 IDE when the lesson has finished |
| Chapter 30: a constrained type over a record, built | Where this lesson comes from | Answers - ek9 -q and the IDE's Answers tab: 1074.For AI assistants - the MCP tool ek9_new_construct, ek9_add_constructor, ek9_add_operator, ek9_add_program. |
| Chapter 31: a project of several files and two modules, built | Chapter 31: a project of several files and two modules, built | The first question a Java, Go or Rust programmer asks is where the build file lives. In EK9 it is a block inside one of your source files, and the compiler is the only build tool. This small inventory is laid out by what each file is about: pricing rules in a module of their own, the Item record ... |
| Chapter 31: a project of several files and two modules, built | Step 1: pricing.ek9 — the pricing rules, a module of their own | Choose Code > New Construct > Constant… The EK9 IDE once this is done: Choose Code > New Construct > Constant… VAT_RATE is the constant's name and 0.2 its value - a literal in the Value field, from which the type is inferred. Type both and choose Preview. The EK9 IDE just before choosing Preview: ... |
| Chapter 31: a project of several files and two modules, built | Step 2: priceWithTax | Choose Code > New Construct > Function… The EK9 IDE once this is done: Choose Code > New Construct > Function… priceWithTax is the function's name. Add one parameter, net of type Money, set Returns to Money and tick pure. Choose Preview. The EK9 IDE just before choosing Preview: priceWithTax is ... |
| Chapter 31: a project of several files and two modules, built | Step 3: items.ek9 — the record, in the SAME module as main.ek9 | Choose Code > New Construct > Record… The EK9 IDE once this is done: Choose Code > New Construct > Record… Item is the record's name. The Fields table holds name of type String, starting at String(); price of type Money, starting at Money(). Choose Preview. The EK9 IDE just before choosing ... |
| Chapter 31: a project of several files and two modules, built | Step 4: stockLine | Choose Code > New Construct > Function… The EK9 IDE once this is done: Choose Code > New Construct > Function… stockLine is the function's name. Add one parameter, item of type Item, set Returns to String and tick pure. Choose Preview. The EK9 IDE just before choosing Preview: stockLine is the ... |
| Chapter 31: a project of several files and two modules, built | Step 5: stockLines | Choose Code > New Construct > Function… The EK9 IDE once this is done: Choose Code > New Construct > Function… stockLines is the function's name. Add one parameter, items of type List of Item, set Returns to List of String and tick pure. Choose Preview. The EK9 IDE just before choosing Preview: ... |
| Chapter 31: a project of several files and two modules, built | Step 6: The program | Choose Code > New Construct > Program… The EK9 IDE once this is done: Choose Code > New Construct > Program… Inventory is the program's name. Choose Preview. The EK9 IDE just before choosing Preview: Inventory is the program's name The preview shows Inventory about to be written. Choose Apply. ... |
| Chapter 31: a project of several files and two modules, built | Step 7: Run it | Run ▸ Run Tests (⌘T) runs every test in the project. Choose Run Tests. The EK9 IDE once this is done: Run ▸ Run Tests (⌘T) runs every test in the project All four tests in dev/ pass - the same as ek9 -t main.ek9 at the command line. The EK9 IDE once this is done: All four tests in dev/ pass - the ... |
| Chapter 31: a project of several files and two modules, built | The result | The four files now read exactly as chapter 31 of EK9 in Depth shows them. stockLine uses Item with no references entry, because main.ek9 and items.ek9 are one module; it needs one for priceWithTax, because that is another. Only the package block - applyStandardIncludes - puts the other files in ... |
| Chapter 31: a project of several files and two modules, built | Where this lesson comes from | Answers - ek9 -q and the IDE's Answers tab: 1380, 13.For AI assistants - the MCP tool ek9_new_construct, ek9_add_constructor, ek9_add_program, ek9_run_tests. |
| Chapter 31: the four comment forms, built | Chapter 31: the four comment forms, built | EK9 has four comment forms and no others. // runs to the end of the line and is the only one Volume 1 used; <!-- --> and <!- -!> are block forms; <?- -?> is the documentation form, for a concept or a reason - the things a compiler cannot check and a comment may state. C's /* */ is not one of ... |
| Chapter 31: the four comment forms, built | Step 1: describe — a documented function | Choose Code > New Construct > Function… The EK9 IDE once this is done: Choose Code > New Construct > Function… describe is the function's name. Add one parameter, count of type Integer, set Returns to String and tick pure. Choose Preview. The EK9 IDE just before choosing Preview: describe is the ... |
| Chapter 31: the four comment forms, built | Step 2: The program | Choose Code > New Construct > Program… The EK9 IDE once this is done: Choose Code > New Construct > Program… Comments is the program's name. Choose Preview. The EK9 IDE just before choosing Preview: Comments is the program's name The preview shows Comments about to be written. Choose Apply. The ... |
| Chapter 31: the four comment forms, built | Step 3: Run it | Choose Run > Run Program… The EK9 IDE once this is done: Choose Run > Run Program… The project's only program is already chosen. Choose Run. 3 item(s). Choose Close. The EK9 IDE just before choosing Close: 3 item(s) |
| Chapter 31: the four comment forms, built | The result | Comments.ek9 now reads exactly as chapter 31 of EK9 in Depth shows it - all four forms in one file. The documentation comments sit before the module and the function they describe; the rest the compiler never sees. The EK9 IDE when the lesson has finished |
| Chapter 31: the four comment forms, built | Where this lesson comes from | Answers - ek9 -q and the IDE's Answers tab: 914.For AI assistants - the MCP tool ek9_new_construct, ek9_add_program. |
| Chapter 32: an exception hierarchy and its dispatcher, built | Chapter 32: an exception hierarchy and its dispatcher, built | Java has checked and unchecked exceptions and a catch ladder, one catch per type. EK9 has no throws, no checked exceptions and exactly one catch: the catch hands whatever was thrown to a dispatcher, which chooses by the run-time type. This till can fail three ways, and the chapter's exceptions ... |
| Chapter 32: an exception hierarchy and its dispatcher, built | Step 1: Constants | Choose Code > New Construct > Constant… The EK9 IDE once this is done: Choose Code > New Construct > Constant… goldCard is the constant's name and "4111" its value - a literal in the Value field, from which the type is inferred. Type both and choose Preview. The EK9 IDE just before choosing ... |
| Chapter 32: an exception hierarchy and its dispatcher, built | Step 2: Constants | Choose Code > New Construct > Constant… The EK9 IDE once this is done: Choose Code > New Construct > Constant… silverCard is the constant's name and "5500" its value - a literal in the Value field, from which the type is inferred. Type both and choose Preview. The EK9 IDE just before choosing ... |
| Chapter 32: an exception hierarchy and its dispatcher, built | Step 3: Constants | Choose Code > New Construct > Constant… The EK9 IDE once this is done: Choose Code > New Construct > Constant… unknownCard is the constant's name and "9999" its value - a literal in the Value field, from which the type is inferred. Type both and choose Preview. The EK9 IDE just before choosing ... |
| Chapter 32: an exception hierarchy and its dispatcher, built | Step 4: PaymentException — an exception of our own | Choose Code > New Construct > Class… The EK9 IDE once this is done: Choose Code > New Construct > Class… PaymentException is the class's name. Choose Open under Extensibility - a class is closed to extension unless it says so. Type Exception into Extends. Choose Preview. The EK9 IDE just before ... |
| Chapter 32: an exception hierarchy and its dispatcher, built | Step 5: CardDeclined — a payment exception | Choose Code > New Construct > Class… The EK9 IDE once this is done: Choose Code > New Construct > Class… CardDeclined is the class's name. Type PaymentException into Extends. Choose Preview. The EK9 IDE just before choosing Preview: CardDeclined is the class's name The preview shows CardDeclined ... |
| Chapter 32: an exception hierarchy and its dispatcher, built | Step 6: InsufficientFunds — another payment exception | Choose Code > New Construct > Class… The EK9 IDE once this is done: Choose Code > New Construct > Class… InsufficientFunds is the class's name. Type PaymentException into Extends. Choose Preview. The EK9 IDE just before choosing Preview: InsufficientFunds is the class's name The preview shows ... |
| Chapter 32: an exception hierarchy and its dispatcher, built | Step 7: Till — it charges, and handles what goes wrong | Choose Code > New Construct > Class… The EK9 IDE once this is done: Choose Code > New Construct > Class… Till is the class's name. Choose Preview. The EK9 IDE just before choosing Preview: Till is the class's name The preview shows Till about to be written. Choose Apply. The EK9 IDE just before ... |
| Chapter 32: an exception hierarchy and its dispatcher, built | Step 8: The program | Choose Code > New Construct > Program… The EK9 IDE once this is done: Choose Code > New Construct > Program… PaymentExceptions is the program's name. Choose Preview. The EK9 IDE just before choosing Preview: PaymentExceptions is the program's name The preview shows PaymentExceptions about to be ... |
| Chapter 32: an exception hierarchy and its dispatcher, built | Step 9: Run it | Choose Run > Run Program… The EK9 IDE once this is done: Choose Run > Run Program… The project's only program is already chosen. Choose Run. charged 120 to card 4111, card 9999 declined with code 51, payment failed on card 5500: Insufficient funds, unexpected: amount must be positive, not 0, and ... |
| Chapter 32: an exception hierarchy and its dispatcher, built | The result | PaymentExceptions.ek9 now reads exactly as chapter 32 of EK9 in Depth shows it. pay has one try and one catch, and handleFailure - declared as dispatcher - routes by the run-time type: CardDeclined to its own overload, InsufficientFunds to the nearest overload above it, a plain Exception to the ... |
| Chapter 32: an exception hierarchy and its dispatcher, built | Where this lesson comes from | Answers - ek9 -q and the IDE's Answers tab: 136, 138.For AI assistants - the MCP tool ek9_new_construct, ek9_add_operator, ek9_add_field, ek9_add_constructor, ek9_add_method, ek9_add_program. |
| Chapter 32: a catch that names its type, built | Chapter 32: a catch that names its type, built | A catch names the type it handles, and only that type - and what it does not name goes on to the next enclosing try. Here charge throws a plain Exception for a negative amount and a CardDeclined for zero; the inner catch takes only the second, so the first escalates to the outer one. The IDE ... |
| Chapter 32: a catch that names its type, built | Step 1: CardDeclined — an exception of our own | Choose Code > New Construct > Class… The EK9 IDE once this is done: Choose Code > New Construct > Class… CardDeclined is the class's name. Choose Open under Extensibility - a class is closed to extension unless it says so. Type Exception into Extends. Choose Preview. The EK9 IDE just before ... |
| Chapter 32: a catch that names its type, built | Step 2: charge — it throws two ways | Choose Code > New Construct > Function… The EK9 IDE once this is done: Choose Code > New Construct > Function… charge is the function's name. Add one parameter, amount of type Integer, set Returns to Integer. Choose Preview. The EK9 IDE just before choosing Preview: charge is the function's name ... |
| Chapter 32: a catch that names its type, built | Step 3: The program | Choose Code > New Construct > Program… The EK9 IDE once this is done: Choose Code > New Construct > Program… NarrowCatch is the program's name. Choose Preview. The EK9 IDE just before choosing Preview: NarrowCatch is the program's name The preview shows NarrowCatch about to be written. Choose ... |
| Chapter 32: a catch that names its type, built | Step 4: Run it | Choose Run > Run Program… The EK9 IDE once this is done: Choose Run > Run Program… The project's only program is already chosen. Choose Run. declined here: nothing to charge, then escalated: amount must not be negative - the 5 never ran. Choose Close. The EK9 IDE just before choosing Close: ... |
| Chapter 32: a catch that names its type, built | The result | NarrowCatch.ek9 now reads exactly as chapter 32 of EK9 in Depth shows it. The CardDeclined for 0 was caught where it happened, the loop went on, and the plain Exception for -1 went past the inner catch to the outer one and ended the loop. The EK9 IDE when the lesson has finished |
| Chapter 32: a catch that names its type, built | Where this lesson comes from | Answers - ek9 -q and the IDE's Answers tab: 138, 1156.For AI assistants - the MCP tool ek9_new_construct, ek9_add_operator, ek9_add_program. |
| Chapter 32: try as an expression, built | Chapter 32: try as an expression, built | In Java a try is a statement: to get a value out of it you declare a variable first and assign it in both arms. In EK9 try is an expression - it has a return of its own, and the catch supplies the value when the body throws. The chapter's TryExpression reads a port number that may not be one. The ... |
| Chapter 32: try as an expression, built | Step 1: A constant | Choose Code > New Construct > Constant… The EK9 IDE once this is done: Choose Code > New Construct > Constant… fallbackPort is the constant's name and 8080 its value - a literal in the Value field, from which the type is inferred. Type both and choose Preview. The EK9 IDE just before choosing ... |
| Chapter 32: try as an expression, built | Step 2: portFrom — a function | Choose Code > New Construct > Function… The EK9 IDE once this is done: Choose Code > New Construct > Function… portFrom is the function's name. Add one parameter, text of type String, set Returns to Integer. Choose Preview. The EK9 IDE just before choosing Preview: portFrom is the function's name ... |
| Chapter 32: try as an expression, built | Step 3: The program | Choose Code > New Construct > Program… The EK9 IDE once this is done: Choose Code > New Construct > Program… TryExpression is the program's name. Add one parameter, configured of type String. Choose Preview. The EK9 IDE just before choosing Preview: TryExpression is the program's name The preview ... |
| Chapter 32: try as an expression, built | Step 4: Run it | Choose Run > Run Program… The EK9 IDE once this is done: Choose Run > Run Program… Type abc into Arguments (space-separated), then choose Run. The EK9 IDE just before choosing Run: Type abc into Arguments (space-separated), then choose Run Given abc, it prints using the fallback: not a port ... |
| Chapter 32: try as an expression, built | The result | TryExpression.ek9 now reads exactly as chapter 32 of EK9 in Depth shows it: port is the value of the try, either portFrom's answer or the fallback the catch assigned to rtn after reporting why. The EK9 IDE when the lesson has finished |
| Chapter 32: try as an expression, built | Where this lesson comes from | Answers - ek9 -q and the IDE's Answers tab: 1358.For AI assistants - the MCP tool ek9_new_construct, ek9_add_program. |
| Chapter 32: when a resource closes, built | Chapter 32: when a resource closes, built | In Java the resources of a try-with-resources are closed BEFORE catch and finally run. In EK9 the body runs, then the try's own catch, then its finally, and only then are the resources closed, last opened first - so a catch runs while the resources are still open. If you write from Java intuition ... |
| Chapter 32: when a resource closes, built | Step 1: Constants | Choose Code > New Construct > Constant… The EK9 IDE once this is done: Choose Code > New Construct > Constant… firstLabel is the constant's name and "first" its value - a literal in the Value field, from which the type is inferred. Type both and choose Preview. The EK9 IDE just before choosing ... |
| Chapter 32: when a resource closes, built | Step 2: Constants | Choose Code > New Construct > Constant… The EK9 IDE once this is done: Choose Code > New Construct > Constant… secondLabel is the constant's name and "second" its value - a literal in the Value field, from which the type is inferred. Type both and choose Preview. The EK9 IDE just before choosing ... |
| Chapter 32: when a resource closes, built | Step 3: Constants | Choose Code > New Construct > Constant… The EK9 IDE once this is done: Choose Code > New Construct > Constant… brokenLabel is the constant's name and "broken" its value - a literal in the Value field, from which the type is inferred. Type both and choose Preview. The EK9 IDE just before choosing ... |
| Chapter 32: when a resource closes, built | Step 4: Connection — a closeable that can fail to open | Choose Code > New Construct > Class… The EK9 IDE once this is done: Choose Code > New Construct > Class… Connection is the class's name. Choose Preview. The EK9 IDE just before choosing Preview: Connection is the class's name The preview shows Connection about to be written. Choose Apply. The EK9 ... |
| Chapter 32: when a resource closes, built | Step 5: The program | Choose Code > New Construct > Program… The EK9 IDE once this is done: Choose Code > New Construct > Program… ResourceOrder is the program's name. Choose Preview. The EK9 IDE just before choosing Preview: ResourceOrder is the program's name The preview shows ResourceOrder about to be written. ... |
| Chapter 32: when a resource closes, built | Step 6: Run it | Choose Run > Run Program… The EK9 IDE once this is done: Choose Run > Run Program… The project's only program is already chosen. Choose Run. Three blocks: opened first, opened second, body done, finally, closed second, closed first; the same with catch: body failed; and finally opened first, ... |
| Chapter 32: when a resource closes, built | The result | ResourceOrder.ek9 now reads exactly as chapter 32 of EK9 in Depth shows it. In the first two runs 'finally' comes before 'closed second' and 'closed first'. In the third, a failure while ACQUIRING a resource is not handled by the try that declares it: the inner catch printed nothing, first was ... |
| Chapter 32: when a resource closes, built | Where this lesson comes from | Answers - ek9 -q and the IDE's Answers tab: 137.For AI assistants - the MCP tool ek9_new_construct, ek9_add_field, ek9_add_constructor, ek9_add_operator, ek9_add_program. |
| Chapter 32: a holder that closes what it holds, built | Chapter 32: a holder that closes what it holds, built | Java closes a try-with-resources before the catch and finally run; C# has using, Python has with. EK9 will not let you write the close at all: a closeable is a type with an operator close, and a try that is handed one owns it. A class that keeps closeables in its properties says default operator ... |
| Chapter 32: a holder that closes what it holds, built | Step 1: Connection — a closeable | Choose Code > New Construct > Class… The EK9 IDE once this is done: Choose Code > New Construct > Class… Connection is the class's name. Choose Preview. The EK9 IDE just before choosing Preview: Connection is the class's name The preview shows Connection about to be written. Choose Apply. The EK9 ... |
| Chapter 32: a holder that closes what it holds, built | Step 2: Session — it owns two connections | Choose Code > New Construct > Class… The EK9 IDE once this is done: Choose Code > New Construct > Class… Session is the class's name. Choose Preview. The EK9 IDE just before choosing Preview: Session is the class's name The preview shows Session about to be written. Choose Apply. The EK9 IDE just ... |
| Chapter 32: a holder that closes what it holds, built | Step 3: The program | Choose Code > New Construct > Program… The EK9 IDE once this is done: Choose Code > New Construct > Program… SessionClose is the program's name. Choose Preview. The EK9 IDE just before choosing Preview: SessionClose is the program's name The preview shows SessionClose about to be written. Choose ... |
| Chapter 32: a holder that closes what it holds, built | Step 4: Run it | Choose Run > Run Program… The EK9 IDE once this is done: Choose Run > Run Program… The project's only program is already chosen. Choose Run. opened primary, opened replica, sending hello, caught link dropped, finally, closed replica, closed primary. Choose Close. The EK9 IDE just before choosing ... |
| Chapter 32: a holder that closes what it holds, built | The result | SessionClose.ek9 now reads exactly as chapter 32 of EK9 in Depth shows it. The session is the try's resource: it was closed after the catch and the finally, and it closed replica before primary - the close the compiler wrote for default operator close, last property first. The EK9 IDE when the ... |
| Chapter 32: a holder that closes what it holds, built | Where this lesson comes from | Answers - ek9 -q and the IDE's Answers tab: 137.For AI assistants - the MCP tool ek9_new_construct, ek9_add_field, ek9_add_constructor, ek9_add_operator, ek9_add_method, ek9_add_program. |
| Chapter 32: a close that fails, built | Chapter 32: a close that fails, built | A close can throw. That failure leaves the try after the try's own catch has run, so a catch on the same try does not see it: it goes to the enclosing try. And if the body had already failed, the close failure does not replace the first exception - it is attached to it, and read through ... |
| Chapter 32: a close that fails, built | Step 1: Journal — a closeable whose close fails | Choose Code > New Construct > Class… The EK9 IDE once this is done: Choose Code > New Construct > Class… Journal is the class's name. Choose Preview. The EK9 IDE just before choosing Preview: Journal is the class's name The preview shows Journal about to be written. Choose Apply. The EK9 IDE just ... |
| Chapter 32: a close that fails, built | Step 2: report — what a handler sees | Choose Code > New Construct > Function… The EK9 IDE once this is done: Choose Code > New Construct > Function… report is the function's name. Add one parameter, ex of type Exception. Choose Preview. The EK9 IDE just before choosing Preview: report is the function's name The preview shows report ... |
| Chapter 32: a close that fails, built | Step 3: The program | Choose Code > New Construct > Program… The EK9 IDE once this is done: Choose Code > New Construct > Program… SuppressedClose is the program's name. Choose Preview. The EK9 IDE just before choosing Preview: SuppressedClose is the program's name The preview shows SuppressedClose about to be ... |
| Chapter 32: a close that fails, built | Step 4: Run it | Choose Run > Run Program… The EK9 IDE once this is done: Choose Run > Run Program… The project's only program is already chosen. Choose Run. The first case ends caught: close of audit failed; the second, caught: posting failed with the close failure listed under suppressed. Choose Close. The EK9 ... |
| Chapter 32: a close that fails, built | The result | SuppressedClose.ek9 now reads exactly as chapter 32 of EK9 in Depth shows it. In the second case the handler sees the body's own exception, posting failed, and the close failure is in its suppressed() list. The EK9 IDE when the lesson has finished |
| Chapter 32: a close that fails, built | Where this lesson comes from | Answers - ek9 -q and the IDE's Answers tab: 137.For AI assistants - the MCP tool ek9_new_construct, ek9_add_field, ek9_add_constructor, ek9_add_method, ek9_add_operator, ek9_add_program. |
| Chapter 32: the Panic a catch cannot see, built | Chapter 32: the Panic a catch cannot see, built | A third kind of failure, beside the Exception you catch and the Result you read: the Panic. A failed require raises one, and it is not an Exception, so no catch can name it - Java's catch (Throwable) has no counterpart. This program averages a list, then hands averageOf an empty one. The IDE ... |
| Chapter 32: the Panic a catch cannot see, built | Step 1: averageOf — a function | Choose Code > New Construct > Function… The EK9 IDE once this is done: Choose Code > New Construct > Function… averageOf is the function's name. Add one parameter, scores of type List of Integer, set Returns to Integer. Choose Preview. The EK9 IDE just before choosing Preview: averageOf is the ... |
| Chapter 32: the Panic a catch cannot see, built | Step 2: The program | Choose Code > New Construct > Program… The EK9 IDE once this is done: Choose Code > New Construct > Program… RequireExit is the program's name. Choose Preview. The EK9 IDE just before choosing Preview: RequireExit is the program's name The preview shows RequireExit about to be written. Choose ... |
| Chapter 32: the Panic a catch cannot see, built | Step 3: Run it | Choose Run > Run Program… The EK9 IDE once this is done: Choose Run > Run Program… The project's only program is already chosen. Choose Run. Average: 6, Averaging an empty list, finally still ran - and then a Panic: Requirement failed, not scores.empty(). The catch's own line never printed. ... |
| Chapter 32: the Panic a catch cannot see, built | The result | RequireExit.ek9 now reads exactly as chapter 32 of EK9 in Depth shows it, and the run ended where the chapter says: the finally ran, the catch did not, and the process stopped with a Panic naming the require, its file, line and column. The EK9 IDE when the lesson has finished |
| Chapter 32: the Panic a catch cannot see, built | Where this lesson comes from | Answers - ek9 -q and the IDE's Answers tab: 136.For AI assistants - the MCP tool ek9_new_construct, ek9_add_program. |
| Chapter 32: an exception that ends the program, built | Chapter 32: an exception that ends the program, built | An Exception nothing catches ends the program, and its exit code is the program's exit status - Exception takes an optional second argument for it, here 3. The IDE writes loadSettings' signature and the program's shell; you type the throw, and the try with only a finally. The run is MEANT to end ... |
| Chapter 32: an exception that ends the program, built | Step 1: loadSettings — a function | Choose Code > New Construct > Function… The EK9 IDE once this is done: Choose Code > New Construct > Function… loadSettings is the function's name. Add one parameter, fileName of type String, set Returns to String. Choose Preview. The EK9 IDE just before choosing Preview: loadSettings is the ... |
| Chapter 32: an exception that ends the program, built | Step 2: The program | Choose Code > New Construct > Program… The EK9 IDE once this is done: Choose Code > New Construct > Program… FatalExit is the program's name. Choose Preview. The EK9 IDE just before choosing Preview: FatalExit is the program's name The preview shows FatalExit about to be written. Choose Apply. ... |
| Chapter 32: an exception that ends the program, built | Step 3: Run it | Choose Run > Run Program… The EK9 IDE once this is done: Choose Run > Run Program… The project's only program is already chosen. Choose Run. Loaded app.properties, Loading settings with no file name, Cleanup ran before the process ended - and then the uncaught Exception: No settings file named, ... |
| Chapter 32: an exception that ends the program, built | The result | FatalExit.ek9 now reads exactly as chapter 32 of EK9 in Depth shows it. The finally ran, then the process ended with the exception's own exit code, 3 - an exception with no code would have ended it with 1. The EK9 IDE when the lesson has finished |
| Chapter 32: an exception that ends the program, built | Where this lesson comes from | Answers - ek9 -q and the IDE's Answers tab: 136, 1431.For AI assistants - the MCP tool ek9_new_construct, ek9_add_program. |
| Chapter 32: a program that returns its exit status, built | Chapter 32: a program that returns its exit status, built | A script reads a program's result from its exit status, and in EK9 that status is the program's return: a program that returns an Integer exits with it. This one takes the number of rows found as its argument, prints it, and exits with 2 when there were none. The IDE writes the program's shell, ... |
| Chapter 32: a program that returns its exit status, built | Step 1: The program | Choose Code > New Construct > Program… The EK9 IDE once this is done: Choose Code > New Construct > Program… ReturnedExit is the program's name. Add one parameter, rows of type Integer. Choose Preview. The EK9 IDE just before choosing Preview: ReturnedExit is the program's name The preview shows ... |
| Chapter 32: a program that returns its exit status, built | Step 2: Run it | Choose Run > Run Program… The EK9 IDE once this is done: Choose Run > Run Program… Type 7 into Arguments (space-separated), then choose Run. The EK9 IDE just before choosing Run: Type 7 into Arguments (space-separated), then choose Run rows found: 7 - and the process ends with exit status 0. ... |
| Chapter 32: a program that returns its exit status, built | The result | ReturnedExit.ek9 now reads exactly as chapter 32 of EK9 in Depth shows it. Given 0 rows it prints rows found: 0 and exits with status 2; given 7, as the run did, it prints rows found: 7 and exits with 0. The EK9 IDE when the lesson has finished |
| Chapter 32: a program that returns its exit status, built | Where this lesson comes from | Answers - ek9 -q and the IDE's Answers tab: 1431.For AI assistants - the MCP tool ek9_add_program. |
| Chapter 32: exceptions inside a pipeline, built | Chapter 32: exceptions inside a pipeline, built | A pipeline stage is an ordinary function, so an exception thrown in one travels as any other does. Two things can happen to it: a try around the whole pipeline statement catches it and nothing is collected, or a stage catches inside itself and substitutes a value, and the pipeline carries on. The ... |
| Chapter 32: exceptions inside a pipeline, built | Step 1: parsePrice — a function | Choose Code > New Construct > Function… The EK9 IDE once this is done: Choose Code > New Construct > Function… parsePrice is the function's name. Add one parameter, text of type String, set Returns to Integer. Choose Preview. The EK9 IDE just before choosing Preview: parsePrice is the function's ... |
| Chapter 32: exceptions inside a pipeline, built | Step 2: parsePriceOrZero — a function | Choose Code > New Construct > Function… The EK9 IDE once this is done: Choose Code > New Construct > Function… parsePriceOrZero is the function's name. Add one parameter, text of type String, set Returns to Integer. Choose Preview. The EK9 IDE just before choosing Preview: parsePriceOrZero is the ... |
| Chapter 32: exceptions inside a pipeline, built | Step 3: The program | Choose Code > New Construct > Program… The EK9 IDE once this is done: Choose Code > New Construct > Program… PipelineFailures is the program's name. Choose Preview. The EK9 IDE just before choosing Preview: PipelineFailures is the program's name The preview shows PipelineFailures about to be ... |
| Chapter 32: exceptions inside a pipeline, built | Step 4: Run it | Choose Run > Run Program… The EK9 IDE once this is done: Choose Run > Run Program… The project's only program is already chosen. Choose Run. pipeline stopped: not a price: oops, then skipped: not a price: oops, then recovered: [12, 0, 30, 45]. Choose Close. The EK9 IDE just before choosing Close: ... |
| Chapter 32: exceptions inside a pipeline, built | The result | PipelineFailures.ek9 now reads exactly as chapter 32 of EK9 in Depth shows it. The first pipeline stopped at oops, which is why unreachable never printed; the second recovered, with 0 standing in for the price that would not parse. The EK9 IDE when the lesson has finished |
| Chapter 32: exceptions inside a pipeline, built | Where this lesson comes from | Answers - ek9 -q and the IDE's Answers tab: 136.For AI assistants - the MCP tool ek9_new_construct, ek9_add_program. |
| Chapter 33: one lock over one record, built | Chapter 33: one lock over one record, built | In Java the shared tally is a synchronized method or an AtomicLong. Here the tally is a record, the record sits under one lock inside a class, and the only way in is a key - a function that runs while the lock is held. Eight workers each make 250 deposits. The IDE writes the constants, the record ... |
| Chapter 33: one lock over one record, built | Step 1: Constants | Choose Code > New Construct > Constant… The EK9 IDE once this is done: Choose Code > New Construct > Constant… workerCount is the constant's name and 8 its value - a literal in the Value field, from which the type is inferred. Type both and choose Preview. The EK9 IDE just before choosing ... |
| Chapter 33: one lock over one record, built | Step 2: Constants | Choose Code > New Construct > Constant… The EK9 IDE once this is done: Choose Code > New Construct > Constant… depositsPerWorker is the constant's name and 250 its value - a literal in the Value field, from which the type is inferred. Type both and choose Preview. The EK9 IDE just before choosing ... |
| Chapter 33: one lock over one record, built | Step 3: Tally — the record the lock protects | Choose Code > New Construct > Record… The EK9 IDE once this is done: Choose Code > New Construct > Record… Tally is the record's name. The Fields table holds deposits of type Integer, starting at 0; total of type Integer, starting at 0. Choose Preview. The EK9 IDE just before choosing Preview: ... |
| Chapter 33: one lock over one record, built | Step 4: Ledger — one lock over one record | Choose Code > New Construct > Class… The EK9 IDE once this is done: Choose Code > New Construct > Class… Ledger is the class's name. Choose Preview. The EK9 IDE just before choosing Preview: Ledger is the class's name The preview shows Ledger about to be written. Choose Apply. The EK9 IDE just ... |
| Chapter 33: one lock over one record, built | Step 5: work — what a worker is | Choose Code > New Construct > Function… The EK9 IDE once this is done: Choose Code > New Construct > Function… work is the function's name. Set Returns to Integer and tick as abstract - a function type: a contract with no body. Choose Preview. The EK9 IDE just before choosing Preview: work is the ... |
| Chapter 33: one lock over one record, built | Step 6: The program | Choose Code > New Construct > Program… The EK9 IDE once this is done: Choose Code > New Construct > Program… SharedTally is the program's name. Choose Preview. The EK9 IDE just before choosing Preview: SharedTally is the program's name The preview shows SharedTally about to be written. Choose ... |
| Chapter 33: one lock over one record, built | Step 7: Run it | Choose Run > Run Program… The EK9 IDE once this is done: Choose Run > Run Program… The project's only program is already chosen. Choose Run. workers finished: [1, 2, 3, 4, 5, 6, 7, 8], then tally: Tally(deposits=2000, total=9000). Choose Close. The EK9 IDE just before choosing Close: workers ... |
| Chapter 33: one lock over one record, built | The result | SharedTally.ek9 now reads exactly as chapter 33 of EK9 in Depth shows it. lockedTally is a field with an initialiser - the only place a MutexLock may be built - and the only way to the Tally inside is a key. A race would have shown as a smaller total. The EK9 IDE when the lesson has finished |
| Chapter 33: one lock over one record, built | Where this lesson comes from | Answers - ek9 -q and the IDE's Answers tab: 213.For AI assistants - the MCP tool ek9_new_construct, ek9_add_operator, ek9_add_field, ek9_add_method, ek9_add_program. |
| Chapter 33: workers that share nothing, built | Chapter 33: workers that share nothing, built | The safest concurrent program shares nothing. Eight workers each sum into a variable that only they can see, and the pipeline collects the results - there is no lock to forget, because there is nothing to lock. work is a function type with no body; each worker is a dynamic function that fills it ... |
| Chapter 33: workers that share nothing, built | Step 1: Constants | Choose Code > New Construct > Constant… The EK9 IDE once this is done: Choose Code > New Construct > Constant… workerCount is the constant's name and 8 its value - a literal in the Value field, from which the type is inferred. Type both and choose Preview. The EK9 IDE just before choosing ... |
| Chapter 33: workers that share nothing, built | Step 2: work — a function | Choose Code > New Construct > Function… The EK9 IDE once this is done: Choose Code > New Construct > Function… work is the function's name. Set Returns to Integer and tick as abstract - a function type: a contract with no body. Choose Preview. The EK9 IDE just before choosing Preview: work is the ... |
| Chapter 33: workers that share nothing, built | Step 3: The program | Choose Code > New Construct > Program… The EK9 IDE once this is done: Choose Code > New Construct > Program… WorkerTotals is the program's name. Choose Preview. The EK9 IDE just before choosing Preview: WorkerTotals is the program's name The preview shows WorkerTotals about to be written. Choose ... |
| Chapter 33: workers that share nothing, built | Step 4: Run it | Choose Run > Run Program… The EK9 IDE once this is done: Choose Run > Run Program… The project's only program is already chosen. Choose Run. subtotals: [250, 500, 750, 1000, 1250, 1500, 1750, 2000], then total: 9000 - the same every time. Choose Close. The EK9 IDE just before choosing Close: ... |
| Chapter 33: workers that share nothing, built | The result | WorkerTotals.ek9 now reads exactly as chapter 33 of EK9 in Depth shows it. Each worker's subtotal is its own; cat ... | async ran the eight together, sort put the answers in order whatever order they finished in, and cat subtotals > total added them. The EK9 IDE when the lesson has finished |
| Chapter 33: workers that share nothing, built | Where this lesson comes from | Answers - ek9 -q and the IDE's Answers tab: 213.For AI assistants - the MCP tool ek9_new_construct, ek9_add_program. |
| Chapter 33: the answer a key would lose, built | Chapter 33: the answer a key would lose, built | Inside a key you carry a result out by changing a captured variable, and the verb that changes it is :=:, not :. A capture shares the caller's object, so reassigning it with : would point only the key's own name at another object, and the caller would never see the answer. This lesson types it ... |
| Chapter 33: the answer a key would lose, built | Step 1: A constant | Choose Code > New Construct > Constant… The EK9 IDE once this is done: Choose Code > New Construct > Constant… withdrawal is the constant's name and 80 its value - a literal in the Value field, from which the type is inferred. Type both and choose Preview. The EK9 IDE just before choosing ... |
| Chapter 33: the answer a key would lose, built | Step 2: Account — a balance under a lock | Choose Code > New Construct > Class… The EK9 IDE once this is done: Choose Code > New Construct > Class… Account is the class's name. Choose Preview. The EK9 IDE just before choosing Preview: Account is the class's name The preview shows Account about to be written. Choose Apply. The EK9 IDE just ... |
| Chapter 33: the answer a key would lose, built | Step 3: The program | Choose Code > New Construct > Program… The EK9 IDE once this is done: Choose Code > New Construct > Program… LostResult is the program's name. Choose Preview. The EK9 IDE just before choosing Preview: LostResult is the program's name The preview shows LostResult about to be written. Choose Apply. ... |
| Chapter 33: the answer a key would lose, built | Step 4: Run it | Choose Run > Run Program… The EK9 IDE once this is done: Choose Run > Run Program… The project's only program is already chosen. Choose Run. funds for 80: true - the answer reached the caller. Choose Close. The EK9 IDE just before choosing Close: funds for 80 |
| Chapter 33: the answer a key would lose, built | The result | LostResult.ek9 now reads exactly as chapter 33 of EK9 in Depth shows it: the compiler refused the re-point with E08280, and rtn :=: lockedItem >= amount changed the one object both names share, so the run shows that a balance of 100 covers the request for 80. The EK9 IDE when the lesson has finished |
| Chapter 33: the answer a key would lose, built | Where this lesson comes from | Answers - ek9 -q and the IDE's Answers tab: 213.For AI assistants - the MCP tool ek9_new_construct, ek9_add_field, ek9_add_method, ek9_add_program. |
| Chapter 33: two locks, one order, built | Chapter 33: two locks, one order, built | Two locks are not a problem. Two locks taken in OPPOSITE orders on two paths are, and the compiler builds one graph of 'holding this, acquiring that' edges for the whole program and finds the cycles. A single direction is not an error. This CacheService nests the log inside the cache in both ... |
| Chapter 33: two locks, one order, built | Step 1: CacheService — two locks, one order | Choose Code > New Construct > Class… The EK9 IDE once this is done: Choose Code > New Construct > Class… CacheService is the class's name. Choose Preview. The EK9 IDE just before choosing Preview: CacheService is the class's name The preview shows CacheService about to be written. Choose Apply. ... |
| Chapter 33: two locks, one order, built | Step 2: The program | Choose Code > New Construct > Program… The EK9 IDE once this is done: Choose Code > New Construct > Program… ConsistentOrder is the program's name. Choose Preview. The EK9 IDE just before choosing Preview: ConsistentOrder is the program's name The preview shows ConsistentOrder about to be ... |
| Chapter 33: two locks, one order, built | Step 3: Run it | Choose Run > Run Program… The EK9 IDE once this is done: Choose Run > Run Program… The project's only program is already chosen. Choose Run. ["refreshed alpha", "evicted alpha"]. Choose Close. The EK9 IDE just before choosing Close: ("refreshed alpha", "evicted alpha") |
| Chapter 33: two locks, one order, built | The result | ConsistentOrder.ek9 now reads exactly as chapter 33 of EK9 in Depth shows it. refresh and evict both take the cache and then the log, so the graph has one edge and no cycle - the program that nests them the other way in a second method is refused with E08252. The EK9 IDE when the lesson has finished |
| Chapter 33: two locks, one order, built | Where this lesson comes from | Answers - ek9 -q and the IDE's Answers tab: 213.For AI assistants - the MCP tool ek9_new_construct, ek9_add_field, ek9_add_method, ek9_add_program. |
| Chapter 33: one lock, nothing to order, built | Chapter 33: one lock, nothing to order, built | The fix for a real lock-order cycle is the one ek9 -h E08252 gives: put both lists in one record under one lock. With only one lock there is no order to get wrong. It costs you contention - every operation on either list now takes the same lock - and it buys a program with nothing to order. The ... |
| Chapter 33: one lock, nothing to order, built | Step 1: CacheState — both lists in one record | Choose Code > New Construct > Record… The EK9 IDE once this is done: Choose Code > New Construct > Record… CacheState is the record's name. The Fields table holds entries of type List of String, starting at List(); log of type List of String, starting at List(). Choose Preview. The EK9 IDE just ... |
| Chapter 33: one lock, nothing to order, built | Step 2: CacheService — one lock | Choose Code > New Construct > Class… The EK9 IDE once this is done: Choose Code > New Construct > Class… CacheService is the class's name. Choose Preview. The EK9 IDE just before choosing Preview: CacheService is the class's name The preview shows CacheService about to be written. Choose Apply. ... |
| Chapter 33: one lock, nothing to order, built | Step 3: The program | Choose Code > New Construct > Program… The EK9 IDE once this is done: Choose Code > New Construct > Program… LockOrderFixed is the program's name. Choose Preview. The EK9 IDE just before choosing Preview: LockOrderFixed is the program's name The preview shows LockOrderFixed about to be written. ... |
| Chapter 33: one lock, nothing to order, built | Step 4: Run it | Choose Run > Run Program… The EK9 IDE once this is done: Choose Run > Run Program… The project's only program is already chosen. Choose Run. CacheState(entries=["alpha", "beta"], log=["refreshed alpha", "refreshed beta", "nightly: cache holds 2"]). Choose Close. The EK9 IDE just before choosing ... |
| Chapter 33: one lock, nothing to order, built | The result | LockOrderFixed.ek9 now reads exactly as chapter 33 of EK9 in Depth shows it: the same idea as the Tally, a record under one lock, and audit can read the entries and write the log in one key. The EK9 IDE when the lesson has finished |
| Chapter 33: one lock, nothing to order, built | Where this lesson comes from | Answers - ek9 -q and the IDE's Answers tab: 213.For AI assistants - the MCP tool ek9_new_construct, ek9_add_operator, ek9_add_field, ek9_add_method, ek9_add_program. |
| Chapter 33: the pair no lock can make atomic, built | Chapter 33: the pair no lock can make atomic, built | The compiler stops a race on a value, a lock taken in the wrong order, a lock handed to another thread. What it does not try to do is make a pair of operations atomic: a check under one lock followed by an act under another is two operations, and nothing is held between them. This Account makes ... |
| Chapter 33: the pair no lock can make atomic, built | Step 1: A constant | Choose Code > New Construct > Constant… The EK9 IDE once this is done: Choose Code > New Construct > Constant… withdrawal is the constant's name and 80 its value - a literal in the Value field, from which the type is inferred. Type both and choose Preview. The EK9 IDE just before choosing ... |
| Chapter 33: the pair no lock can make atomic, built | Step 2: Account — a balance under a lock | Choose Code > New Construct > Class… The EK9 IDE once this is done: Choose Code > New Construct > Class… Account is the class's name. Choose Preview. The EK9 IDE just before choosing Preview: Account is the class's name The preview shows Account about to be written. Choose Apply. The EK9 IDE just ... |
| Chapter 33: the pair no lock can make atomic, built | Step 3: The program | Choose Code > New Construct > Program… The EK9 IDE once this is done: Choose Code > New Construct > Program… CheckThenAct is the program's name. Choose Preview. The EK9 IDE just before choosing Preview: CheckThenAct is the program's name The preview shows CheckThenAct about to be written. Choose ... |
| Chapter 33: the pair no lock can make atomic, built | Step 4: Run it | Choose Run > Run Program… The EK9 IDE once this is done: Choose Run > Run Program… The project's only program is already chosen. Choose Run. both saw enough: true, then check and take apart a balance of -60, then together a balance of 20, with taken true then false. Choose Close. The EK9 IDE just ... |
| Chapter 33: the pair no lock can make atomic, built | The result | CheckThenAct.ek9 now reads exactly as chapter 33 of EK9 in Depth shows it. hasFunds and take, apart, let two withdrawals both see enough and both go through; takeIfFunds does the check and the take under one enter, so the second finds nothing left. Every operation was correct - the pair was not. ... |
| Chapter 33: the pair no lock can make atomic, built | Where this lesson comes from | Answers - ek9 -q and the IDE's Answers tab: 213.For AI assistants - the MCP tool ek9_new_construct, ek9_add_field, ek9_add_method, ek9_add_program. |
| Chapter 34: a contract, two implementations and two applications, built | Chapter 34: a contract, two implementations and two applications, built | If you know Spring or Guice you expect annotations and a container scan. EK9 has neither: a component is a contract, an Application says which implementation stands for it, and a program names the Application it runs under. This lesson builds the notifier example of chapter 34 from the contract ... |
| Chapter 34: a contract, two implementations and two applications, built | Step 1: Notifier — a component | Choose Code > New Construct > Component… The EK9 IDE once this is done: Choose Code > New Construct > Component… Notifier is the component's name. A component is a contract in EK9, not a Spring bean: the abstract one names what any notifier can do and has nothing behind it. Choose Abstract under ... |
| Chapter 34: a contract, two implementations and two applications, built | Step 2: EmailNotifier — a component | Choose Code > New Construct > Component… The EK9 IDE once this is done: Choose Code > New Construct > Component… EmailNotifier is the component's name. It is the production implementation, and Extends is all it takes - there is no annotation and no scan. Type Notifier into Extends. Choose ... |
| Chapter 34: a contract, two implementations and two applications, built | Step 3: ConsoleNotifier — a component | Choose Code > New Construct > Component… The EK9 IDE once this is done: Choose Code > New Construct > Component… ConsoleNotifier is the component's name. It is the second implementation, the one a developer runs without sending real mail. Type Notifier into Extends. Choose Preview. The EK9 IDE ... |
| Chapter 34: a contract, two implementations and two applications, built | Step 4: OrderService — a class | Choose Code > New Construct > Class… The EK9 IDE once this is done: Choose Code > New Construct > Class… OrderService is the class's name. It is an ordinary class that needs a notifier. It will ask for the CONTRACT, never for EmailNotifier or ConsoleNotifier. Choose Preview. The EK9 IDE just ... |
| Chapter 34: a contract, two implementations and two applications, built | Step 5: liveApp — an application | Choose Code > New Construct > Application… The EK9 IDE once this is done: Choose Code > New Construct > Application… liveApp is the application's name. It is production wiring: wherever a Notifier is asked for, the EmailNotifier answers. The Registrations table holds EmailNotifier as Notifier. ... |
| Chapter 34: a contract, two implementations and two applications, built | Step 6: developmentApp — an application | Choose Code > New Construct > Application… The EK9 IDE once this is done: Choose Code > New Construct > Application… developmentApp is the application's name. It is the same contract wired to the other implementation - a second application is all a development setup takes. The Registrations table ... |
| Chapter 34: a contract, two implementations and two applications, built | Step 7: LiveShop — a program | Choose Code > New Construct > Program… The EK9 IDE once this is done: Choose Code > New Construct > Program… LiveShop is the program's name. It runs with application of liveApp. Type liveApp into Application. Choose Preview. The EK9 IDE just before choosing Preview: LiveShop is the program's name ... |
| Chapter 34: a contract, two implementations and two applications, built | Step 8: DevelopmentShop — a program | Choose Code > New Construct > Program… The EK9 IDE once this is done: Choose Code > New Construct > Program… DevelopmentShop is the program's name. It is the same program under the other application. Type developmentApp into Application. Choose Preview. The EK9 IDE just before choosing Preview: ... |
| Chapter 34: a contract, two implementations and two applications, built | Step 9: Run it | Choose Run > Run Program… The EK9 IDE once this is done: Choose Run > Run Program… Choose DevelopmentShop from the list, then choose Run. The EK9 IDE just before choosing Run: Choose DevelopmentShop from the list, then choose Run DevelopmentShop prints the two orders as CONSOLE lines - the same ... |
| Chapter 34: a contract, two implementations and two applications, built | The result | Notifiers.ek9 now reads exactly as chapter 34 of EK9 in Depth shows it. OrderService never names a notifier; the Application a program runs under decides, and swapping EmailNotifier for ConsoleNotifier was a second Application, not a change to OrderService. The EK9 IDE when the lesson has finished |
| Chapter 34: a contract, two implementations and two applications, built | Where this lesson comes from | For AI assistants - the MCP tool ek9_new_construct, ek9_add_field, ek9_add_method, ek9_add_application, ek9_add_program. |
| Chapter 34: the seams that make a game testable, built | Chapter 34: the seams that make a game testable, built | The notifier example showed the seam; this one shows what it buys. A guessing game gets its secret and its player from components, so the live program asks the operating system and the keyboard while a test supplies a fixed number and a script. The lesson builds the game and its live wiring in ... |
| Chapter 34: the seams that make a game testable, built | Step 1: Constants | Choose Code > New Construct > Constant… The EK9 IDE once this is done: Choose Code > New Construct > Constant… HIGHEST is the constant's name and 100 its value - a literal in the Value field, from which the type is inferred. Type both and choose Preview. The EK9 IDE just before choosing Preview: ... |
| Chapter 34: the seams that make a game testable, built | Step 2: hint — a pure function | Choose Code > New Construct > Function… The EK9 IDE once this is done: Choose Code > New Construct > Function… hint is the function's name. Add the parameters secret of type Integer and guess of type Integer, set Returns to String and tick pure. Choose Preview. The EK9 IDE just before choosing ... |
| Chapter 34: the seams that make a game testable, built | Step 3: onTheBoard — a pure function | Choose Code > New Construct > Function… The EK9 IDE once this is done: Choose Code > New Construct > Function… onTheBoard is the function's name. Add one parameter, secret of type Integer, set Returns to Boolean and tick pure. Choose Preview. The EK9 IDE just before choosing Preview: onTheBoard ... |
| Chapter 34: the seams that make a game testable, built | Step 4: triesLeft — a pure function | Choose Code > New Construct > Function… The EK9 IDE once this is done: Choose Code > New Construct > Function… triesLeft is the function's name. Add one parameter, tries of type Integer, set Returns to Boolean and tick pure. Choose Preview. The EK9 IDE just before choosing Preview: triesLeft is ... |
| Chapter 34: the seams that make a game testable, built | Step 5: verdict — a pure function | Choose Code > New Construct > Function… The EK9 IDE once this is done: Choose Code > New Construct > Function… verdict is the function's name. Add the parameters solved of type Boolean and tries of type Integer, set Returns to String and tick pure. Choose Preview. The EK9 IDE just before choosing ... |
| Chapter 34: the seams that make a game testable, built | Step 6: SecretSource — a component | Choose Code > New Construct > Component… The EK9 IDE once this is done: Choose Code > New Construct > Component… SecretSource is the component's name. The secret is a seam: where the number comes from is a component, so a test can fix it. Choose Abstract under Extensibility. Choose Preview. The ... |
| Chapter 34: the seams that make a game testable, built | Step 7: Player — a component | Choose Code > New Construct > Component… The EK9 IDE once this is done: Choose Code > New Construct > Component… Player is the component's name. The player is the second seam: a keyboard in production, a script in a test. Choose Abstract under Extensibility. Choose Preview. The EK9 IDE just ... |
| Chapter 34: the seams that make a game testable, built | Step 8: RandomSecret — a component | Choose Code > New Construct > Component… The EK9 IDE once this is done: Choose Code > New Construct > Component… RandomSecret is the component's name. It is the live secret. Type SecretSource into Extends. Choose Preview. The EK9 IDE just before choosing Preview: RandomSecret is the component's ... |
| Chapter 34: the seams that make a game testable, built | Step 9: KeyboardPlayer — a component | Choose Code > New Construct > Component… The EK9 IDE once this is done: Choose Code > New Construct > Component… KeyboardPlayer is the component's name. It is the live player. Type Player into Extends. Choose Preview. The EK9 IDE just before choosing Preview: KeyboardPlayer is the component's ... |
| Chapter 34: the seams that make a game testable, built | Step 10: GuessGame — a class | Choose Code > New Construct > Class… The EK9 IDE once this is done: Choose Code > New Construct > Class… GuessGame is the class's name. It is the game itself. It asks for its secret and its player as components. Choose Preview. The EK9 IDE just before choosing Preview: GuessGame is the class's ... |
| Chapter 34: the seams that make a game testable, built | Step 11: liveGame — an application | Choose Code > New Construct > Application… The EK9 IDE once this is done: Choose Code > New Construct > Application… liveGame is the application's name. It is the live wiring: a random secret and a player at the keyboard. The Registrations table holds RandomSecret as SecretSource and ... |
| Chapter 34: the seams that make a game testable, built | Step 12: Play — a program | Choose Code > New Construct > Program… The EK9 IDE once this is done: Choose Code > New Construct > Program… Play is the program's name. It runs the game under the live wiring. Type liveGame into Application. Choose Preview. The EK9 IDE just before choosing Preview: Play is the program's name The ... |
| Chapter 34: the seams that make a game testable, built | Step 13: guess-seam/dev/GuessSeamTests.ek9 | Open guess-seam/dev/GuessSeamTests.ek9 in the Project panel - it is already there, with just its module line. The EK9 IDE once this is done: Open guess-seam/dev/GuessSeamTests.ek9 in the Project panel - it is already there, with just its module line A test in another module names what it uses. ... |
| Chapter 34: the seams that make a game testable, built | Step 14: FixedSecret — a component | Choose Code > New Construct > Component… The EK9 IDE once this is done: Choose Code > New Construct > Component… FixedSecret is the component's name. It is a test double: the same contract, a number that never changes. Type SecretSource into Extends. Choose Preview. The EK9 IDE just before ... |
| Chapter 34: the seams that make a game testable, built | Step 15: ScriptedPlayer — a component | Choose Code > New Construct > Component… The EK9 IDE once this is done: Choose Code > New Construct > Component… ScriptedPlayer is the component's name. It plays a fixed script of guesses. Type Player into Extends. Choose Preview. The EK9 IDE just before choosing Preview: ScriptedPlayer is the ... |
| Chapter 34: the seams that make a game testable, built | Step 16: HopelessPlayer — a component | Choose Code > New Construct > Component… The EK9 IDE once this is done: Choose Code > New Construct > Component… HopelessPlayer is the component's name. It always guesses 1. Type Player into Extends. Choose Preview. The EK9 IDE just before choosing Preview: HopelessPlayer is the component's name ... |
| Chapter 34: the seams that make a game testable, built | Step 17: OffTheBoardSecret — a component | Choose Code > New Construct > Component… The EK9 IDE once this is done: Choose Code > New Construct > Component… OffTheBoardSecret is the component's name. It is a secret the game must refuse. Type SecretSource into Extends. Choose Preview. The EK9 IDE just before choosing Preview: ... |
| Chapter 34: the seams that make a game testable, built | Step 18: scriptedGame — an application | Choose Code > New Construct > Application… The EK9 IDE once this is done: Choose Code > New Construct > Application… scriptedGame is the application's name. It wires the fixed secret to the scripted player. The Registrations table holds FixedSecret as SecretSource and ScriptedPlayer as Player. ... |
| Chapter 34: the seams that make a game testable, built | Step 19: hopelessGame — an application | Choose Code > New Construct > Application… The EK9 IDE once this is done: Choose Code > New Construct > Application… hopelessGame is the application's name. It wires the fixed secret to the player who never improves. The Registrations table holds FixedSecret as SecretSource and HopelessPlayer as ... |
| Chapter 34: the seams that make a game testable, built | Step 20: brokenGame — an application | Choose Code > New Construct > Application… The EK9 IDE once this is done: Choose Code > New Construct > Application… brokenGame is the application's name. It wires the impossible secret. The Registrations table holds OffTheBoardSecret as SecretSource and HopelessPlayer as Player. Choose Preview. ... |
| Chapter 34: the seams that make a game testable, built | Step 21: ThirdGuessWins — a test | Choose Code > New Construct > Test… The EK9 IDE once this is done: Choose Code > New Construct > Test… ThirdGuessWins is the test's name. Type scriptedGame into Application. Choose Preview. The EK9 IDE just before choosing Preview: ThirdGuessWins is the test's name The preview shows ... |
| Chapter 34: the seams that make a game testable, built | Step 22: RunsOutOfTries — a test | Choose Code > New Construct > Test… The EK9 IDE once this is done: Choose Code > New Construct > Test… RunsOutOfTries is the test's name. Type hopelessGame into Application. Choose Preview. The EK9 IDE just before choosing Preview: RunsOutOfTries is the test's name The preview shows ... |
| Chapter 34: the seams that make a game testable, built | Step 23: ASecretOffTheBoardIsRefused — a test | Choose Code > New Construct > Test… The EK9 IDE once this is done: Choose Code > New Construct > Test… ASecretOffTheBoardIsRefused is the test's name. Type brokenGame into Application. Choose Preview. The EK9 IDE just before choosing Preview: ASecretOffTheBoardIsRefused is the test's name The ... |
| Chapter 34: the seams that make a game testable, built | Step 24: HintsPointTheRightWay — a test | Choose Code > New Construct > Test… The EK9 IDE once this is done: Choose Code > New Construct > Test… HintsPointTheRightWay is the test's name. It needs no application: hint is a pure function. Leave Application empty. Choose Preview. The EK9 IDE just before choosing Preview: ... |
| Chapter 34: the seams that make a game testable, built | Step 25: VerdictCountsTheTries — a test | Choose Code > New Construct > Test… The EK9 IDE once this is done: Choose Code > New Construct > Test… VerdictCountsTheTries is the test's name. It tests the other pure function. Choose Preview. The EK9 IDE just before choosing Preview: VerdictCountsTheTries is the test's name The preview shows ... |
| Chapter 34: the seams that make a game testable, built | Step 26: TheLastTryIsTheSeventh — a test | Choose Code > New Construct > Test… The EK9 IDE once this is done: Choose Code > New Construct > Test… TheLastTryIsTheSeventh is the test's name. It pins the limit. Choose Preview. The EK9 IDE just before choosing Preview: TheLastTryIsTheSeventh is the test's name The preview shows ... |
| Chapter 34: the seams that make a game testable, built | Step 27: LiveSecretStaysOnTheBoard — a test | Choose Code > New Construct > Test… The EK9 IDE once this is done: Choose Code > New Construct > Test… LiveSecretStaysOnTheBoard is the test's name. It tests the live component directly, with no application: a component can be constructed like any class. Choose Preview. The EK9 IDE just before ... |
| Chapter 34: the seams that make a game testable, built | Step 28: GameIsSet — a test | Choose Code > New Construct > Test… The EK9 IDE once this is done: Choose Code > New Construct > Test… GameIsSet is the test's name. Type scriptedGame into Application. Choose Preview. The EK9 IDE just before choosing Preview: GameIsSet is the test's name The preview shows GameIsSet about to be ... |
| Chapter 34: the seams that make a game testable, built | Step 29: Run it | Run ▸ Run Tests (⌘T) runs every test in the project. Choose Run Tests. The EK9 IDE once this is done: Run ▸ Run Tests (⌘T) runs every test in the project All eight pass: the same GuessGame, a different Application each time. The EK9 IDE once this is done: All eight pass |
| Chapter 34: the seams that make a game testable, built | The result | GuessSeam.ek9 and dev/GuessSeamTests.ek9 now read exactly as chapter 34 of EK9 in Depth shows them. The game never changed between live and test: only the Application did. Run Tests runs all eight. |
| Chapter 34: the seams that make a game testable, built | Where this lesson comes from | For AI assistants - the MCP tool ek9_new_construct, ek9_add_field, ek9_add_method, ek9_add_application, ek9_add_program, ek9_run_tests. |
| Chapter 35: two aspects on one component, built | Chapter 35: two aspects on one component, built | Chapter 35 asks what happens when more than one aspect wraps a component. This lesson builds the chapter's AspectOrder: one aspect class that takes a label, applied twice - outer, then inner - to a greeter, and a program that greets once. To play it in the IDE: Help > Lessons > EK9 in Depth…, or ... |
| Chapter 35: two aspects on one component, built | Step 1: LabelAspect — a class | Choose Code > New Construct > Class… The EK9 IDE once this is done: Choose Code > New Construct > Class… LabelAspect is the class's name. An aspect is a class that extends Aspect - no annotation, no pointcut language. This one takes a label, so it can be applied twice and the two told apart. Type ... |
| Chapter 35: two aspects on one component, built | Step 2: Greeter — a component | Choose Code > New Construct > Component… The EK9 IDE once this is done: Choose Code > New Construct > Component… Greeter is the component's name. It is the contract. Choose Abstract under Extensibility. Choose Preview. The EK9 IDE just before choosing Preview: Greeter is the component's name The ... |
| Chapter 35: two aspects on one component, built | Step 3: PoliteGreeter — a component | Choose Code > New Construct > Component… The EK9 IDE once this is done: Choose Code > New Construct > Component… PoliteGreeter is the component's name. It does the greeting. Type Greeter into Extends. Choose Preview. The EK9 IDE just before choosing Preview: PoliteGreeter is the component's name ... |
| Chapter 35: two aspects on one component, built | Step 4: greetingApp — an application | Choose Code > New Construct > Application… The EK9 IDE once this is done: Choose Code > New Construct > Application… greetingApp is the application's name. It registers PoliteGreeter with TWO aspects, outer first. The order written is the order the before advice runs; the after advice runs in ... |
| Chapter 35: two aspects on one component, built | Step 5: Greeting — a program | Choose Code > New Construct > Program… The EK9 IDE once this is done: Choose Code > New Construct > Program… Greeting is the program's name. It runs under greetingApp and asks for a Greeter. Type greetingApp into Application. Add the injection greeter of type Greeter. Choose Preview. The EK9 IDE ... |
| Chapter 35: two aspects on one component, built | Step 6: Run it | Choose Run > Run Program… The EK9 IDE once this is done: Choose Run > Run Program… The project's only program is already chosen. Choose Run. Four label lines around the greeting: outer before, inner before, hello Steve, inner after, outer after. Choose Close. The EK9 IDE just before choosing ... |
| Chapter 35: two aspects on one component, built | The result | AspectOrder.ek9 now reads exactly as chapter 35 of EK9 in Depth shows it. The before advice ran outer then inner; the after advice ran inner then outer - like nested calls, with the component in the middle. The EK9 IDE when the lesson has finished |
| Chapter 35: two aspects on one component, built | Where this lesson comes from | For AI assistants - the MCP tool ek9_new_construct, ek9_add_field, ek9_add_method, ek9_add_application, ek9_add_program. |
| Chapter 35: a timing aspect and its own data, built | Chapter 35: a timing aspect and its own data, built | Chapter 35's PriceBook is the full example: two aspects on one component, the second one timing each call and passing a TimerData from its before advice to its after advice. The lesson builds the logging aspect, the TimerData and TimerAspect classes, a clock that stands still, the PriceBook ... |
| Chapter 35: a timing aspect and its own data, built | Step 1: LoggingAspect — a class | Choose Code > New Construct > Class… The EK9 IDE once this is done: Choose Code > New Construct > Class… LoggingAspect is the class's name. An aspect is a class that extends Aspect - no annotation, no pointcut language. Type Aspect into Extends. Choose Preview. The EK9 IDE just before choosing ... |
| Chapter 35: a timing aspect and its own data, built | Step 2: TimerData — a class | Choose Code > New Construct > Class… The EK9 IDE once this is done: Choose Code > New Construct > Class… TimerData is the class's name. It is what the timer's before advice hands to its after advice: the PreparedMetaData, plus the moment the call began. Type PreparedMetaData into Extends. Choose ... |
| Chapter 35: a timing aspect and its own data, built | Step 3: TimerAspect — a class | Choose Code > New Construct > Class… The EK9 IDE once this is done: Choose Code > New Construct > Class… TimerAspect is the class's name. It times each call. It is given a Clock, so a test can supply one that stands still. Type Aspect into Extends. Choose Preview. The EK9 IDE just before choosing ... |
| Chapter 35: a timing aspect and its own data, built | Step 4: StandStillClock — a class | Choose Code > New Construct > Class… The EK9 IDE once this is done: Choose Code > New Construct > Class… StandStillClock is the class's name. It is a Clock that never moves, so the book's output is the same every run. Choose Preview. The EK9 IDE just before choosing Preview: StandStillClock is ... |
| Chapter 35: a timing aspect and its own data, built | Step 5: PriceBook — a component | Choose Code > New Construct > Component… The EK9 IDE once this is done: Choose Code > New Construct > Component… PriceBook is the component's name. It is the contract the aspects wrap. Choose Abstract under Extensibility. Choose Preview. The EK9 IDE just before choosing Preview: PriceBook is the ... |
| Chapter 35: a timing aspect and its own data, built | Step 6: SimplePriceBook — a component | Choose Code > New Construct > Component… The EK9 IDE once this is done: Choose Code > New Construct > Component… SimplePriceBook is the component's name. It answers the same price for everything. Type PriceBook into Extends. Choose Preview. The EK9 IDE just before choosing Preview: ... |
| Chapter 35: a timing aspect and its own data, built | Step 7: shopApp — an application | Choose Code > New Construct > Application… The EK9 IDE once this is done: Choose Code > New Construct > Application… shopApp is the application's name. It registers SimplePriceBook with two aspects, one cell with a comma between: the second is given its clock right there, ... |
| Chapter 35: a timing aspect and its own data, built | Step 8: Shop — a program | Choose Code > New Construct > Program… The EK9 IDE once this is done: Choose Code > New Construct > Program… Shop is the program's name. It runs under shopApp and asks for a PriceBook. Type shopApp into Application. Add the injection prices of type PriceBook. Choose Preview. The EK9 IDE just ... |
| Chapter 35: a timing aspect and its own data, built | Step 9: Run it | Choose Run > Run Program… The EK9 IDE once this is done: Choose Run > Run Program… The project's only program is already chosen. Choose Run. The log and timer lines around each call, the timer always reporting the same elapsed time because the clock stands still. Choose Close. The EK9 IDE just ... |
| Chapter 35: a timing aspect and its own data, built | The result | PriceBook.ek9 now reads exactly as chapter 35 of EK9 in Depth shows it. The same pair of aspects wrapped a call with a result and a call without, and neither the component nor the program mentions either. The EK9 IDE when the lesson has finished |
| Chapter 35: a timing aspect and its own data, built | Where this lesson comes from | For AI assistants - the MCP tool ek9_new_construct, ek9_add_field, ek9_add_method, ek9_add_operator, ek9_adopt_trait, ek9_add_application, ek9_add_program. |
| Chapter 35: an aspect around a method that throws, built | Chapter 35: an aspect around a method that throws, built | What does an aspect do when the method it wraps throws? Chapter 35's AspectException builds a payment gateway that refuses a negative amount, a logging aspect around it, and a caller that catches the failure. To play it in the IDE: Help > Lessons > EK9 in Depth…, or ek9 -ide -lesson ... |
| Chapter 35: an aspect around a method that throws, built | Step 1: LoggingAspect — a class | Choose Code > New Construct > Class… The EK9 IDE once this is done: Choose Code > New Construct > Class… LoggingAspect is the class's name. An aspect is a class that extends Aspect - no annotation, no pointcut language. Type Aspect into Extends. Choose Preview. The EK9 IDE just before choosing ... |
| Chapter 35: an aspect around a method that throws, built | Step 2: PaymentGateway — a component | Choose Code > New Construct > Component… The EK9 IDE once this is done: Choose Code > New Construct > Component… PaymentGateway is the component's name. It is the contract. Choose Abstract under Extensibility. Choose Preview. The EK9 IDE just before choosing Preview: PaymentGateway is the ... |
| Chapter 35: an aspect around a method that throws, built | Step 3: StrictGateway — a component | Choose Code > New Construct > Component… The EK9 IDE once this is done: Choose Code > New Construct > Component… StrictGateway is the component's name. It refuses a negative amount by throwing. Type PaymentGateway into Extends. Choose Preview. The EK9 IDE just before choosing Preview: ... |
| Chapter 35: an aspect around a method that throws, built | Step 4: paymentsApp — an application | Choose Code > New Construct > Application… The EK9 IDE once this is done: Choose Code > New Construct > Application… paymentsApp is the application's name. It registers StrictGateway as a PaymentGateway with the logging aspect. The Registrations table holds StrictGateway as PaymentGateway, with ... |
| Chapter 35: an aspect around a method that throws, built | Step 5: Payments — a program | Choose Code > New Construct > Program… The EK9 IDE once this is done: Choose Code > New Construct > Program… Payments is the program's name. It runs under paymentsApp and asks for a PaymentGateway. Type paymentsApp into Application. Add the injection gateway of type PaymentGateway. Choose ... |
| Chapter 35: an aspect around a method that throws, built | Step 6: Run it | Choose Run > Run Program… The EK9 IDE once this is done: Choose Run > Run Program… The project's only program is already chosen. Choose Run. The first charge is wrapped in the log lines; the second is logged before, then refused - and the caller's catch prints the reason. Choose Close. The EK9 ... |
| Chapter 35: an aspect around a method that throws, built | The result | AspectException.ek9 now reads exactly as chapter 35 of EK9 in Depth shows it. The caller still catches the exception: an aspect does not swallow it, and the after advice is skipped when the method throws. The EK9 IDE when the lesson has finished |
| Chapter 35: an aspect around a method that throws, built | Where this lesson comes from | For AI assistants - the MCP tool ek9_new_construct, ek9_add_method, ek9_add_operator, ek9_add_application, ek9_add_program. |
| Chapter 35: an aspect that counts calls, built | Chapter 35: an aspect that counts calls, built | If you know AspectJ or Spring AOP you expect pointcut expressions and a proxy. An EK9 aspect is a class that extends Aspect, and it is attached on a register line of an application. This lesson builds the smallest useful one: an aspect that counts calls, wrapped round a Worker that never knows. ... |
| Chapter 35: an aspect that counts calls, built | Step 1: CountingAspect — a class | Choose Code > New Construct > Class… The EK9 IDE once this is done: Choose Code > New Construct > Class… CountingAspect is the class's name. An aspect is a class that extends Aspect - no annotation, no pointcut language. Type Aspect into Extends. Choose Preview. The EK9 IDE just before choosing ... |
| Chapter 35: an aspect that counts calls, built | Step 2: Worker — a component | Choose Code > New Construct > Component… The EK9 IDE once this is done: Choose Code > New Construct > Component… Worker is the component's name. It is the contract the aspect will wrap. Choose Abstract under Extensibility. Choose Preview. The EK9 IDE just before choosing Preview: Worker is the ... |
| Chapter 35: an aspect that counts calls, built | Step 3: PlainWorker — a component | Choose Code > New Construct > Component… The EK9 IDE once this is done: Choose Code > New Construct > Component… PlainWorker is the component's name. It does the work and knows nothing about counting. Type Worker into Extends. Choose Preview. The EK9 IDE just before choosing Preview: PlainWorker ... |
| Chapter 35: an aspect that counts calls, built | Step 4: countingApp — an application | Choose Code > New Construct > Application… The EK9 IDE once this is done: Choose Code > New Construct > Application… countingApp is the application's name. It registers PlainWorker as a Worker with CountingAspect: the aspect is attached where the component is registered, never inside it. The ... |
| Chapter 35: an aspect that counts calls, built | Step 5: Echo — a program | Choose Code > New Construct > Program… The EK9 IDE once this is done: Choose Code > New Construct > Program… Echo is the program's name. It runs under countingApp and asks for a Worker. Type countingApp into Application. Add the injection worker of type Worker. Choose Preview. The EK9 IDE just ... |
| Chapter 35: an aspect that counts calls, built | Step 6: Run it | Choose Run > Run Program… The EK9 IDE once this is done: Choose Run > Run Program… The project's only program is already chosen. Choose Run. Two calls, and after each the aspect prints how many calls so far: the work output, then calls so far 1, then the second, then calls so far 2. Choose Close. ... |
| Chapter 35: an aspect that counts calls, built | The result | CallCounter.ek9 now reads exactly as chapter 35 of EK9 in Depth shows it. PlainWorker and Echo never mention CountingAspect; the register line in countingApp is the only place the two meet. The EK9 IDE when the lesson has finished |
| Chapter 35: an aspect that counts calls, built | Where this lesson comes from | For AI assistants - the MCP tool ek9_new_construct, ek9_add_field, ek9_add_method, ek9_add_application, ek9_add_program. |
| Chapter 36: a server and its own client in one process, built | Chapter 36: a server and its own client in one process, built | A network program does not have to be two programs. This lesson builds chapter 36's first example, a TCP server and its own client in ONE process: the server asks the operating system for a free port, so nothing is fixed and nothing outside the machine can reach it. echo is a named function that ... |
| Chapter 36: a server and its own client in one process, built | Step 1: echo — a function | Choose Code > New Construct > Function… The EK9 IDE once this is done: Choose Code > New Construct > Function… echo is the function's name. Add the parameters input of type StringInput and output of type StringOutput, type TCPHandler into Extends. Choose Preview. The EK9 IDE just before choosing ... |
| Chapter 36: a server and its own client in one process, built | Step 2: EchoInProcess — a program | Choose Code > New Construct > Program… The EK9 IDE once this is done: Choose Code > New Construct > Program… EchoInProcess is the program's name. Choose Preview. The EK9 IDE just before choosing Preview: EchoInProcess is the program's name The preview shows EchoInProcess about to be written. ... |
| Chapter 36: a server and its own client in one process, built | Step 3: Run it | Choose Run > Run Program… The EK9 IDE once this is done: Choose Run > Run Program… The project's only program is already chosen. Choose Run. The client received echo:hello, the server was still set when it stopped, and the try had closed it by the last line. Choose Close. The EK9 IDE just before ... |
| Chapter 36: a server and its own client in one process, built | The result | EchoInProcess.ek9 now reads exactly as chapter 36 of EK9 in Depth shows it: a server that is stopped by its own client and closed by the try that owns it - nothing in the program says close. The EK9 IDE when the lesson has finished |
| Chapter 36: a server and its own client in one process, built | Where this lesson comes from | For AI assistants - the MCP tool ek9_new_construct, ek9_add_program, ek9_run_program. |
| Chapter 36: a TCP line server and its client, built | Chapter 36: a TCP line server and its client, built | Chapter 36's line server is two programs in two files: one listens, the other connects, and the word shutdown ends the server. The port is a constant in both files and the server listens on the loopback address alone. This lesson builds both. To play it in the IDE: Help > Lessons > EK9 in Depth…, ... |
| Chapter 36: a TCP line server and its client, built | Step 1: Constants | Choose Code > New Construct > Constant… The EK9 IDE once this is done: Choose Code > New Construct > Constant… SERVER_PORT is the constant's name and 4446 its value - a literal in the Value field, from which the type is inferred. Type both and choose Preview. The EK9 IDE just before choosing ... |
| Chapter 36: a TCP line server and its client, built | Step 2: LineServer — a program | Choose Code > New Construct > Program… The EK9 IDE once this is done: Choose Code > New Construct > Program… LineServer is the program's name. Choose Preview. The EK9 IDE just before choosing Preview: LineServer is the program's name The preview shows LineServer about to be written. Choose Apply. ... |
| Chapter 36: a TCP line server and its client, built | Step 3: LineClient.ek9 | Open LineClient.ek9 in the Project panel - it is already there, with just its module line. The EK9 IDE once this is done: Open LineClient.ek9 in the Project panel - it is already there, with just its module line |
| Chapter 36: a TCP line server and its client, built | Step 4: A constant | Choose Code > New Construct > Constant… The EK9 IDE once this is done: Choose Code > New Construct > Constant… SERVER_PORT is the constant's name and 4446 its value - a literal in the Value field, from which the type is inferred. Type both and choose Preview. The EK9 IDE just before choosing ... |
| Chapter 36: a TCP line server and its client, built | Step 5: LineClient — a program | Choose Code > New Construct > Program… The EK9 IDE once this is done: Choose Code > New Construct > Program… LineClient is the program's name. It takes the message as its argument. Add one parameter, message of type String. Choose Preview. The EK9 IDE just before choosing Preview: LineClient is ... |
| Chapter 36: a TCP line server and its client, built | Step 6: Run it | Choose Run > Run Program… The EK9 IDE once this is done: Choose Run > Run Program… Choose LineServer from the list, then choose Run. The program starts and stays running: its window opens, blank until it ends - a run's output arrives when the program finishes. It listens on this machine's ... |
| Chapter 36: a TCP line server and its client, built | The result | LineServer.ek9 and LineClient.ek9 now read exactly as chapter 36 of EK9 in Depth shows them. The handler captures the server it belongs to, which is how the word shutdown can stop it without closing it - only the try that owns a server closes it. The EK9 IDE when the lesson has finished |
| Chapter 36: a TCP line server and its client, built | Where this lesson comes from | For AI assistants - the MCP tool ek9_new_construct, ek9_add_program. |
| Chapter 36: a UDP echo server and client, built | Chapter 36: a UDP echo server and client, built | UDP has no connection, only packets: a server that receives one and sends it back, and a client that sends two and reads the replies. Both use the loopback address and one fixed port, and the word end stops the server. This lesson builds both files. To play it in the IDE: Help > Lessons > EK9 in ... |
| Chapter 36: a UDP echo server and client, built | Step 1: Constants | Choose Code > New Construct > Constant… The EK9 IDE once this is done: Choose Code > New Construct > Constant… ECHO_PORT is the constant's name and 4447 its value - a literal in the Value field, from which the type is inferred. Type both and choose Preview. The EK9 IDE just before choosing ... |
| Chapter 36: a UDP echo server and client, built | Step 2: UdpEchoServer — a program | Choose Code > New Construct > Program… The EK9 IDE once this is done: Choose Code > New Construct > Program… UdpEchoServer is the program's name. Choose Preview. The EK9 IDE just before choosing Preview: UdpEchoServer is the program's name The preview shows UdpEchoServer about to be written. ... |
| Chapter 36: a UDP echo server and client, built | Step 3: UdpEchoClient.ek9 | Open UdpEchoClient.ek9 in the Project panel - it is already there, with just its module line. The EK9 IDE once this is done: Open UdpEchoClient.ek9 in the Project panel - it is already there, with just its module line |
| Chapter 36: a UDP echo server and client, built | Step 4: Constants | Choose Code > New Construct > Constant… The EK9 IDE once this is done: Choose Code > New Construct > Constant… ECHO_PORT is the constant's name and 4447 its value - a literal in the Value field, from which the type is inferred. Type both and choose Preview. The EK9 IDE just before choosing ... |
| Chapter 36: a UDP echo server and client, built | Step 5: exchange — a function | Choose Code > New Construct > Function… The EK9 IDE once this is done: Choose Code > New Construct > Function… exchange is the function's name. Add the parameters client of type UDP and packet of type UDPPacket. Choose Preview. The EK9 IDE just before choosing Preview: exchange is the function's ... |
| Chapter 36: a UDP echo server and client, built | Step 6: UdpEchoClient — a program | Choose Code > New Construct > Program… The EK9 IDE once this is done: Choose Code > New Construct > Program… UdpEchoClient is the program's name. Choose Preview. The EK9 IDE just before choosing Preview: UdpEchoClient is the program's name The preview shows UdpEchoClient about to be written. ... |
| Chapter 36: a UDP echo server and client, built | Step 7: Run it | Choose Run > Run Program… The EK9 IDE once this is done: Choose Run > Run Program… Choose UdpEchoServer from the list, then choose Run. The program starts and stays running: its window opens, blank until it ends - a run's output arrives when the program finishes. It listens on this machine's ... |
| Chapter 36: a UDP echo server and client, built | The result | UdpEchoServer.ek9 and UdpEchoClient.ek9 now read exactly as chapter 36 of EK9 in Depth shows them. A client with a timeout asks for a reply and gets 'no response' rather than waiting for ever. The EK9 IDE when the lesson has finished |
| Chapter 36: a UDP echo server and client, built | Where this lesson comes from | For AI assistants - the MCP tool ek9_new_construct, ek9_add_program. |
| Chapter 36: UDP as a stream pipeline, built | Chapter 36: UDP as a stream pipeline, built | A UDP connection is a stream source and a stream sink, so a server can be one pipeline: cat the connection, map each packet through a handler, send the results on. The client is the same shape in the other direction. Both programs are built here; the server is stopped by a signal, so this lesson ... |
| Chapter 36: UDP as a stream pipeline, built | Step 1: Constants | Choose Code > New Construct > Constant… The EK9 IDE once this is done: Choose Code > New Construct > Constant… PIPELINE_PORT is the constant's name and 4448 its value - a literal in the Value field, from which the type is inferred. Type both and choose Preview. The EK9 IDE just before choosing ... |
| Chapter 36: UDP as a stream pipeline, built | Step 2: packetHandler — a function | Choose Code > New Construct > Function… The EK9 IDE once this is done: Choose Code > New Construct > Function… packetHandler is the function's name. Add one parameter, incoming of type UDPPacket, set Returns to UDPPacket and tick as abstract - a function type: a contract with no body. Choose ... |
| Chapter 36: UDP as a stream pipeline, built | Step 3: UdpPipelineServer — a program | Choose Code > New Construct > Program… The EK9 IDE once this is done: Choose Code > New Construct > Program… UdpPipelineServer is the program's name. Choose Preview. The EK9 IDE just before choosing Preview: UdpPipelineServer is the program's name The preview shows UdpPipelineServer about to be ... |
| Chapter 36: UDP as a stream pipeline, built | Step 4: UdpPipelineClient.ek9 | Open UdpPipelineClient.ek9 in the Project panel - it is already there, with just its module line. The EK9 IDE once this is done: Open UdpPipelineClient.ek9 in the Project panel - it is already there, with just its module line |
| Chapter 36: UDP as a stream pipeline, built | Step 5: A constant | Choose Code > New Construct > Constant… The EK9 IDE once this is done: Choose Code > New Construct > Constant… PIPELINE_PORT is the constant's name and 4448 its value - a literal in the Value field, from which the type is inferred. Type both and choose Preview. The EK9 IDE just before choosing ... |
| Chapter 36: UDP as a stream pipeline, built | Step 6: packetConverter — a function | Choose Code > New Construct > Function… The EK9 IDE once this is done: Choose Code > New Construct > Function… packetConverter is the function's name. Add one parameter, content of type String, set Returns to UDPPacket and tick as abstract - a function type: a contract with no body. Choose ... |
| Chapter 36: UDP as a stream pipeline, built | Step 7: UdpPipelineClient — a program | Choose Code > New Construct > Program… The EK9 IDE once this is done: Choose Code > New Construct > Program… UdpPipelineClient is the program's name. Choose Preview. The EK9 IDE just before choosing Preview: UdpPipelineClient is the program's name The preview shows UdpPipelineClient about to be ... |
| Chapter 36: UDP as a stream pipeline, built | The result | UdpPipelineServer.ek9 and UdpPipelineClient.ek9 now read exactly as chapter 36 of EK9 in Depth shows them: an abstract function as the contract, a dynamic function that implements it, and a pipeline. |
| Chapter 36: UDP as a stream pipeline, built | Where this lesson comes from | For AI assistants - the MCP tool ek9_new_construct, ek9_add_program. |
| Chapter 36: where a program's URLs come from, built | Chapter 36: where a program's URLs come from, built | Where does a program's URL come from? Chapter 36 reads it from an environment variable, and the answer is an unset URL when the value is missing, malformed or refused by policy - never an exception. This lesson builds the small program that reports three destinations. To play it in the IDE: Help ... |
| Chapter 36: where a program's URLs come from, built | Step 1: report — a function | Choose Code > New Construct > Function… The EK9 IDE once this is done: Choose Code > New Construct > Function… report is the function's name. Add one parameter, variableName of type String. Choose Preview. The EK9 IDE just before choosing Preview: report is the function's name The preview shows ... |
| Chapter 36: where a program's URLs come from, built | Step 2: CheckDestinations — a program | Choose Code > New Construct > Program… The EK9 IDE once this is done: Choose Code > New Construct > Program… CheckDestinations is the program's name. Choose Preview. The EK9 IDE just before choosing Preview: CheckDestinations is the program's name The preview shows CheckDestinations about to be ... |
| Chapter 36: where a program's URLs come from, built | Step 3: Run it | Choose Run > Run Program… The EK9 IDE once this is done: Choose Run > Run Program… The project's only program is already chosen. Choose Run. None of the three variables is set in this run, so each line says it is refused or not set - the same answer a malformed or policy-refused value would get. ... |
| Chapter 36: where a program's URLs come from, built | The result | CheckDestinations.ek9 now reads exactly as chapter 36 of EK9 in Depth shows it. urlFromEnv gives a URL that is either usable or unset; one question, destination?, covers every failure. The EK9 IDE when the lesson has finished |
| Chapter 36: where a program's URLs come from, built | Where this lesson comes from | For AI assistants - the MCP tool ek9_new_construct, ek9_add_program, ek9_run_program. |
| Chapter 36: links from a base URL, built | Chapter 36: links from a base URL, built | A service builds links from a base URL it was configured with, not from the request. Chapter 36's NoteLinks resolves a path, appends a segment and a query parameter, and prints them. To play it in the IDE: Help > Lessons > EK9 in Depth…, or ek9 -ide -lesson depth-note-links. The EK9 IDE as the ... |
| Chapter 36: links from a base URL, built | Step 1: NoteLinks — a program | Choose Code > New Construct > Program… The EK9 IDE once this is done: Choose Code > New Construct > Program… NoteLinks is the program's name. It takes the note's id as its argument. Add one parameter, noteId of type String. Choose Preview. The EK9 IDE just before choosing Preview: NoteLinks is ... |
| Chapter 36: links from a base URL, built | Step 2: Run it | Choose Run > Run Program… The EK9 IDE once this is done: Choose Run > Run Program… Type 42 into Arguments (space-separated), then choose Run. The EK9 IDE just before choosing Run: Type 42 into Arguments (space-separated), then choose Run PUBLIC_BASE_URL is not set in this run, so the program ... |
| Chapter 36: links from a base URL, built | The result | NoteLinks.ek9 now reads exactly as chapter 36 of EK9 in Depth shows it. The URL type builds the links; no string is joined by hand. The EK9 IDE when the lesson has finished |
| Chapter 36: links from a base URL, built | Where this lesson comes from | For AI assistants - the MCP tool ek9_add_program, ek9_run_program. |
| Chapter 36: a service and its HTTP client in one process, built | Chapter 36: a service and its HTTP client in one process, built | The client side of HTTP: HTTPClient is a closeable the try owns, send gives back a Result, and a program can run a service and its caller in one process on a port the operating system chose - the shape of EchoInProcess again. This lesson builds the service, a function that calls it three ways, ... |
| Chapter 36: a service and its HTTP client in one process, built | Step 1: describe — a function | Choose Code > New Construct > Function… The EK9 IDE once this is done: Choose Code > New Construct > Function… describe is the function's name. Add one parameter, result of type Result of (HTTPClientResponse, HTTPError). Choose Preview. The EK9 IDE just before choosing Preview: describe is the ... |
| Chapter 36: a service and its HTTP client in one process, built | Step 2: callGreeting — a function | Choose Code > New Construct > Function… The EK9 IDE once this is done: Choose Code > New Construct > Function… callGreeting is the function's name. Add one parameter, port of type Integer. Choose Preview. The EK9 IDE just before choosing Preview: callGreeting is the function's name The preview ... |
| Chapter 36: a service and its HTTP client in one process, built | Step 3: Greeting — a service | Choose Code > New Construct > Service… The EK9 IDE once this is done: Choose Code > New Construct > Service… Greeting is the service's name and /greeting the base URI every route sits under. The route's parameter personName takes its value from the path variable name. The Routes table holds ... |
| Chapter 36: a service and its HTTP client in one process, built | Step 4: GreetingApp — an application | Choose Code > New Construct > Application… The EK9 IDE once this is done: Choose Code > New Construct > Application… GreetingApp is the application's name. It registers the service. The Registrations table holds Greeting. Choose Preview. The EK9 IDE just before choosing Preview: GreetingApp is ... |
| Chapter 36: a service and its HTTP client in one process, built | Step 5: ServeAndCall — a program | Choose Code > New Construct > Program… The EK9 IDE once this is done: Choose Code > New Construct > Program… ServeAndCall is the program's name. Leave Application empty - a later step says why. Choose Preview. The EK9 IDE just before choosing Preview: ServeAndCall is the program's name The ... |
| Chapter 36: a service and its HTTP client in one process, built | Step 6: Run it | Choose Run > Run Program… The EK9 IDE once this is done: Choose Run > Run Program… The project's only program is already chosen. Choose Run. The first request is answered with hello Ada; the second is answered 404, which is still an ok Result; the third is not sent, and the Result carries the ... |
| Chapter 36: a service and its HTTP client in one process, built | The result | ServeAndCall.ek9 now reads exactly as chapter 36 of EK9 in Depth shows it. Three requests, three meanings: an answer, an answer that is a 404 - an error status is still a response - and a request that was never sent because TRACE is not an HTTPMethod. The EK9 IDE when the lesson has finished |
| Chapter 36: a service and its HTTP client in one process, built | Where this lesson comes from | For AI assistants - the MCP tool ek9_new_construct, ek9_add_application, ek9_add_program, ek9_run_program. |
| Chapter 37: the smallest web service, built | Chapter 37: the smallest web service, built | A web service in EK9 is a construct, not annotations on a class. Chapter 37 builds one a step at a time, starting with the smallest: one route that greets by name, registered in an application and served by a program that listens on the loopback address only, and stops cleanly when it is sent ... |
| Chapter 37: the smallest web service, built | Step 1: Constants | Choose Code > New Construct > Constant… The EK9 IDE once this is done: Choose Code > New Construct > Constant… HELLO_PORT is the constant's name and 8083 its value - a literal in the Value field, from which the type is inferred. Type both and choose Preview. The EK9 IDE just before choosing ... |
| Chapter 37: the smallest web service, built | Step 2: Greeting — a service | Choose Code > New Construct > Service… The EK9 IDE once this is done: Choose Code > New Construct > Service… Greeting is the service's name and /greeting the base URI every route sits under. The route's parameter personName takes its value from the path variable name. The Routes table holds ... |
| Chapter 37: the smallest web service, built | Step 3: GreetingApp — an application | Choose Code > New Construct > Application… The EK9 IDE once this is done: Choose Code > New Construct > Application… GreetingApp is the application's name. It registers the service. There is no scanning: a service that is not registered is not served. The Registrations table holds Greeting. ... |
| Chapter 37: the smallest web service, built | Step 4: ServeGreeting — a program | Choose Code > New Construct > Program… The EK9 IDE once this is done: Choose Code > New Construct > Program… ServeGreeting is the program's name. Leave Application empty - a later step says why. Choose Preview. The EK9 IDE just before choosing Preview: ServeGreeting is the program's name The ... |
| Chapter 37: the smallest web service, built | The result | HelloNotes.ek9 now reads exactly as chapter 37 of EK9 in Depth shows it. The route's parameter has its own name, personName, and takes the value from the path variable name; the server is created localOnly, so it can only be reached from this machine. The program is built, not run: it serves ... |
| Chapter 37: the smallest web service, built | Where this lesson comes from | For AI assistants - the MCP tool ek9_new_construct, ek9_add_application, ek9_add_program. |
| Chapter 37: JSON in and out, built | Chapter 37: JSON in and out, built | Chapter 37 reads JSON from a request and writes JSON in a response. This lesson builds the small program behind that: a parsed document read field by field - a missing field is simply unset - a malformed body that comes back as an error and not an exception, and a record written back out with $$. ... |
| Chapter 37: JSON in and out, built | Step 1: Constants | Choose Code > New Construct > Constant… The EK9 IDE once this is done: Choose Code > New Construct > Constant… TEXT_FIELD is the constant's name and "text" its value - a literal in the Value field, from which the type is inferred. Type both and choose Preview. The EK9 IDE just before choosing ... |
| Chapter 37: JSON in and out, built | Step 2: Note — a record | Choose Code > New Construct > Record… The EK9 IDE once this is done: Choose Code > New Construct > Record… Note is the record's name. A note is a value: an id and its text. The Fields table holds id of type Integer, starting at Integer(); text of type String, starting at String(). Choose Preview. ... |
| Chapter 37: JSON in and out, built | Step 3: textOf — a pure function | Choose Code > New Construct > Function… The EK9 IDE once this is done: Choose Code > New Construct > Function… textOf is the function's name. Add the parameters document of type JSON and field of type String, set Returns to String and tick pure. Choose Preview. The EK9 IDE just before choosing ... |
| Chapter 37: JSON in and out, built | Step 4: describe — a function | Choose Code > New Construct > Function… The EK9 IDE once this is done: Choose Code > New Construct > Function… describe is the function's name. Add one parameter, document of type JSON. Choose Preview. The EK9 IDE just before choosing Preview: describe is the function's name The preview shows ... |
| Chapter 37: JSON in and out, built | Step 5: JsonDocuments — a program | Choose Code > New Construct > Program… The EK9 IDE once this is done: Choose Code > New Construct > Program… JsonDocuments is the program's name. Choose Preview. The EK9 IDE just before choosing Preview: JsonDocuments is the program's name The preview shows JsonDocuments about to be written. ... |
| Chapter 37: JSON in and out, built | Step 6: Run it | Choose Run > Run Program… The EK9 IDE once this is done: Choose Run > Run Program… The project's only program is already chosen. Choose Run. The note's text as JSON and as plain text, its two tags, that pinned is not set; then the broken and the empty bodies each reported as an error, and finally ... |
| Chapter 37: JSON in and out, built | The result | JsonDocuments.ek9 now reads exactly as chapter 37 of EK9 in Depth shows it. parse gives a Result, so bad input never throws; get on a missing field gives an unset JSON, and $$ is the one operator that writes a value as JSON. The EK9 IDE when the lesson has finished |
| Chapter 37: JSON in and out, built | Where this lesson comes from | For AI assistants - the MCP tool ek9_new_construct, ek9_add_constructor, ek9_add_operator, ek9_add_program, ek9_run_program. |
| Chapter 37: two routes that could both match, built | Chapter 37: two routes that could both match, built | Which route answers /words/search - the one with a variable or the one with the fixed path? Chapter 37's RouteOrder asks the question with two routes. This lesson builds the service and the program that serves it. To play it in the IDE: Help > Lessons > EK9 in Depth…, or ek9 -ide -lesson ... |
| Chapter 37: two routes that could both match, built | Step 1: A constant | Choose Code > New Construct > Constant… The EK9 IDE once this is done: Choose Code > New Construct > Constant… ORDER_PORT is the constant's name and 8082 its value - a literal in the Value field, from which the type is inferred. Type both and choose Preview. The EK9 IDE just before choosing ... |
| Chapter 37: two routes that could both match, built | Step 2: plain — a function | Choose Code > New Construct > Function… The EK9 IDE once this is done: Choose Code > New Construct > Function… plain is the function's name. Add one parameter, text of type String, set Returns to String. Choose Preview. The EK9 IDE just before choosing Preview: plain is the function's name The ... |
| Chapter 37: two routes that could both match, built | Step 3: Words — a service | Choose Code > New Construct > Service… The EK9 IDE once this is done: Choose Code > New Construct > Service… Words is the service's name and /words the base URI every route sits under. Two routes: one with a path variable, one with a fixed path. Both could match /words/search; the order is the ... |
| Chapter 37: two routes that could both match, built | Step 4: WordsApp — an application | Choose Code > New Construct > Application… The EK9 IDE once this is done: Choose Code > New Construct > Application… WordsApp is the application's name. It registers the service. The Registrations table holds Words. Choose Preview. The EK9 IDE just before choosing Preview: WordsApp is the ... |
| Chapter 37: two routes that could both match, built | Step 5: ServeWords — a program | Choose Code > New Construct > Program… The EK9 IDE once this is done: Choose Code > New Construct > Program… ServeWords is the program's name. Leave Application empty - a later step says why. Choose Preview. The EK9 IDE just before choosing Preview: ServeWords is the program's name The preview ... |
| Chapter 37: two routes that could both match, built | The result | RouteOrder.ek9 now reads exactly as chapter 37 of EK9 in Depth shows it: two routes answering through one small function. The program is built, not run: it serves until sent TERM. |
| Chapter 37: two routes that could both match, built | Where this lesson comes from | For AI assistants - the MCP tool ek9_new_construct, ek9_add_application, ek9_add_program. |
| Chapter 37: a key that cannot be printed, built | Chapter 37: a key that cannot be printed, built | A service that calls another one holds a secret. Chapter 37's Sensitive wraps it so it cannot be printed, interpolated or serialised by accident, and only a class marked Privileged may reveal it. This lesson builds that class and a program that tries to print the key. To play it in the IDE: Help ... |
| Chapter 37: a key that cannot be printed, built | Step 1: A constant | Choose Code > New Construct > Constant… The EK9 IDE once this is done: Choose Code > New Construct > Constant… SYNC_KEY_NAME is the constant's name and "NOTES_SYNC_KEY" its value - a literal in the Value field, from which the type is inferred. Type both and choose Preview. The EK9 IDE just before ... |
| Chapter 37: a key that cannot be printed, built | Step 2: authorisationFor — a pure function | Choose Code > New Construct > Function… The EK9 IDE once this is done: Choose Code > New Construct > Function… authorisationFor is the function's name. Add one parameter, header of type String, set Returns to String and tick pure. Choose Preview. The EK9 IDE just before choosing Preview: ... |
| Chapter 37: a key that cannot be printed, built | Step 3: NoteSync — a class | Choose Code > New Construct > Class… The EK9 IDE once this is done: Choose Code > New Construct > Class… NoteSync is the class's name. It is the one class that may reveal the key. Choose Preview. The EK9 IDE just before choosing Preview: NoteSync is the class's name The preview shows NoteSync ... |
| Chapter 37: a key that cannot be printed, built | Step 4: ShowSyncKey — a program | Choose Code > New Construct > Program… The EK9 IDE once this is done: Choose Code > New Construct > Program… ShowSyncKey is the program's name. Choose Preview. The EK9 IDE just before choosing Preview: ShowSyncKey is the program's name The preview shows ShowSyncKey about to be written. Choose ... |
| Chapter 37: a key that cannot be printed, built | Step 5: Run it | Choose Run > Run Program… The EK9 IDE once this is done: Choose Run > Run Program… The project's only program is already chosen. Choose Run. NOTES_SYNC_KEY is not set in this run, so the program says so; set it in a run configuration and the key still never prints. Choose Close. The EK9 IDE just ... |
| Chapter 37: a key that cannot be printed, built | The result | SyncKey.ek9 now reads exactly as chapter 37 of EK9 in Depth shows it. The key prints as nothing useful - stdout, string interpolation and JSON all refuse to show it - and only NoteSync, which is Privileged, can read it to build the header. The EK9 IDE when the lesson has finished |
| Chapter 37: a key that cannot be printed, built | Where this lesson comes from | For AI assistants - the MCP tool ek9_new_construct, ek9_adopt_trait, ek9_add_field, ek9_add_method, ek9_add_program, ek9_run_program. |
| Chapter 37: a status decided late, built | Chapter 37: a status decided late, built | When is an HTTP status decided? Usually before the body - but a body can discover a problem. Chapter 37's LateStatus builds a response class whose status is read after its content is made, and a route that returns it. To play it in the IDE: Help > Lessons > EK9 in Depth…, or ek9 -ide -lesson ... |
| Chapter 37: a status decided late, built | Step 1: Constants | Choose Code > New Construct > Constant… The EK9 IDE once this is done: Choose Code > New Construct > Constant… LATE_PORT is the constant's name and 8084 its value - a literal in the Value field, from which the type is inferred. Type both and choose Preview. The EK9 IDE just before choosing ... |
| Chapter 37: a status decided late, built | Step 2: LateResponse — a class | Choose Code > New Construct > Class… The EK9 IDE once this is done: Choose Code > New Construct > Class… LateResponse is the class's name. It is a response that can change its mind: its status is read after its content is made. Choose Preview. The EK9 IDE just before choosing Preview: ... |
| Chapter 37: a status decided late, built | Step 3: Late — a service | Choose Code > New Construct > Service… The EK9 IDE once this is done: Choose Code > New Construct > Service… Late is the service's name and /late the base URI every route sits under. One route, with no path variable. The Routes table holds check, GET /. Choose Preview. The EK9 IDE just before ... |
| Chapter 37: a status decided late, built | Step 4: LateApp — an application | Choose Code > New Construct > Application… The EK9 IDE once this is done: Choose Code > New Construct > Application… LateApp is the application's name. It registers the service. The Registrations table holds Late. Choose Preview. The EK9 IDE just before choosing Preview: LateApp is the ... |
| Chapter 37: a status decided late, built | Step 5: ServeLate — a program | Choose Code > New Construct > Program… The EK9 IDE once this is done: Choose Code > New Construct > Program… ServeLate is the program's name. Leave Application empty - a later step says why. Choose Preview. The EK9 IDE just before choosing Preview: ServeLate is the program's name The preview ... |
| Chapter 37: a status decided late, built | The result | LateStatus.ek9 now reads exactly as chapter 37 of EK9 in Depth shows it. The response answers 200 until its content is made, and the content makes it 404 - the status is read afterwards. Built, not run: the program serves until sent TERM. |
| Chapter 37: a status decided late, built | Where this lesson comes from | For AI assistants - the MCP tool ek9_new_construct, ek9_adopt_trait, ek9_add_field, ek9_add_method, ek9_add_application, ek9_add_program. |
| Chapter 38: a package to share, built and packaged | Chapter 38: a package to share, built and packaged | Chapter 38 ships a small package: four greeting functions, a thin program, and the block that makes it publishable. In Maven, Cargo or npm, publishing is another tool with its own manifest; here the manifest is a block in the source, and packaging is the compiler you already run - which refuses ... |
| Chapter 38: a package to share, built and packaged | Step 1: greeting — a pure function | Choose Code > New Construct > Function… The EK9 IDE once this is done: Choose Code > New Construct > Function… greeting is the function's name. Add one parameter, name of type String, set Returns to String and tick pure. Choose Preview. The EK9 IDE just before choosing Preview: greeting is the ... |
| Chapter 38: a package to share, built and packaged | Step 2: farewell — a pure function | Choose Code > New Construct > Function… The EK9 IDE once this is done: Choose Code > New Construct > Function… farewell is the function's name. Add one parameter, name of type String, set Returns to String and tick pure. Choose Preview. The EK9 IDE just before choosing Preview: farewell is the ... |
| Chapter 38: a package to share, built and packaged | Step 3: shouted — a pure function | Choose Code > New Construct > Function… The EK9 IDE once this is done: Choose Code > New Construct > Function… shouted is the function's name. Add one parameter, text of type String, set Returns to String and tick pure. Choose Preview. The EK9 IDE just before choosing Preview: shouted is the ... |
| Chapter 38: a package to share, built and packaged | Step 4: whispered — a pure function | Choose Code > New Construct > Function… The EK9 IDE once this is done: Choose Code > New Construct > Function… whispered is the function's name. Add one parameter, text of type String, set Returns to String and tick pure. Choose Preview. The EK9 IDE just before choosing Preview: whispered is the ... |
| Chapter 38: a package to share, built and packaged | Step 5: The program | Choose Code > New Construct > Program… The EK9 IDE once this is done: Choose Code > New Construct > Program… Greet is the program's name. Add one parameter, name of type String. Choose Preview. The EK9 IDE just before choosing Preview: Greet is the program's name The preview shows Greet about to ... |
| Chapter 38: a package to share, built and packaged | Step 6: Run it | Choose Run > Run Program… The EK9 IDE once this is done: Choose Run > Run Program… Type Ada into Arguments (space-separated), then choose Run. The EK9 IDE just before choosing Run: Type Ada into Arguments (space-separated), then choose Run Hello, Ada Choose Close. The EK9 IDE just before choosing ... |
| Chapter 38: a package to share, built and packaged | Step 7: The manifest — defines package | Where Maven keeps a pom.xml and npm a package.json, EK9 keeps the manifest in the source: a defines package block at the end of the module, the version in it a native Version literal, no second file to disagree with it. Select the last line of the code and, after it, type the block. Saves when ... |
| Chapter 38: a package to share, built and packaged | Step 8: The tests' file | Open greeter/dev/greeterTests.ek9 - already there, with just its own module line. Packaging refuses a project whose tests fail or cover less than 80%, so they come before the package. The EK9 IDE once this is done: Open greeter/dev/greeterTests.ek9 - already there, with just its own module line ... |
| Chapter 38: a package to share, built and packaged | Step 9: GreetingTest | Choose Code > New Construct > Test… The EK9 IDE once this is done: Choose Code > New Construct > Test… GreetingTest is the test's name. Choose Preview. The EK9 IDE just before choosing Preview: GreetingTest is the test's name The preview shows GreetingTest about to be written, marked @Test, with ... |
| Chapter 38: a package to share, built and packaged | Step 10: FarewellTest | Choose Code > New Construct > Test… The EK9 IDE once this is done: Choose Code > New Construct > Test… FarewellTest is the test's name. Choose Preview. The EK9 IDE just before choosing Preview: FarewellTest is the test's name The preview shows FarewellTest about to be written, marked @Test, with ... |
| Chapter 38: a package to share, built and packaged | Step 11: ShoutedTest | Choose Code > New Construct > Test… The EK9 IDE once this is done: Choose Code > New Construct > Test… ShoutedTest is the test's name. Choose Preview. The EK9 IDE just before choosing Preview: ShoutedTest is the test's name The preview shows ShoutedTest about to be written, marked @Test, with a ... |
| Chapter 38: a package to share, built and packaged | Step 12: WhisperedTest | Choose Code > New Construct > Test… The EK9 IDE once this is done: Choose Code > New Construct > Test… WhisperedTest is the test's name. Choose Preview. The EK9 IDE just before choosing Preview: WhisperedTest is the test's name The preview shows WhisperedTest about to be written, marked @Test, ... |
| Chapter 38: a package to share, built and packaged | Step 13: Run the tests | Run ▸ Run Tests (⌘T) runs every @Test in the project - the same tests -P will run before it packages anything. All four tests pass - together they cover the functions, which is what the 80% gate wants. Choose Run Tests. The EK9 IDE once this is done: Run ▸ Run Tests (⌘T) runs every @Test in the ... |
| Chapter 38: a package to share, built and packaged | Step 14: Package | Choose Build ▸ Package…. The EK9 IDE once this is done: Choose Build ▸ Package… The report says Success, with nothing more to say: packaging compiled the module, ran the four tests, checked the coverage and wrote the zip and its checksum into the package folder's .ek9 folder. Choose Close. |
| Chapter 38: a package to share, built and packaged | Step 15: Install | Choose Build ▸ Install Package. The EK9 IDE once this is done: Choose Build ▸ Install Package Install copied the archive into the library, depth-package-greeter-home/.ek9/lib here - ~/.ek9/lib for you outside this lesson - where another project's deps entry would find it. Choose Close. |
| Chapter 38: a package to share, built and packaged | The result | main.ek9 and dev/greeterTests.ek9 now read exactly as chapter 38 of EK9 in Depth shows them, and the package is built: an archive of the SOURCE (main.ek9, the tests in dev/ and a properties file the compiler made) and a .sha256 beside it, installed into a library of this lesson's own, never your ... |
| Chapter 38: a package to share, built and packaged | Where this lesson comes from | For AI assistants - the MCP tool ek9_new_construct, ek9_add_program, ek9_package, ek9_install_package. |
| Chapter 38: declaring what a package may do, built | Chapter 38: declaring what a package may do, built | A package other people will build on is, for them, a supply-chain risk: any package can open a socket or read an environment variable, and nothing in npm, Cargo or Maven makes it say so. Here a small program reads a name from the environment and greets it. The IDE writes the program's shell; you ... |
| Chapter 38: declaring what a package may do, built | Step 1: The program | Choose Code > New Construct > Program… The EK9 IDE once this is done: Choose Code > New Construct > Program… EnvironmentGreeter is the program's name. Choose Preview. The EK9 IDE just before choosing Preview: EnvironmentGreeter is the program's name The preview shows EnvironmentGreeter about to ... |
| Chapter 38: declaring what a package may do, built | Step 2: The manifest, with a capability missing | After the last line of the program, type the package block. It declares what the package may touch - and lists Stdout only, which is true of the first line of the program and not of the second. Saves when typed. The EK9 IDE once this is done: After the last line of the program, type the package ... |
| Chapter 38: declaring what a package may do, built | Step 3: Declare what the code uses | Right-click the EnvVars() call, where the error is, and choose Add capability 'EnvVars' to package. The same fix is in the package block's own Add Capability… item. The EK9 IDE once this is done: Right-click the EnvVars() call, where the error is, and choose Add capability 'EnvVars' to package ... |
| Chapter 38: declaring what a package may do, built | Step 4: Run it, the variable unset | Choose Run > Run Program… The EK9 IDE once this is done: Choose Run > Run Program… The project's only program is already chosen. Choose Run. With the variable unset the guard finds nothing: nobody to greet. Choose Close. The EK9 IDE just before choosing Close: With the variable unset the guard ... |
| Chapter 38: declaring what a package may do, built | Step 5: Run it, the variable set | Choose Run > Configurations… The EK9 IDE once this is done: Choose Run > Configurations… Choose + New Configuration… - the project's program is already the one it will belong to. Name it Greet Ada, and into Environment type EK9_BOOK_GREETEE=Ada - the one field with anywhere to put it. Choose ... |
| Chapter 38: declaring what a package may do, built | The result | EnvironmentGreeter.ek9 now reads exactly as chapter 38 of EK9 in Depth shows it, and its package block is an honest statement of what the package does: Stdout and EnvVars. npm, Cargo and Maven do not ask a package to declare that it reads the environment or opens a socket; EK9's publishable ... |
| Chapter 38: declaring what a package may do, built | Where this lesson comes from | For AI assistants - the MCP tool ek9_add_program, ek9_add_capability. |
| Chapter 38: a library to depend on, built and installed | Chapter 38: a library to depend on, built and installed | The chapter's consumer needs a library to depend on, and a dependency can only come from a library on your own disk today, so it must be installed first. This one is tiny - a constant and two area functions - and its package block lists nothing it needs to declare: no program, no gated type, so ... |
| Chapter 38: a library to depend on, built and installed | Step 1: A constant | Choose Code > New Construct > Constant… The EK9 IDE once this is done: Choose Code > New Construct > Constant… CIRCLE_CONSTANT is the constant's name and 3.14159 its value - a literal in the Value field, from which the type is inferred. Type both and choose Preview. The EK9 IDE just before ... |
| Chapter 38: a library to depend on, built and installed | Step 2: circleArea — a pure function | Choose Code > New Construct > Function… The EK9 IDE once this is done: Choose Code > New Construct > Function… circleArea is the function's name. Add one parameter, radius of type Float, set Returns to Float and tick pure. Choose Preview. The EK9 IDE just before choosing Preview: circleArea is ... |
| Chapter 38: a library to depend on, built and installed | Step 3: squareArea — a pure function | Choose Code > New Construct > Function… The EK9 IDE once this is done: Choose Code > New Construct > Function… squareArea is the function's name. Add one parameter, side of type Float, set Returns to Float and tick pure. Choose Preview. The EK9 IDE just before choosing Preview: squareArea is the ... |
| Chapter 38: a library to depend on, built and installed | Step 4: The manifest — defines package | Where Maven keeps a pom.xml and npm a package.json, EK9 keeps the manifest in the source: a defines package block at the end of the module, the version in it a native Version literal, no second file to disagree with it. Select the last line of the code and, after it, type the block. Saves when ... |
| Chapter 38: a library to depend on, built and installed | Step 5: The tests' file | Open shapes/dev/shapesTests.ek9 - already there, with just its own module line. Packaging refuses a project whose tests fail or cover less than 80%, so they come before the package. The EK9 IDE once this is done: Open shapes/dev/shapesTests.ek9 - already there, with just its own module line ... |
| Chapter 38: a library to depend on, built and installed | Step 6: CircleAreaTest | Choose Code > New Construct > Test… The EK9 IDE once this is done: Choose Code > New Construct > Test… CircleAreaTest is the test's name. Choose Preview. The EK9 IDE just before choosing Preview: CircleAreaTest is the test's name The preview shows CircleAreaTest about to be written, marked @Test, ... |
| Chapter 38: a library to depend on, built and installed | Step 7: SquareAreaTest | Choose Code > New Construct > Test… The EK9 IDE once this is done: Choose Code > New Construct > Test… SquareAreaTest is the test's name. Choose Preview. The EK9 IDE just before choosing Preview: SquareAreaTest is the test's name The preview shows SquareAreaTest about to be written, marked @Test, ... |
| Chapter 38: a library to depend on, built and installed | Step 8: Run the tests | Run ▸ Run Tests (⌘T) runs every @Test in the project - the same tests -P will run before it packages anything. Both tests pass. Choose Run Tests. The EK9 IDE once this is done: Run ▸ Run Tests (⌘T) runs every @Test in the project - the same tests -P will run before it packages anything |
| Chapter 38: a library to depend on, built and installed | Step 9: Package | Choose Build ▸ Package…. The EK9 IDE once this is done: Choose Build ▸ Package… The report says Success, with nothing more to say: the module compiled, its two tests passed and the archive and checksum were written. Choose Close. |
| Chapter 38: a library to depend on, built and installed | Step 10: Install | Choose Build ▸ Install Package. The EK9 IDE once this is done: Choose Build ▸ Install Package Install copied the archive into the library, depth-package-shapes-home/.ek9/lib here - ~/.ek9/lib for you outside this lesson - where another project's deps entry would find it. Choose Close. |
| Chapter 38: a library to depend on, built and installed | The result | shapes.ek9 and dev/shapesTests.ek9 now read exactly as chapter 38 of EK9 in Depth shows them, and book.shapes.lib-1.0.0-0 sits in the lesson's own library. A consumer would name it in a deps entry and the resolver would find the archive there, compiling its source with the consumer's. Your own ... |
| Chapter 38: a library to depend on, built and installed | Where this lesson comes from | For AI assistants - the MCP tool ek9_new_construct, ek9_add_program, ek9_package, ek9_install_package. |
| Chapter 39: three kinds of test, one runner, built | Chapter 39: three kinds of test, one runner, built | A green suite can be hollow: a test that asserts nothing passes, an assertion in a helper no test calls never runs, and coverage is a plugin someone must remember to configure. The EK9 runner is part of the compiler, and it refuses to call such a suite green. Here the pricing and checkout module ... |
| Chapter 39: three kinds of test, one runner, built | Step 1: The program under test | Shop.ek9 prints two receipts, kettle: 2000p and mug: 400p. Notice discounted, which throws an Exception when the percentage is over a hundred, bulkPrice, and OrderService, which is handed a Notifier. A test is a program marked @Test in a file under dev/, and the runner recognises three kinds: ... |
| Chapter 39: three kinds of test, one runner, built | Step 2: Assertion tests — discounted | Open dev/ShopUnitTests.ek9 - it holds only its module line. This is the first kind: an assertion test states what must be true. assert is for tests as require is for production code. The EK9 IDE once this is done: Open dev/ShopUnitTests.ek9 - it holds only its module line Select the module line, ... |
| Chapter 39: three kinds of test, one runner, built | Step 3: Assertion tests — bulkPrice and receipt | Choose Code > New Construct > Test… The EK9 IDE once this is done: Choose Code > New Construct > Test… TenItemsGetTwentyPercentOff is the test's name. Choose Preview. The EK9 IDE just before choosing Preview: TenItemsGetTwentyPercentOff is the test's name The preview shows ... |
| Chapter 39: three kinds of test, one runner, built | Step 4: An assertion test with the application | Choose Code > New Construct > Test… The EK9 IDE once this is done: Choose Code > New Construct > Test… EveryPartIsSet is the test's name. A test that needs the application's wiring says so, with application of shopApp. Type shopApp into Application. Choose Preview. The EK9 IDE just before ... |
| Chapter 39: three kinds of test, one runner, built | Step 5: A black-box test, with its own stand-in | Open dev/checkout/CheckoutOutputTest.ek9. The second kind has no assertion: it prints, and the runner compares everything it printed with the expected_output.txt beside it. Where the program talks to the world, here through Notifier, the test brings its own stand-in and an application that ... |
| Chapter 39: three kinds of test, one runner, built | Step 6: A parameterized test | Open dev/receipts/ReceiptTest.ek9. The third kind takes program arguments, and the runner runs it once per case: a commandline_arg_<case>.txt file supplies the arguments, one per line, and expected_case_<case>.txt pins that case's output. The table is files, not a data provider. The EK9 IDE once ... |
| Chapter 39: three kinds of test, one runner, built | Step 7: One runner | Run ▸ Run Tests (⌘T) runs every test in the project, all three kinds together. Choose Run Tests. The EK9 IDE once this is done: Run ▸ Run Tests (⌘T) runs every test in the project, all three kinds together The Tests tab lists them alphabetically, not in source order, each labelled by kind: ... |
| Chapter 39: three kinds of test, one runner, built | The result | The four test files now read exactly as chapter 39 of EK9 in Depth shows them, and the one runner ran all three kinds together: ten assertion tests, two black-box tests whose printed output is compared with expected_output.txt, and one parameterized test run once per case. There is no framework ... |
| Chapter 39: three kinds of test, one runner, built | Where this lesson comes from | For AI assistants - the MCP tool ek9_add_program, ek9_new_construct, ek9_add_application, ek9_run_tests. |
| Chapter 40: what coverage cannot say, built | Chapter 40: what coverage cannot say, built | Chapter 40's closing section asks what coverage cannot say. A small function, postage, has three branches; a first test takes one of them. Coverage gates - the build stops under 80% - but it is easy to meet with tests that ask one easy question, so the quality report joins it to HEX: hazard (how ... |
| Chapter 40: what coverage cannot say, built | Step 1: Constants | Choose Code > New Construct > Constant… The EK9 IDE once this is done: Choose Code > New Construct > Constant… LIGHT_LIMIT is the constant's name and 500 its value - a literal in the Value field, from which the type is inferred. Type both and choose Preview. The EK9 IDE just before choosing ... |
| Chapter 40: what coverage cannot say, built | Step 2: postage — a pure function | Choose Code > New Construct > Function… The EK9 IDE once this is done: Choose Code > New Construct > Function… postage is the function's name. Add the parameters grams of type Integer and express of type Boolean, set Returns to Integer and tick pure. Choose Preview. The EK9 IDE just before ... |
| Chapter 40: what coverage cannot say, built | Step 3: The tests' file | Open postage/dev/tests.ek9 - already there, with just its own module line. The EK9 IDE once this is done: Open postage/dev/tests.ek9 - already there, with just its own module line Select the module line, and below it type a references block bringing in postage. Saves when typed. The EK9 IDE once ... |
| Chapter 40: what coverage cannot say, built | Step 4: One test, and the report | Choose Code > New Construct > Test… The EK9 IDE once this is done: Choose Code > New Construct > Test… LetterByStandardPost is the test's name. Choose Preview. The EK9 IDE just before choosing Preview: LetterByStandardPost is the test's name The preview shows LetterByStandardPost about to be ... |
| Chapter 40: what coverage cannot say, built | Step 5: Five more tests | Choose Code > New Construct > Test… The EK9 IDE once this is done: Choose Code > New Construct > Test… ParcelByStandardPost is the test's name. Choose Preview. The EK9 IDE just before choosing Preview: ParcelByStandardPost is the test's name The preview shows ParcelByStandardPost about to be ... |
| Chapter 40: what coverage cannot say, built | Step 6: The report again | Choose Run > Quality Report again: the six tests take every branch, and a spread of weights - among them zero and a negative one. The EK9 IDE once this is done: Choose Run > Quality Report again Now every line (10 of 10) and every branch (3 of 3) ran, so the gate is satisfied. The entry for ... |
| Chapter 40: what coverage cannot say, built | Step 7: Reading HEX | Three rules from ek9 -h hex keep the score honest. Read the mean and the maximum together: a calm average over one dangerous outlier is the usual misreading. A construct whose parameter is a bare String has no exact input space, so it is counted apart as approximate - tighten the type to measure ... |
| Chapter 40: what coverage cannot say, built | The result | postage.ek9 and dev/tests.ek9 now read exactly as chapter 40 of EK9 in Depth shows them. The same report, twice: after one test the function was untested in two of its three branches and its exposure was high; after six, every branch ran and the exposure fell - but only to the share of the input ... |
| Chapter 40: what coverage cannot say, built | Where this lesson comes from | For AI assistants - the MCP tool ek9_new_construct, ek9_add_program, ek9_run_quality_checks. |
| Chapter 41: substitution, as the compiler checks it, built | Chapter 41: substitution, as the compiler checks it, built | Liskov's rule says a subtype must be usable wherever its parent is. Java leaves that to convention; here the compiler checks it. Shape declares area() as pure and abstract - a promise that asking for an area changes nothing - and two subtypes keep it. The IDE's tools write the classes, the field, ... |
| Chapter 41: substitution, as the compiler checks it, built | Step 1: Shape — pure area(), declared once | Choose Code > New Construct > Class… The EK9 IDE once this is done: Choose Code > New Construct > Class… Shape is the class's name. Shape is a contract. Choose Abstract under Extensibility. Choose Preview. The EK9 IDE just before choosing Preview: Shape is the class's name The preview shows Shape ... |
| Chapter 41: substitution, as the compiler checks it, built | Step 2: Square — a subtype | Choose Code > New Construct > Class… The EK9 IDE once this is done: Choose Code > New Construct > Class… Square is the class's name. Type Shape into Extends. Choose Preview. The EK9 IDE just before choosing Preview: Square is the class's name The preview shows Square extends Shape about to be ... |
| Chapter 41: substitution, as the compiler checks it, built | Step 3: Rectangle — another subtype | Choose Code > New Construct > Class… The EK9 IDE once this is done: Choose Code > New Construct > Class… Rectangle is the class's name. Type Shape into Extends. Choose Preview. The EK9 IDE just before choosing Preview: Rectangle is the class's name The preview shows Rectangle extends Shape about ... |
| Chapter 41: substitution, as the compiler checks it, built | Step 4: describe — a caller that knows no subtype | Choose Code > New Construct > Function… The EK9 IDE once this is done: Choose Code > New Construct > Function… describe is the function's name. Add shape of type Shape, set Returns to String and tick pure. Its parameter is the PARENT type: this is the function that must work for every subtype. ... |
| Chapter 41: substitution, as the compiler checks it, built | Step 5: The program | Choose Code > New Construct > Program… The EK9 IDE once this is done: Choose Code > New Construct > Program… Substitution is the program's name. Choose Preview. The EK9 IDE just before choosing Preview: Substitution is the program's name The preview shows Substitution about to be written. Choose ... |
| Chapter 41: substitution, as the compiler checks it, built | Step 6: Run it | Choose Run > Run Program… The EK9 IDE once this is done: Choose Run > Run Program… The project's only program is already chosen. Choose Run. area 9.0 and area 10.0 - one loop, one call to describe each time, and the right formula runs for each shape without describe ever asking which one it is. ... |
| Chapter 41: substitution, as the compiler checks it, built | The result | Substitution.ek9 now reads exactly as chapter 41 of EK9 in Depth shows it. describe knows nothing of Square or Rectangle, and area() is declared pure on Shape, so a caller can rely on it being a query - and the compiler holds each subtype to that: an override that drops pure is E05150, one that ... |
| Chapter 41: substitution, as the compiler checks it, built | Where this lesson comes from | For AI assistants - the MCP tool ek9_new_construct, ek9_add_method, ek9_add_field, ek9_add_operator, ek9_add_constructor, ek9_add_program. |
| Chapter 41: the tri-state operators, built | Chapter 41: the tri-state operators, built | Chapter 41 argues that EK9 has no null, because a value is absent, present but unset, or present and set, and the program asks about the last two with ?. Two small functions make a set value or an unset one on demand, and three programs use the tri-state operators: :=? assigns only when the ... |
| Chapter 41: the tri-state operators, built | Step 1: Constants | Choose Code > New Construct > Constant… The EK9 IDE once this is done: Choose Code > New Construct > Constant… FALLBACK_NAME is the constant's name and "anon" its value - a literal in the Value field, from which the type is inferred. Type both and choose Preview. The EK9 IDE just before choosing ... |
| Chapter 41: the tri-state operators, built | Step 2: nameOf — a pure function | Choose Code > New Construct > Function… The EK9 IDE once this is done: Choose Code > New Construct > Function… nameOf is the function's name. Add one parameter, known of type Boolean, set Returns to String and tick pure. Choose Preview. The EK9 IDE just before choosing Preview: nameOf is the ... |
| Chapter 41: the tri-state operators, built | Step 3: numberOf — a pure function | Choose Code > New Construct > Function… The EK9 IDE once this is done: Choose Code > New Construct > Function… numberOf is the function's name. Add one parameter, known of type Boolean, set Returns to Integer and tick pure. Choose Preview. The EK9 IDE just before choosing Preview: numberOf is the ... |
| Chapter 41: the tri-state operators, built | Step 4: The program | Choose Code > New Construct > Program… The EK9 IDE once this is done: Choose Code > New Construct > Program… AssignIfUnset is the program's name. Choose Preview. The EK9 IDE just before choosing Preview: AssignIfUnset is the program's name The preview shows AssignIfUnset about to be written. ... |
| Chapter 41: the tri-state operators, built | Step 5: Fallback — another program | Choose Code > New Construct > Program… The EK9 IDE once this is done: Choose Code > New Construct > Program… Fallback is the program's name. Choose Preview. The EK9 IDE just before choosing Preview: Fallback is the program's name The preview shows Fallback about to be written after the program ... |
| Chapter 41: the tri-state operators, built | Step 6: UnsetFlows — another program | Choose Code > New Construct > Program… The EK9 IDE once this is done: Choose Code > New Construct > Program… UnsetFlows is the program's name. Choose Preview. The EK9 IDE just before choosing Preview: UnsetFlows is the program's name The preview shows UnsetFlows about to be written after the ... |
| Chapter 41: the tri-state operators, built | Step 7: Run it | Choose Run > Run Program… The EK9 IDE once this is done: Choose Run > Run Program… Choose AssignIfUnset from the list, then choose Run. a set name stays [Ada], and an unset name becomes [anon]. Choose Close. The EK9 IDE just before choosing Close: a set name stays (Ada), and an unset name becomes ... |
| Chapter 41: the tri-state operators, built | Step 8: Run Fallback | Choose Run > Run Program… The EK9 IDE once this is done: Choose Run > Run Program… Choose Fallback from the list, then choose Run. The EK9 IDE just before choosing Run: Choose Fallback from the list, then choose Run unset or 5 gives 5, set? true; then set or 5 gives 42, set? true. Choose Close. ... |
| Chapter 41: the tri-state operators, built | Step 9: Run UnsetFlows | Choose Run > Run Program… The EK9 IDE once this is done: Choose Run > Run Program… Choose UnsetFlows from the list, then choose Run. The EK9 IDE just before choosing Run: Choose UnsetFlows from the list, then choose Run only two lines: total set? false, and after the unset lines - the ... |
| Chapter 41: the tri-state operators, built | The result | TriState.ek9 now reads exactly as chapter 41 of EK9 in Depth shows it. Three programs, one lesson each: :=? never overwrites a real value, ?: gives its right side only when its left is unset, and the sum with an unset operand is unset - which prints nothing at all, only total? says so. The EK9 ... |
| Chapter 41: the tri-state operators, built | Where this lesson comes from | For AI assistants - the MCP tool ek9_new_construct, ek9_add_program. |
| Appendix: a literal of every type, built | Appendix: a literal of every type, built | The appendix on types shows that EK9 has a literal for nearly every built-in type - a date, a duration, money, a version, a dimension, a regex, even a JSON path - where Java or C# would reach for a constructor or a library. One program writes them all and prints them. The IDE writes the program's ... |
| Appendix: a literal of every type, built | Step 1: The program | Choose Code > New Construct > Program… The EK9 IDE once this is done: Choose Code > New Construct > Program… Literals is the program's name. Choose Preview. The EK9 IDE just before choosing Preview: Literals is the program's name The preview shows Literals about to be written. Choose Apply. The ... |
| Appendix: a literal of every type, built | Step 2: Run it | Choose Run > Run Program… The EK9 IDE once this is done: Choose Run > Run Program… The project's only program is already chosen. Choose Run. eight lines, one per group of literals: for instance the hexadecimal 0x1F printing as 31, the money as 25.99#GBP and the version as 1.2.3-0. Choose Close. ... |
| Appendix: a literal of every type, built | The result | Literals.ek9 now reads exactly as the appendix shows it. Each variable's type was inferred from its literal alone; the only constructor call is Locale("en_GB"), because a locale has no literal, and a bare 1.2.3 would not parse as a version - the build number is part of the literal. The EK9 IDE ... |
| Appendix: a literal of every type, built | Where this lesson comes from | For AI assistants - the MCP tool ek9_add_program. |
| Extract Constant | Extract Constant | Extract Constant gives a literal a name: a constant defined once, and every use of the literal in the file replaced by it. Here 18 in a comparison says nothing about what it means, so EK9 refuses it - E11064, explained in the Hovers panel; a literal used three times or more is refused the same ... |
| Extract Constant | Step 1: Where it is | Put the caret on 18, on line 8. The EK9 IDE once this is done: Put the caret on 18, on line 8 |
| Extract Constant | Step 2: Extract Constant | Right-click it - or choose Refactor > Refactor This… - and choose Extract Constant… The EK9 IDE once this is done: Right-click it - or choose Refactor > Refactor This… - and choose Extract Constant… Name it ADULT_AGE - what 18 stands for - and choose Preview. The EK9 IDE just before choosing ... |
| Extract Constant | Step 3: Preview and apply | The preview shows every change the refactoring makes; then the IDE formats each file it changed. Choose Apply. The EK9 IDE just before choosing Apply: The preview shows every change the refactoring makes; then the IDE formats each file it changed |
| Extract Constant | The result | That is Extract Constant: 18 is ADULT_AGE, defined once in a defines constant block, every use in the file replaced - also the fix for E11065, a literal used three times or more. It is on the right-click menu wherever the caret is on a literal; AI assistants use the ek9_extract_constant tool. The ... |
| Extract Constant | Where this lesson comes from | The errors it fixes - each one's explanation offers this lesson: E11064, E11065.Answers - ek9 -q and the IDE's Answers tab: 317, 638, 1184.For AI assistants - the MCP tool ek9_extract_constant. |
| Rename Symbol | Rename Symbol | Rename Symbol renames a name and every use of it, wherever it is. Here temp says nothing of what it holds, so EK9 refuses it - E11031, explained in the Hovers panel - as it refuses flag, data, value and the others below it. To play it in the IDE: Help > Lessons > Refactoring…, or ek9 -ide -lesson ... |
| Rename Symbol | Step 1: Where it is | Put the caret on temp, on line 8. The EK9 IDE once this is done: Put the caret on temp, on line 8 |
| Rename Symbol | Step 2: Rename Symbol | Choose Refactor > Rename Symbol… The EK9 IDE once this is done: Choose Refactor > Rename Symbol… Type the new name, mainText - what it holds - and choose Preview. The EK9 IDE just before choosing Preview: Type the new name, mainText - what it holds - and choose Preview |
| Rename Symbol | Step 3: Preview and apply | The preview shows every change the refactoring makes; then the IDE formats each file it changed. Choose Apply. The EK9 IDE just before choosing Apply: The preview shows every change the refactoring makes; then the IDE formats each file it changed |
| Rename Symbol | The result | That is Rename Symbol: temp is mainText, at its declaration and its use. The seven names below it are the same refactoring - try one yourself. Shift+F6 opens it; AI assistants use the ek9_rename_symbol tool. The EK9 IDE when the lesson has finished |
| Rename Symbol | Where this lesson comes from | The errors it fixes - each one's explanation offers this lesson: E11031, E11030, E11032.Answers - ek9 -q and the IDE's Answers tab: 291, 297, 922, 1037.For AI assistants - the MCP tool ek9_rename_symbol. |
| Extract Variable | Extract Variable | Extract Variable gives part of an expression a name: a local that holds it, and the expression using the name. Here one expression does too much at once to read, so EK9 refuses it - E11013, explained in the Hovers panel. To play it in the IDE: Help > Lessons > Refactoring…, or ek9 -ide -lesson ... |
| Extract Variable | Step 1: The expression | Select (first ?: second) <? third, on line 12. The EK9 IDE once this is done: Select (first ?: second) <? third, on line 12 |
| Extract Variable | Step 2: Extract Variable | Choose Refactor > Extract Variable… The EK9 IDE once this is done: Choose Refactor > Extract Variable… Name it lower - the lower of the first two and the third - and choose Preview. The EK9 IDE just before choosing Preview: Name it lower - the lower of the first two and the third - and choose ... |
| Extract Variable | Step 3: Preview and apply | The preview shows every change the refactoring makes; then the IDE formats each file it changed. Choose Apply. The EK9 IDE just before choosing Apply: The preview shows every change the refactoring makes; then the IDE formats each file it changed |
| Extract Variable | The result | That is Extract Variable: (first ?: second) <? third is lower, and the expression that did too much reads lower >? fourth - the return's value moved into the body to make room for the local. AI assistants use the ek9_extract_variable tool. The EK9 IDE when the lesson has finished |
| Extract Variable | Where this lesson comes from | The errors it fixes - each one's explanation offers this lesson: E11013, E11069, E11070.Answers - ek9 -q and the IDE's Answers tab: 1302, 1393.For AI assistants - the MCP tool ek9_extract_variable. |
| Change Signature | Change Signature | Change Signature changes a function's parameters - adds, removes or reorders them - and every call to it with them. Here unusedOneOfTwo never uses notUsed, so EK9 refuses it (E08091, explained in the Hovers panel); removing it must take its argument out of the call in describeReady too. To play ... |
| Change Signature | Step 1: Where it is | Put the caret on unusedOneOfTwo, on line 11. The EK9 IDE once this is done: Put the caret on unusedOneOfTwo, on line 11 |
| Change Signature | Step 2: Change Signature | Choose Refactor > Change Signature… The EK9 IDE once this is done: Choose Refactor > Change Signature… Choose notUsed in the parameters, then Remove, then Preview. The EK9 IDE just before choosing Preview: Choose notUsed in the parameters, then Remove, then Preview |
| Change Signature | Step 3: Preview and apply | The preview shows every change the refactoring makes; then the IDE formats each file it changed. Choose Apply. The EK9 IDE just before choosing Apply: The preview shows every change the refactoring makes; then the IDE formats each file it changed |
| Change Signature | The result | That is Change Signature: notUsed is gone from unusedOneOfTwo, and its argument from the call in describeReady. The error left - ignored, in unusedSingleParam - is the same refactoring: try it yourself (nothing calls it, so only its declaration changes). Cmd+F6 opens it (Ctrl+F6 elsewhere); AI ... |
| Change Signature | Where this lesson comes from | The errors it fixes - each one's explanation offers this lesson: E08091.Answers - ek9 -q and the IDE's Answers tab: 319.For AI assistants - the MCP tool ek9_change_signature. |
| Extract Method | Extract Method | Extract Method moves a block of statements into a function of its own, called where the block was. Here seven ifs inside each other are too deep to follow, so EK9 refuses it - E11011, explained in the Hovers panel; moving the inner four into a function of their own brings both under the limit. To ... |
| Extract Method | Step 1: The statements | Select from if mainValue > LEVEL_THREE, on line 19, to the end of the line with stdout.println, line 23. The EK9 IDE once this is done: Select from if mainValue > LEVEL_THREE, on line 19, to the end of the line with stdout.println, line 23 |
| Extract Method | Step 2: Extract Method | Choose Refactor > Extract Method… The EK9 IDE once this is done: Choose Refactor > Extract Method… Name it reportHighLevels - what the block does - and choose Preview. The EK9 IDE just before choosing Preview: Name it reportHighLevels - what the block does - and choose Preview |
| Extract Method | Step 3: Preview and apply | The preview shows every change the refactoring makes; then the IDE formats each file it changed. Choose Apply. The EK9 IDE just before choosing Apply: The preview shows every change the refactoring makes; then the IDE formats each file it changed |
| Extract Method | The result | That is Extract Method: the inner four ifs are reportHighLevels, called where they were, with mainValue and stdout passed in - seven levels became three here and four there. Cmd+Option+M opens it (Ctrl+Alt+M elsewhere); AI assistants use the ek9_extract_method tool. The EK9 IDE when the lesson ... |
| Extract Method | Where this lesson comes from | The errors it fixes - each one's explanation offers this lesson: E11011, E11012, E11021, E11010.Answers - ek9 -q and the IDE's Answers tab: 814, 1020.For AI assistants - the MCP tool ek9_extract_method. |
| Safe Delete | Safe Delete | Safe Delete removes a class, a function, a method or a field once it has checked that nothing uses it. Here Derived's doWork repeats Base's word for word, so EK9 refuses it - E11044, explained in the Hovers panel; Derived has doWork from Base without it. To play it in the IDE: Help > Lessons > ... |
| Safe Delete | Step 1: Where it is | Put the caret on doWork, on line 11. The EK9 IDE once this is done: Put the caret on doWork, on line 11 |
| Safe Delete | Step 2: Safe Delete | Choose Refactor > Safe Delete… The EK9 IDE once this is done: Choose Refactor > Safe Delete… |
| Safe Delete | Step 3: Preview and apply | The preview shows every change the refactoring makes; then the IDE formats each file it changed. Choose Apply. |
| Safe Delete | The result | That is Safe Delete: Derived's doWork is gone, and Derived has Base's. Had anything still used what you deleted, the preview would have listed each place instead of offering Apply. It is on the right-click menu wherever the caret is on a declaration, and is Delete safely… on each entry of the ... |
| Safe Delete | Where this lesson comes from | The errors it fixes - each one's explanation offers this lesson: E11044.Answers - ek9 -q and the IDE's Answers tab: 801.For AI assistants - the MCP tool ek9_safe_delete. |
| Unused Code | Unused Code | The Unused Code window finds every callable the workspace never reaches, from any program, service or test. Here tidy.ek9 declares two functions: greeting, which the Greet program calls, and forgottenHelper, which nothing calls at all. To play it in the IDE: Help > Lessons > Refactoring…, or ek9 ... |
| Unused Code | Step 1: Open the window | Choose View > Tool Windows > Unused Code. The EK9 IDE once this is done: Choose View > Tool Windows > Unused Code |
| Unused Code | Step 2: The findings | forgottenHelper is listed under 🗑 Dead - reached by nothing, so it is safe to remove. greeting is not listed at all: the Greet program calls it, so it is live. |
| Unused Code | Step 3: Delete it safely | Right-click forgottenHelper and choose Delete safely… The EK9 IDE once this is done: Right-click forgottenHelper and choose Delete safely… |
| Unused Code | Step 4: Preview and apply | The preview shows forgottenHelper's declaration gone, with nothing else to change - nothing else used it. Choose Apply. |
| Unused Code | The result | That is the Unused Code window: forgottenHelper is gone - nothing called it, in production or test code - and greeting, which the program does call, was never listed at all. Delete safely… on a finding reaches the SAME preview as Safe Delete from a declaration's own right-click menu, so a finding ... |
| Unused Code | Where this lesson comes from | For AI assistants - the MCP tool ek9_find_unused_code, ek9_safe_delete. |
| Organize Constants | Organize Constants | Organize Constants gathers every constant of a module into one file, so its fixed values are found in one place. Here three files of one module each define constants of their own, so EK9 refuses it - E11066, explained in the Hovers panel; ten or more constants across two files are refused the ... |
| Organize Constants | Step 1: Where it is | Put the caret on MAX_RETRIES, on line 5. The EK9 IDE once this is done: Put the caret on MAX_RETRIES, on line 5 |
| Organize Constants | Step 2: Organize Constants | Choose Refactor > Organize Constants… The EK9 IDE once this is done: Choose Refactor > Organize Constants… Choose new file, name it constants.ek9 - a file of the module's own for its constants - and choose Preview. The EK9 IDE just before choosing Preview: Choose new file, name it constants.ek9 - ... |
| Organize Constants | Step 3: Preview and apply | The preview shows every change the refactoring makes; then the IDE formats each file it changed. Choose Apply. The EK9 IDE just before choosing Apply: The preview shows every change the refactoring makes; then the IDE formats each file it changed |
| Organize Constants | The result | That is Organize Constants: the six constants are one block in constants.ek9, and the three files they came from hold only their module line - delete them, or keep them for what comes next. Which file a constant is in makes no difference to the code that uses it. AI assistants use the ... |
| Organize Constants | Where this lesson comes from | The errors it fixes - each one's explanation offers this lesson: E11066, E11067.Answers - ek9 -q and the IDE's Answers tab: 863, 1341.For AI assistants - the MCP tool ek9_organize_constants. |
| Organize References | Organize References | Organize References deletes the unused entries of one file's references block - usage judged by a scratch compile, so it is never fooled by a name collision. Here workshop.ek9 references both polish and sharpen from toolbox.ek9, but only ever calls sharpen. To play it in the IDE: Help > Lessons > ... |
| Organize References | Step 1: Where it is | Put the caret on polish, on line 5. The EK9 IDE once this is done: Put the caret on polish, on line 5 |
| Organize References | Step 2: Organize References | Right-click it - or choose Refactor > Refactor This… - and choose Organize References. The EK9 IDE once this is done: Right-click it - or choose Refactor > Refactor This… - and choose Organize References |
| Organize References | Step 3: Preview and apply | The preview shows every change the refactoring makes; then the IDE formats each file it changed. Choose Apply. |
| Organize References | The result | That is Organize References: polish is gone from the references block, and sharpen - the one it actually calls - is untouched. Which functions a file references makes no difference to how fast it runs; it is about the block reading true. It is on the Code menu and the right-click menu whenever ... |
| Organize References | Where this lesson comes from | For AI assistants - the MCP tool ek9_organize_references. |
| Sync References | Sync References | Sync References does what Organize References does - delete unused entries - and also adds the entry for any cross-module symbol the file uses but has not declared, in one pass. Here garden.ek9 references both prune and water from shed.ek9, but only ever calls water. To play it in the IDE: Help > ... |
| Sync References | Step 1: Where it is | Put the caret on prune, on line 5. The EK9 IDE once this is done: Put the caret on prune, on line 5 |
| Sync References | Step 2: Sync References | Right-click it - or choose Refactor > Refactor This… - and choose Sync References. The EK9 IDE once this is done: Right-click it - or choose Refactor > Refactor This… - and choose Sync References |
| Sync References | Step 3: Preview and apply | The preview shows every change the refactoring makes; then the IDE formats each file it changed. Choose Apply. |
| Sync References | The result | That is Sync References: prune is gone from the references block, and water is untouched - the same result Organize References gives here, because nothing was missing to add. On a file that calls a symbol it has not yet referenced, Sync adds the module::Name entry instead of leaving the error; ... |
| Sync References | Where this lesson comes from | For AI assistants - the MCP tool ek9_sync_references. |
| Inline Variable | Inline Variable | Inline Variable puts a local's value where the local is used, and removes the local - the reverse of Extract Variable. Here total is set once and read once, on the very next line: the name says nothing that price * quantity does not. To play it in the IDE: Help > Lessons > Refactoring…, or ek9 ... |
| Inline Variable | Step 1: Where it is | Put the caret on total, on line 12. The EK9 IDE once this is done: Put the caret on total, on line 12 |
| Inline Variable | Step 2: Inline Variable | Choose Refactor > Inline Variable. The EK9 IDE once this is done: Choose Refactor > Inline Variable |
| Inline Variable | Step 3: Preview and apply | The preview shows every change the refactoring makes; then the IDE formats each file it changed. Choose Apply. |
| Inline Variable | The result | That is Inline Variable: total is gone, and rtn takes price * quantity itself. Where inlining would change what the code does - a local assigned again, or a call that would then run twice - the preview says so instead of offering Apply. Cmd+Option+N opens it (Ctrl+Alt+N elsewhere), the Inline ... |
| Inline Variable | Where this lesson comes from | For AI assistants - the MCP tool ek9_inline_variable. |
| Introduce Parameter | Introduce Parameter | Introduce Parameter turns a value a function uses into one its callers pass - and passes the old value at every call, so nothing changes until a caller wants something else. Here discounted always uses STANDARD_RATE; a caller that needs another rate cannot ask for one. To play it in the IDE: Help ... |
| Introduce Parameter | Step 1: The expression | Select STANDARD_RATE, on line 11. The EK9 IDE once this is done: Select STANDARD_RATE, on line 11 |
| Introduce Parameter | Step 2: Introduce Parameter | Choose Refactor > Introduce Parameter… The EK9 IDE once this is done: Choose Refactor > Introduce Parameter… Name it rate - what a caller now chooses - and choose Preview. The EK9 IDE just before choosing Preview: Name it rate - what a caller now chooses - and choose Preview |
| Introduce Parameter | Step 3: Preview and apply | The preview shows every change the refactoring makes; then the IDE formats each file it changed. Choose Apply. The EK9 IDE just before choosing Apply: The preview shows every change the refactoring makes; then the IDE formats each file it changed |
| Introduce Parameter | The result | That is Introduce Parameter: discounted takes rate, and the call in Discounts passes STANDARD_RATE - what it used before, so the program prints the same. Another caller can now pass another rate. At four parameters or more the calls are given named arguments (E11062). Cmd+Option+P opens it ... |
| Introduce Parameter | Where this lesson comes from | For AI assistants - the MCP tool ek9_introduce_parameter. |
| Inline Function | Inline Function | Inline Function puts a function's body in place of every call to it, and removes the function - the reverse of Extract Method. Here welcome does nothing but call greeting: a name between the caller and the work that adds nothing. To play it in the IDE: Help > Lessons > Refactoring…, or ek9 -ide ... |
| Inline Function | Step 1: Where it is | Put the caret on welcome, on line 10. The EK9 IDE once this is done: Put the caret on welcome, on line 10 |
| Inline Function | Step 2: Inline Function | Choose Refactor > Inline Function… The EK9 IDE once this is done: Choose Refactor > Inline Function… |
| Inline Function | Step 3: Preview and apply | The preview shows every change the refactoring makes; then the IDE formats each file it changed. Choose Apply. |
| Inline Function | The result | That is Inline Function: Greeter calls greeting itself, and welcome is gone. Where the function's own locals would clash with names at a call, the preview says which to rename first instead of offering Apply. Cmd+Option+I opens it (Ctrl+Alt+I elsewhere); AI assistants use the ek9_inline_function ... |
| Inline Function | Where this lesson comes from | For AI assistants - the MCP tool ek9_inline_function. |
| Move Construct | Move Construct | Move Construct moves a class, record, trait, component or function to another file - into that file's module, when it is another - and every reference to it follows. Here priceLabel is about money but sits in the shop's module, lesson.shop; money.ek9, in lesson.money, is where it belongs. To play ... |
| Move Construct | Step 1: Where it is | Put the caret on priceLabel, on line 9. The EK9 IDE once this is done: Put the caret on priceLabel, on line 9 |
| Move Construct | Step 2: Move Construct | Choose Refactor > Move Construct… The EK9 IDE once this is done: Choose Refactor > Move Construct… Move to file is money.ek9 - in lesson.money, so the move is cross-module. Choose Preview. |
| Move Construct | Step 3: Preview and apply | The preview shows every change the refactoring makes; then the IDE formats each file it changed. Choose Apply. The EK9 IDE just before choosing Apply: The preview shows every change the refactoring makes; then the IDE formats each file it changed |
| Move Construct | The result | That is Move Construct: priceLabel now lives in money.ek9, in lesson.money, and shop.ek9 references it as lesson.money::priceLabel, beside withVat. A move within one module changes no reference at all. F6 opens it; AI assistants use the ek9_move_construct tool. The EK9 IDE when the lesson has ... |
| Move Construct | Where this lesson comes from | For AI assistants - the MCP tool ek9_move_construct. |
| Lift into Guard | Lift into Guard | Lift into Guard turns a declare-then-check pattern into one guarded head: a variable declared, then immediately tested with '?', becomes the control construct's own guard - entering only when the value is set, the separate check gone. Here greeting is declared, then checked with greeting? before ... |
| Lift into Guard | Step 1: Where it is | Put the caret on greeting?, on line 18. The EK9 IDE once this is done: Put the caret on greeting?, on line 18 |
| Lift into Guard | Step 2: Lift into Guard | Right-click it - or choose Refactor > Refactor This… - and choose Lift into Guard… The EK9 IDE once this is done: Right-click it - or choose Refactor > Refactor This… - and choose Lift into Guard… |
| Lift into Guard | Step 3: Preview and apply | The preview shows every change the refactoring makes; then the IDE formats each file it changed. Choose Apply. |
| Lift into Guard | The result | That is Lift into Guard: greeting <- findGreeting("Steve") and if greeting? become one line, if greeting <- findGreeting("Steve") - the redundant greeting? check subsumed into the guard. It folds switch, try, while, do and for heads the same way, keeping a loop's own condition or iteration as a ... |
| Lift into Guard | Where this lesson comes from | Answers - ek9 -q and the IDE's Answers tab: 971, 1146.For AI assistants - the MCP tool ek9_apply_guard_pattern. |
| Wrap with coalescing | Wrap with coalescing | Wrap with coalescing puts a selected expression on the left of one of EK9's coalescing operators, with what to fall back on on the right: ?: defaults an unset value, <? and >? return the lesser or greater of two operands - the set one when only one is. Here displayName takes name with no default ... |
| Wrap with coalescing | Step 1: The expression | Select name, on line 9. The EK9 IDE once this is done: Select name, on line 9 |
| Wrap with coalescing | Step 2: Wrap with coalescing | Right-click it - or choose Refactor > Refactor This… - and choose Wrap with coalescing… The EK9 IDE once this is done: Right-click it - or choose Refactor > Refactor This… - and choose Wrap with coalescing… Choose ?: - elvis, a default when the left is unset - type "Anonymous" for the right ... |
| Wrap with coalescing | Step 3: Preview and apply | The preview shows every change the refactoring makes; then the IDE formats each file it changed. Choose Apply. The EK9 IDE just before choosing Apply: The preview shows every change the refactoring makes; then the IDE formats each file it changed |
| Wrap with coalescing | The result | That is Wrap with coalescing: displayName is name ?: "Anonymous" - "Anonymous" only when name is unset, name itself otherwise. <? and >? wrap the same way, returning whichever operand is set, or the lesser/greater when both are. It is on the right-click menu whenever a single-line expression is ... |
| Wrap with coalescing | Where this lesson comes from | Answers - ek9 -q and the IDE's Answers tab: 243, 1059, 1067.For AI assistants - the MCP tool ek9_insert_coalescing. |
| Make Open | Make Open | Change Modifier > Make Open adds 'as open' to a closed class, record, component or function, so it can be extended. EK9 types are closed by default - the opposite of most languages - so Shape cannot be extended until it says so; EK9 refuses Circle's attempt to extend it - E05030, explained in the ... |
| Make Open | Step 1: Where it is | Put the caret on Shape, on line 6. The EK9 IDE once this is done: Put the caret on Shape, on line 6 |
| Make Open | Step 2: Make Open | Right-click it - or choose Refactor > Refactor This… - and choose Change Modifier > Make Open. The EK9 IDE once this is done: Right-click it - or choose Refactor > Refactor This… - and choose Change Modifier > Make Open |
| Make Open | Step 3: Preview and apply | The preview shows every change the refactoring makes; then the IDE formats each file it changed. Choose Apply. |
| Make Open | The result | That is Make Open: Shape now says 'as open', so Circle extends it cleanly. Make Closed, Make Abstract and Make Concrete sit beside it in the same right-click Change Modifier submenu - the opposite narrowings. AI assistants use the ek9_make_open tool. The EK9 IDE when the lesson has finished |
| Make Open | Where this lesson comes from | The errors it fixes - each one's explanation offers this lesson: E05030.Answers - ek9 -q and the IDE's Answers tab: 101, 102, 1043.For AI assistants - the MCP tool ek9_make_open. |
| Fix Purity Contract | Fix Purity Contract | Fix Purity Contract adds, or removes, 'as pure' on the callable a purity error names - with the override cascade applied automatically. EK9 purity is about mutation and non-pure calls, not input or output: stdout.println is itself declared pure, so printing is always allowed inside a pure method; ... |
| Fix Purity Contract | Step 1: Where the error is | Put the caret on WordLength, on line 10 - the override the compiler flagged. The EK9 IDE once this is done: Put the caret on WordLength, on line 10 - the override the compiler flagged |
| Fix Purity Contract | Step 2: Blast Radius: the fix it offers | Choose Analyse > Blast Radius. It draws Measure, the contract, in gold, and WordLength under it as fixable, and states the one fix there is - add pure to WordLength - with an Apply button beside it. Press that Apply. The EK9 IDE just before choosing 🔧 Apply — Add pure to WordLength(): Choose ... |
| Fix Purity Contract | Step 3: Preview and apply | The preview shows WordLength gaining 'as pure'; then the IDE formats the file. Choose Apply. The EK9 IDE just before choosing Apply: The preview shows WordLength gaining 'as pure'; then the IDE formats the file |
| Fix Purity Contract | The result | That is Fix Purity Contract: WordLength is now 'as pure', matching what Measure promises. The same picture - the Blast Radius pane draws - is what ek9_query_purity_impact answers read-only; AI assistants call ek9_fix_purity_contract directly, with the diagnostic's file, line and mode. The EK9 IDE ... |
| Fix Purity Contract | Where this lesson comes from | The errors it fixes - each one's explanation offers this lesson: E05150, E05160, E08130.Answers - ek9 -q and the IDE's Answers tab: 560, 561, 562.For AI assistants - the MCP tool ek9_fix_purity_contract. |
| Implement Methods | Implement Methods | Implement Methods adds an override stub for every abstract trait method a class has not yet implemented. Here C6 declares trait T1, which requires tMethod() and operator +; C6 has overridden the operator but not tMethod(), so EK9 refuses it - E07130, explained in the Hovers panel. To play it in ... |
| Implement Methods | Step 1: Where it is | Put the caret on C6, on line 65. The EK9 IDE once this is done: Put the caret on C6, on line 65 |
| Implement Methods | Step 2: Implement Methods | Right-click it - or choose Refactor > Refactor This… - and choose Implement Methods… The EK9 IDE once this is done: Right-click it - or choose Refactor > Refactor This… - and choose Implement Methods… |
| Implement Methods | Step 3: Preview and apply | The preview shows every change the refactoring makes; then the IDE formats each file it changed. Choose Apply. |
| Implement Methods | The result | That is Implement Methods: C6 now has an override stub for tMethod(), so every obligation trait T1 asks of it is met. C5, C7, C8 and C9 are left - this tool batches a trait's METHODS only, so an outstanding operator (Add Operator) or an abstract method inherited from a superclass needs a ... |
| Implement Methods | Where this lesson comes from | The errors it fixes - each one's explanation offers this lesson: E07130.Answers - ek9 -q and the IDE's Answers tab: 103, 108.For AI assistants - the MCP tool ek9_implement_methods. |
| Rewrite String Concatenation | Rewrite String Concatenation | Rewrite String Concatenation turns a + chain of three or more parts into the equivalent backtick interpolation. Here "Hello " + name + "!" is three parts, so EK9 refuses it - E11068, explained in the Hovers panel. To play it in the IDE: Help > Lessons > Refactoring…, or ek9 -ide -lesson ... |
| Rewrite String Concatenation | Step 1: Where it is | Put the caret on Hello, on line 9. The EK9 IDE once this is done: Put the caret on Hello, on line 9 |
| Rewrite String Concatenation | Step 2: Rewrite String Concatenation | Right-click it - or choose Refactor > Refactor This… - and choose Localisation > Rewrite to Backtick Interpolation. The EK9 IDE once this is done: Right-click it - or choose Refactor > Refactor This… - and choose Localisation > Rewrite to Backtick Interpolation |
| Rewrite String Concatenation | Step 3: Preview and apply | The preview shows every change the refactoring makes; then the IDE formats each file it changed. Choose Apply. |
| Rewrite String Concatenation | The result | That is Rewrite String Concatenation: "Hello " + name + "!" is Hello ${name}!, one allocation instead of three. The four- and five-part chains below it are the same refactoring - try one yourself. It is on the right-click menu wherever the caret is inside a + concatenation; AI assistants use the ... |
| Rewrite String Concatenation | Where this lesson comes from | The errors it fixes - each one's explanation offers this lesson: E11068.Answers - ek9 -q and the IDE's Answers tab: 309, 174, 313.For AI assistants - the MCP tool ek9_rewrite_string_concat. |
| Pull Up | Pull Up | Pull Up promotes a method or operator from a subclass into its superclass, where every subclass can use it - with no dialog: the superclass comes from the subclass's 'extends' clause. Here describe() is declared on Circle, but has nothing to do with being a circle - Square, right beside it, could ... |
| Pull Up | Step 1: Where it is | Put the caret on describe, on line 10. The EK9 IDE once this is done: Put the caret on describe, on line 10 |
| Pull Up | Step 2: Pull Up | Right-click it - or choose Refactor > Refactor This… - and choose Pull 'describe' Up to Shape… The EK9 IDE once this is done: Right-click it - or choose Refactor > Refactor This… - and choose Pull 'describe' Up to Shape… |
| Pull Up | Step 3: Preview and apply | The preview shows every change the refactoring makes; then the IDE formats each file it changed. Choose Apply. |
| Pull Up | The result | That is Pull Up: describe() is gone from Circle and lives on Shape itself, so Square could call it too. A member that uses state only the subclass has, or a name already on the superclass, surfaces in the preview instead of a silent wrong move. It is on the right-click menu wherever the caret is ... |
| Pull Up | Where this lesson comes from | For AI assistants - the MCP tool ek9_pull_up. |
| Push Down | Push Down | Push Down relocates a method or operator from a superclass into the subclasses you choose: removed from the superclass, copied into each one picked. Here fly() is declared on Bird, but a Penguin cannot fly - only Eagle should keep it. To play it in the IDE: Help > Lessons > Refactoring…, or ek9 ... |
| Push Down | Step 1: Where it is | Put the caret on fly, on line 8. The EK9 IDE once this is done: Put the caret on fly, on line 8 |
| Push Down | Step 2: Push Down | Right-click it - or choose Refactor > Refactor This… - and choose Push 'fly' Down… The EK9 IDE once this is done: Right-click it - or choose Refactor > Refactor This… - and choose Push 'fly' Down… Tick Eagle only - Penguin stays without fly() - and choose Preview. The EK9 IDE just before choosing ... |
| Push Down | Step 3: Preview and apply | The preview shows every change the refactoring makes; then the IDE formats each file it changed. Choose Apply. The EK9 IDE just before choosing Apply: The preview shows every change the refactoring makes; then the IDE formats each file it changed |
| Push Down | The result | That is Push Down: fly() is gone from Bird and lives on Eagle alone; Penguin has none at all. A caller that reached the member through the superclass type, or a subclass left out that still needed it, surfaces in the preview instead of a silent wrong move. It is on the right-click menu wherever ... |
| Push Down | Where this lesson comes from | For AI assistants - the MCP tool ek9_push_down. |
| Extract Trait | Extract Trait | Extract Trait pulls a class's public methods out into a NEW trait it then implements: the class keeps its bodies, gains 'with trait of' and the new trait's name on its header and 'override' on each extracted method. Here Product's describe() is the kind of thing other things in a catalogue could ... |
| Extract Trait | Step 1: Where it is | Put the caret on Product, on line 6. The EK9 IDE once this is done: Put the caret on Product, on line 6 |
| Extract Trait | Step 2: Extract Trait | Right-click it - or choose Refactor > Refactor This… - and choose Extract Trait… The EK9 IDE once this is done: Right-click it - or choose Refactor > Refactor This… - and choose Extract Trait… Name it Describable - what describe() promises - and choose Preview. The EK9 IDE just before choosing ... |
| Extract Trait | Step 3: Preview and apply | The preview shows every change the refactoring makes; then the IDE formats each file it changed. Choose Apply. The EK9 IDE just before choosing Apply: The preview shows every change the refactoring makes; then the IDE formats each file it changed |
| Extract Trait | The result | That is Extract Trait: Product now implements Describable, describe() is overridden, and the trait declares describe() as abstract for anything else that adopts it. A name already used in the file, or a method that is private, protected or an operator, surfaces as a conflict instead of an error ... |
| Extract Trait | Where this lesson comes from | For AI assistants - the MCP tool ek9_extract_trait. |
| Adopt Trait | Adopt Trait | Adopt Trait adds 'with trait of' and a trait's name to a class or component's declaration and, implementing, an override stub for every one of the trait's abstract methods - or, delegating, forwards them all to an existing field instead. Here Greeter declares one abstract method, greet(); Robot ... |
| Adopt Trait | Step 1: Right-click Robot | Right-click the Robot line and choose Adopt Trait… The EK9 IDE once this is done: Right-click the Robot line and choose Adopt Trait… |
| Adopt Trait | Step 2: Name the trait, and OK | Greeter is the trait - Implement method stubs is already chosen, the other way being to delegate to a field. Type Greeter and choose OK. The EK9 IDE just before choosing OK: Greeter is the trait - Implement method stubs is already chosen, the other way being to delegate to a field Adopt Trait ... |
| Adopt Trait | The result | That is Adopt Trait: Robot now says 'with trait of Greeter', and carries an override stub for greet() - the trait's one abstract method - with a //AI: Implement greet lead where the body goes. Delegate to a field instead and the compiler forwards every trait method for you, with no stub to fill ... |
| Adopt Trait | Where this lesson comes from | Answers - ek9 -q and the IDE's Answers tab: 108, 210.For AI assistants - the MCP tool ek9_adopt_trait. |
| Make Abstract | Make Abstract | Change Modifier > Make Abstract adds 'as abstract' to a class, record, component or function directly - an alternative to implementing every outstanding member. Here C7 extends C1, which is abstract, but implements neither of C1's abstract members, so EK9 refuses it - E07130, explained in the ... |
| Make Abstract | Step 1: Where it is | Put the caret on C7, on line 73. The EK9 IDE once this is done: Put the caret on C7, on line 73 |
| Make Abstract | Step 2: Make Abstract | Right-click it - or choose Refactor > Refactor This… - and choose Change Modifier > Make Abstract. The EK9 IDE once this is done: Right-click it - or choose Refactor > Refactor This… - and choose Change Modifier > Make Abstract |
| Make Abstract | Step 3: Preview and apply | The preview shows every change the refactoring makes; then the IDE formats each file it changed. Choose Apply. |
| Make Abstract | The result | That is Make Abstract: C7 now says 'as abstract', so it compiles without implementing C1's members itself - whatever extends C7 still owes them. C5, C8 and C9 are left, fixable the same way or by implementing the missing members (Implement Methods…, which fixes C6 the same error asks for); Make ... |
| Make Abstract | Where this lesson comes from | The errors it fixes - each one's explanation offers this lesson: E07130.Answers - ek9 -q and the IDE's Answers tab: 103.For AI assistants - the MCP tool ek9_make_abstract. |
| Make Closed | Make Closed | Change Modifier > Make Closed removes 'as open' from a class, record, component or function, returning it to EK9's closed-by-default. Here Shape says 'as open' but nothing extends it - an openness nobody uses. To play it in the IDE: Help > Lessons > Refactoring…, or ek9 -ide -lesson make-closed. ... |
| Make Closed | Step 1: Where it is | Put the caret on Shape, on line 6. The EK9 IDE once this is done: Put the caret on Shape, on line 6 |
| Make Closed | Step 2: Make Closed | Right-click it - or choose Refactor > Refactor This… - and choose Change Modifier > Make Closed. The EK9 IDE once this is done: Right-click it - or choose Refactor > Refactor This… - and choose Change Modifier > Make Closed |
| Make Closed | Step 3: Preview and apply | The preview shows every change the refactoring makes; then the IDE formats each file it changed. Choose Apply. |
| Make Closed | The result | That is Make Closed: Shape no longer says 'as open', so it is closed again - exactly where every EK9 type starts. Had anything already extended it, the preview would have listed each subtype instead of offering Apply. Make Open reverses it; Make Abstract and Make Concrete sit beside it in the ... |
| Make Closed | Where this lesson comes from | Answers - ek9 -q and the IDE's Answers tab: 574, 784.For AI assistants - the MCP tool ek9_make_closed. |
| Make Concrete | Make Concrete | Change Modifier > Make Concrete removes 'as abstract' from a class, record, component or function whose abstract members are all implemented, so it can be instantiated directly - keeping 'as open' unless told otherwise. Here Shape says 'as abstract' but has no abstract member at all: describe() ... |
| Make Concrete | Step 1: Where it is | Put the caret on Shape, on line 6. The EK9 IDE once this is done: Put the caret on Shape, on line 6 |
| Make Concrete | Step 2: Make Concrete | Right-click it - or choose Refactor > Refactor This… - and choose Change Modifier > Make Concrete. The EK9 IDE once this is done: Right-click it - or choose Refactor > Refactor This… - and choose Change Modifier > Make Concrete |
| Make Concrete | Step 3: Preview and apply | The preview shows every change the refactoring makes; then the IDE formats each file it changed. Choose Apply. |
| Make Concrete | The result | That is Make Concrete: Shape now says 'as open' instead of 'as abstract' - Circle still extends it, and Shape itself can now be constructed too. Had an abstract member remained, the preview would have listed it instead of offering Apply. Make Abstract reverses it; Make Open and Make Closed sit ... |
| Make Concrete | Where this lesson comes from | For AI assistants - the MCP tool ek9_make_concrete. |
| Seal Type | Seal Type | Change Modifier > Seal Type adds an 'allow only A, B, C' clause to a class or trait, restricting extension to exactly the subtypes listed - the compiler then knows the hierarchy is complete, so a switch over it can be exhaustive. Here Shape is open to anything; Circle and Square are its only two ... |
| Seal Type | Step 1: Where it is | Put the caret on Shape, on line 6. The EK9 IDE once this is done: Put the caret on Shape, on line 6 |
| Seal Type | Step 2: Seal Type | Right-click it - or choose Refactor > Refactor This… - and choose Change Modifier > Seal Type… The EK9 IDE once this is done: Right-click it - or choose Refactor > Refactor This… - and choose Change Modifier > Seal Type… Circle and Square are already ticked - every existing subtype must stay ... |
| Seal Type | Step 3: Preview and apply | The preview shows every change the refactoring makes; then the IDE formats each file it changed. Choose Apply. The EK9 IDE just before choosing Apply: The preview shows every change the refactoring makes; then the IDE formats each file it changed |
| Seal Type | The result | That is Seal Type: Shape now reads 'allow only Circle, Square as open' - only those two may extend it, and a third attempt is refused (E05240) until it is added to the list. Unseal Type removes the clause again; Add to Allowlist… adds one more name without starting over - both sit beside it in ... |
| Seal Type | Where this lesson comes from | Answers - ek9 -q and the IDE's Answers tab: 1171, 301, 608.For AI assistants - the MCP tool ek9_seal_type. |
| Unseal Type / Add to Allowlist | Unseal Type / Add to Allowlist | Add to Allowlist widens an existing 'allow only' list without starting over; Unseal Type removes the restriction entirely. Here SealedTrait's 'allow only AllowedClass1, AllowedClass2' refuses AddedLater and AlsoAddedLater - each its own E05240, explained in the Hovers panel - and a dynamic class, ... |
| Unseal Type / Add to Allowlist | Step 1: Add to Allowlist | Right-click the AddedLater line and choose Add to 'SealedTrait' allow only list… The EK9 IDE once this is done: Right-click the AddedLater line and choose Add to 'SealedTrait' allow only list… AddedLater and AlsoAddedLater are already ticked - every unlisted subtype of SealedTrait, so one edit ... |
| Unseal Type / Add to Allowlist | Step 2: Preview and apply | The preview shows both names added to SealedTrait's allow only list; then the IDE formats the file. Choose Apply. The EK9 IDE just before choosing Apply: The preview shows both names added to SealedTrait's allow only list; then the IDE formats the file |
| Unseal Type / Add to Allowlist | Step 3: Unseal Type | Right-click the SealedTrait line and choose Change Modifier > Unseal Type The EK9 IDE once this is done: Right-click the SealedTrait line and choose Change Modifier > Unseal Type |
| Unseal Type / Add to Allowlist | Step 4: Preview and apply | The preview shows the allow only clause removed entirely; then the IDE formats the file. Choose Apply. |
| Unseal Type / Add to Allowlist | The result | That is Add to Allowlist and Unseal Type: AddedLater and AlsoAddedLater are both in SealedTrait's allow only list - one edit admitted both, since each was its own E05240 - and the dynamic class's error, which no allowlist edit could ever fix, is gone only once SealedTrait is unsealed entirely. ... |
| Unseal Type / Add to Allowlist | Where this lesson comes from | The errors it fixes - each one's explanation offers this lesson: E05240.Answers - ek9 -q and the IDE's Answers tab: 301, 608, 303.For AI assistants - the MCP tool ek9_add_to_sealed_allowlist, ek9_unseal_type. |
| Introduce Field | Introduce Field | Introduce Field lifts a local and its initialiser up to a field of the enclosing class, record or component, keeping the same name - the field-level sibling of Introduce Parameter: Introduce Parameter turns a value a function uses into one its CALLERS pass; Introduce Field turns a value a METHOD ... |
| Introduce Field | Step 1: Where it is | Put the caret on balance, on line 7. The EK9 IDE once this is done: Put the caret on balance, on line 7 |
| Introduce Field | Step 2: Introduce Field | Right-click it - or choose Refactor > Refactor This… - and choose Introduce Field… The EK9 IDE once this is done: Right-click it - or choose Refactor > Refactor This… - and choose Introduce Field… |
| Introduce Field | Step 3: Preview and apply | The preview shows every change the refactoring makes; then the IDE formats each file it changed. Choose Apply. |
| Introduce Field | The result | That is Introduce Field: balance is now a field of Account, set once when the object is created and shared by every method after it - today just show(). Because this is Account's first field, the tool also appends default operator ? (EK9's tri-state requirement, E07235) so the result compiles in ... |
| Introduce Field | Where this lesson comes from | For AI assistants - the MCP tool ek9_introduce_field. |
| Rename Field | Rename Field | Rename Field renames a field and every reference to it inside its owning construct - the construct-scoped sibling of Rename Symbol, which reaches across the whole workspace. EK9 fields are private to their declaring construct, so a field's rename never needs to look beyond the one file that ... |
| Rename Field | Step 1: Where it is | Put the caret on farewell, on line 6. The EK9 IDE once this is done: Put the caret on farewell, on line 6 |
| Rename Field | Step 2: Rename Field | Right-click it - or choose Refactor > Refactor This… - and choose Rename Field… The EK9 IDE once this is done: Right-click it - or choose Refactor > Refactor This… - and choose Rename Field… Name it signoff - the word the rest of the project uses for this - and choose Preview. The EK9 IDE just ... |
| Rename Field | Step 3: Preview and apply | The preview shows every change the refactoring makes; then the IDE formats each file it changed. Choose Apply. The EK9 IDE just before choosing Apply: The preview shows every change the refactoring makes; then the IDE formats each file it changed |
| Rename Field | The result | That is Rename Field: farewell is signoff, at its declaration and every use inside Greeter - sayGoodbye included. Nothing outside Greeter needed to change, because nothing outside it could see farewell in the first place; a same-named constructor parameter, and its named arguments at every call, ... |
| Rename Field | Where this lesson comes from | For AI assistants - the MCP tool ek9_rename_field. |
| Remove Field | Remove Field | Remove Field deletes a field from a class, record or component once it has checked every reference inside that construct's body - the field-scoped sibling of Safe Delete, which reaches across the whole workspace. It classifies each reference it finds and offers a repair for the mechanical kinds, ... |
| Remove Field | Step 1: Where it is | Put the caret on spare, on line 7. The EK9 IDE once this is done: Put the caret on spare, on line 7 |
| Remove Field | Step 2: Remove Field | Right-click it - or choose Refactor > Refactor This… - and choose Remove Field… The EK9 IDE once this is done: Right-click it - or choose Refactor > Refactor This… - and choose Remove Field… |
| Remove Field | Step 3: Preview and apply | The preview shows every change the refactoring makes; then the IDE formats each file it changed. Choose Apply. |
| Remove Field | The result | That is Remove Field: spare is gone from Greeter, in one edit - name and the rest of the class unchanged. Had sayHello, or anywhere else inside Greeter, still read spare, the preview would have listed each reference, classified by kind, with a repair for the mechanical ones - a boolean-chain ... |
| Remove Field | Where this lesson comes from | For AI assistants - the MCP tool ek9_remove_field. |
| Change Visibility | Change Visibility | Change Visibility narrows or widens a method's access modifier - public, protected or private - and the submenu only ever offers the moves that are actually legal for the method under the caret. Here decorate is a helper describe alone calls; nothing outside Order uses it, so it can be private. ... |
| Change Visibility | Step 1: Where it is | Put the caret on decorate, on line 14. The EK9 IDE once this is done: Put the caret on decorate, on line 14 |
| Change Visibility | Step 2: Change Visibility | Right-click it - or choose Refactor > Refactor This… - and choose Change Visibility > Make Private. The EK9 IDE once this is done: Right-click it - or choose Refactor > Refactor This… - and choose Change Visibility > Make Private |
| Change Visibility | Step 3: Preview and apply | The preview shows every change the refactoring makes; then the IDE formats each file it changed. Choose Apply. |
| Change Visibility | The result | That is Change Visibility: decorate is private on Order - describe still calls it from inside the class, but nothing outside Order can. Make Public, Make Protected and Make Private sit together in the same submenu, and a narrowing that would strand an outside caller surfaces as a would-fail ... |
| Change Visibility | Where this lesson comes from | For AI assistants - the MCP tool ek9_change_visibility. |
| Surround With | Surround With | Surround With folds a selection of whole statements under an if, try/catch, for-range or while head - EK9 has no braces, so the tool re-indents the lines for you rather than leave it to be mis-typed by hand. Here warnLowStock always prints, even before stock is actually low. To play it in the ... |
| Surround With | Step 1: Surround it with if … | Put the caret on the stdout.println line, right-click it - or choose Refactor > Refactor This… - and choose Surround With ▸ if …. The EK9 IDE once this is done: Put the caret on the stdout.println line, right-click it - or choose Refactor > Refactor This… - and choose Surround With ▸ if … The ... |
| Surround With | The result | That is Surround With: warnLowStock's one statement is folded under 'if surroundGuard? //AI: Replace with condition' - an opaque placeholder you replace with the real stock check, the statement itself re-indented +2 spaces so EK9's brace-free layout is never mis-typed by hand. The same submenu ... |
| Surround With | Where this lesson comes from | For AI assistants - the MCP tool ek9_surround_with. |
| Generate Delegation | Generate Delegation | Generate Delegation wires a trait the class already declares to an existing field with 'by' and the field's name, so the compiler forwards every trait method to it - no bodies to write. Here Robot declares Greeter but has not yet delegated it, so greet() falls back to the trait's own default ... |
| Generate Delegation | Step 1: Where it is | Put the caret on Robot, on line 17. The EK9 IDE once this is done: Put the caret on Robot, on line 17 |
| Generate Delegation | Step 2: Generate Delegation | Right-click it - or choose Refactor > Refactor This… - and choose Generate Delegation… The EK9 IDE once this is done: Right-click it - or choose Refactor > Refactor This… - and choose Generate Delegation… Greeter and inner are already chosen - Robot's only trait and only field. Choose Preview. |
| Generate Delegation | Step 3: Preview and apply | The preview shows every change the refactoring makes; then the IDE formats each file it changed. Choose Apply. The EK9 IDE just before choosing Apply: The preview shows every change the refactoring makes; then the IDE formats each file it changed |
| Generate Delegation | The result | That is Generate Delegation: Robot now reads 'with trait of Greeter by inner', so greet() forwards to inner and returns 'Echo' instead of the trait's own 'Hello'. Wiring a trait the class does NOT yet declare is Adopt Trait's delegate mode instead; overriding one forwarded method yourself (Add ... |
| Generate Delegation | Where this lesson comes from | For AI assistants - the MCP tool ek9_generate_delegation. |
| Generate Dispatcher | Generate Dispatcher | Generate Dispatcher scaffolds a dispatcher entry - 'sound() as dispatcher', say - plus one handler overload per subtype of a base type - sealed for exhaustive dispatch, or open with the entry's own fallback covering the rest. Here Animal allows only Dog and Cat; AnimalDispatcher has no dispatcher ... |
| Generate Dispatcher | Step 1: Where it is | Put the caret on AnimalDispatcher, on line 12. The EK9 IDE once this is done: Put the caret on AnimalDispatcher, on line 12 |
| Generate Dispatcher | Step 2: Generate Dispatcher | Right-click it - or choose Refactor > Refactor This… - and choose Generate Dispatcher… The EK9 IDE once this is done: Right-click it - or choose Refactor > Refactor This… - and choose Generate Dispatcher… Animal is already chosen - the workspace's one sealed type. Name the dispatcher sound and ... |
| Generate Dispatcher | Step 3: Preview and apply | The preview shows every change the refactoring makes; then the IDE formats each file it changed. Choose Apply. The EK9 IDE just before choosing Apply: The preview shows every change the refactoring makes; then the IDE formats each file it changed |
| Generate Dispatcher | The result | That is Generate Dispatcher: AnimalDispatcher gained sound() as dispatcher plus a private sound() overload for Dog and for Cat, each with a //AI: Implement sound lead where its body goes - exhaustive, since Animal is sealed; a non-sealed base instead leaves the entry's own fallback body to cover ... |
| Generate Dispatcher | Where this lesson comes from | For AI assistants - the MCP tool ek9_generate_dispatcher. |
| Extract to Localized Text | Extract to Localized Text | Extract to Localized Text moves a hard-coded string out of the code and into a localized text method, rewriting the call site to use the text variable already in scope. Here "Goodbye for now!" is hard-coded in ShowFarewell, when appText - the AppText text type's en_GB instance - already speaks ... |
| Extract to Localized Text | Step 1: Where it is | Put the caret on "Goodbye for now!", on line 17. The EK9 IDE once this is done: Put the caret on "Goodbye for now!", on line 17 |
| Extract to Localized Text | Step 2: Extract to Localized Text | Right-click it - or choose Refactor > Refactor This… - and choose Localisation > Extract to Localized Text… The EK9 IDE once this is done: Right-click it - or choose Refactor > Refactor This… - and choose Localisation > Extract to Localized Text… Name the new method farewell, and the text ... |
| Extract to Localized Text | Step 3: Preview and apply | The preview shows every change the refactoring makes; then the IDE formats each file it changed. Choose Apply. The EK9 IDE just before choosing Apply: The preview shows every change the refactoring makes; then the IDE formats each file it changed |
| Extract to Localized Text | The result | That is Extract to Localized Text: "Goodbye for now!" is gone from ShowFarewell, and AppText gained farewell() - one method, one body, for its one locale. A text type spanning several locales instead gets a stub per locale, listed for translation; a literal with no text type yet needs Code > ... |
| Extract to Localized Text | Where this lesson comes from | Answers - ek9 -q and the IDE's Answers tab: 113.For AI assistants - the MCP tool ek9_extract_to_localized_text. |
| Organize Localized Text | Organize Localized Text | Organize Localized Text gathers a module's localized text into one of three layouts: one file per locale, one file per text type, or everything collapsed into one file you name. Here greetings.ek9 declares Greeting for both en_GB and de inline, in the same file that runs it. To play it in the ... |
| Organize Localized Text | Step 1: Choose the layout | Choose Code > Localisation > Organize Localized Text… The EK9 IDE once this is done: Choose Code > Localisation > Organize Localized Text… |
| Organize Localized Text | Step 2: Split by Locale | Choose Split by Locale. That is one file per language, the layout Getting Started's localisation chapter uses. |
| Organize Localized Text | Step 3: Preview and apply | The preview shows a new file for each locale and the lines removed from greetings.ek9. Choose Apply. The EK9 IDE just before choosing Apply: The preview shows a new file for each locale and the lines removed from greetings.ek9 |
| Organize Localized Text | The result | That is Organize Localized Text: greetings.ek9 keeps only the program, and en_GB.ek9 and de.ek9 each hold their own locale's Greeting - one file per language, so adding a third locale is adding a third file. Split by Class gathers the same text the OTHER way, one file per text type, every locale ... |
| Organize Localized Text | Where this lesson comes from | Answers - ek9 -q and the IDE's Answers tab: 113, 1380.For AI assistants - the MCP tool ek9_organize_localized_text. |
| Inline Candidates | Inline Candidates | The Inline Candidates window finds locals whose name adds little over their initialiser - the inverse of Unused Code, and a self-audit against naming slop. Here reportLine declares two such locals: heading, a trivial literal used once, and total, which calls addTax() once. To play it in the IDE: ... |
| Inline Candidates | Step 1: Open the window | Choose View > Tool Windows > Inline Candidates. The EK9 IDE once this is done: Choose View > Tool Windows > Inline Candidates |
| Inline Candidates | Step 2: The findings | heading is listed under 🧹 Worth inlining - a trivial literal, used exactly once: a redundant name. total is listed under ✓ Safe - review first - its initialiser calls addTax(), so inlining it is mechanical, but the call it stands for may still be worth a name. |
| Inline Candidates | Step 3: Inline one | Right-click heading and choose Inline variable… The EK9 IDE once this is done: Right-click heading and choose Inline variable… |
| Inline Candidates | Step 4: Preview and apply | The preview shows heading's value moved to where it was used, and the declaration gone. Choose Apply. |
| Inline Candidates | The result | That is the Inline Candidates window: heading is gone from reportLine, its literal "Daily Report" now written where heading was used, in the string rtn is given. total is left under Safe - review first: its initialiser calls addTax(), so inlining it is mechanical but the name addTax(100) stands ... |
| Inline Candidates | Where this lesson comes from | For AI assistants - the MCP tool ek9_find_inline_candidates, ek9_inline_variable. |
| Promote to Constant | Promote to Constant | Promote to Constant moves a name <- literal declaration - a property or a local - into the module's defines constant block, keeping the same name, and deletes the original declaration. Here temperature is Weather's own field, but 20 is the same for every Weather there will ever be: state that ... |
| Promote to Constant | Step 1: Where it is | Put the caret on temperature <- 20, on line 7. The EK9 IDE once this is done: Put the caret on temperature <- 20, on line 7 |
| Promote to Constant | Step 2: Promote to Constant | Right-click it - or choose Refactor > Refactor This… - and choose Promote to Constant… The EK9 IDE once this is done: Right-click it - or choose Refactor > Refactor This… - and choose Promote to Constant… |
| Promote to Constant | Step 3: Preview and apply | The preview shows every change the refactoring makes; then the IDE formats each file it changed. Choose Apply. |
| Promote to Constant | The result | That is Promote to Constant: temperature is gone from Weather's own fields and lives in the module's defines constant block instead; show() still reads temperature - unqualified, it now resolves to the constant - so nothing else about Weather had to change. A value that DOES vary between ... |
| Promote to Constant | Where this lesson comes from | Answers - ek9 -q and the IDE's Answers tab: 140.For AI assistants - the MCP tool ek9_promote_to_constant. |
| Convert Constructor | Convert Constructor | Convert Constructor swaps a no-arg constructor between its two equivalent forms: 'default Name()' - the compiler's own shorthand - and an explicit body that sets every field with :=?. Here Person's no-arg constructor is 'default private', with nothing to customise yet. To play it in the IDE: Help ... |
| Convert Constructor | Step 1: The constructor | Put the caret on the default private Person() as pure line. The EK9 IDE once this is done: Put the caret on the default private Person() as pure line |
| Convert Constructor | Step 2: Expand it | Right-click it and choose Expand 'default' Constructor to Default-Setter. The EK9 IDE once this is done: Right-click it and choose Expand 'default' Constructor to Default-Setter The change is in the open file, not yet saved. Choose File > Save. The EK9 IDE once this is done: The change is in the ... |
| Convert Constructor | The result | That is Convert Constructor: Person's no-arg constructor is now explicit - private Person() as pure - with one this.field :=? String() per assignable field, ready to customise (add validation before the fields are set, say). Collapse Constructor to 'default' is the exact reverse, offered instead ... |
| Convert Constructor | Where this lesson comes from | For AI assistants - the MCP tool ek9_convert_constructor. |
| Expand Default Operator | Expand Default Operator | Expand Default Operator replaces a 'default operator' line (default operator $, == and the like) with the explicit body the compiler would synthesise from the fields - ready to customise. Here Point's default operator $ gives a string form nobody has looked at yet. To play it in the IDE: Help > ... |
| Expand Default Operator | Step 1: The default operator | Put the caret on the default operator $ line. The EK9 IDE once this is done: Put the caret on the default operator $ line |
| Expand Default Operator | Step 2: Expand it | Right-click it and choose Expand 'default operator $' to Skeleton. The EK9 IDE once this is done: Right-click it and choose Expand 'default operator $' to Skeleton The change is in the open file, not yet saved. Choose File > Save. The EK9 IDE once this is done: The change is in the open file, not ... |
| Expand Default Operator | The result | That is Expand Default Operator: Point's default operator $ is now an explicit body - operator $ as pure, interpolating every field in declaration order - ready to customise (a different format, say). Collapse to Default Operator is the exact reverse, offered instead on an explicit defaultable ... |
| Expand Default Operator | Where this lesson comes from | For AI assistants - the MCP tool ek9_expand_default_operator, ek9_collapse_to_default_operator. |
| Rename File / Move File | Rename File / Move File | Rename File and Move File relocate a file on disk, contents untouched - Rename edits the basename in place and enforces the .ek9 extension; Move edits the whole workspace-relative path, into another directory if you like, for any file. Here caller.ek9 references greet() from greeting.ek9; watch ... |
| Rename File / Move File | Step 1: Rename it | In the Project panel, right-click greeting.ek9, choose Rename File…, replace the name with greetings.ek9 and choose OK. The EK9 IDE just before choosing OK: In the Project panel, right-click greeting.ek9, choose Rename File…, replace the name with greetings.ek9 and choose OK |
| Rename File / Move File | Step 2: Move it | In the Project panel, right-click greetings.ek9, choose Move File…, replace the path with lib/greetings.ek9 and choose OK. The EK9 IDE just before choosing OK: In the Project panel, right-click greetings.ek9, choose Move File…, replace the path with lib/greetings.ek9 and choose OK |
| Rename File / Move File | The result | That is Rename File and Move File: greeting.ek9 is now lib/greetings.ek9, and caller.ek9 - which never changed - still resolves greet() exactly as before. EK9 module identity comes from the file's own 'defines module' line, never its name or directory, so neither tool touches a single byte of ... |
| Rename File / Move File | Where this lesson comes from | For AI assistants - the MCP tool ek9_rename_file, ek9_move_file. |
| Toggle Comment, Remove Comment, Reformat | Toggle Comment, Remove Comment, Reformat | Toggle Comment, Remove Comment, Reformat File and Reformat All Open Files are code-tidying actions with no dialog and no preview - each change lands at once, so each gets its own Save afterwards. Toggle Comment wraps whole lines in EK9's <!- -!> block-comment form, disabling them without deleting ... |
| Toggle Comment, Remove Comment, Reformat | Step 1: Toggle Comment | Put the caret on the second stdout.println line - the debug print, not the greeting - then choose Code > Toggle Comment (⌘/), also on the right-click menu. It wraps the line in EK9's <!- -!> block-comment form, so it stops running without being deleted. The EK9 IDE once this is done: Put the ... |
| Toggle Comment, Remove Comment, Reformat | Step 2: Remove Comment | Right-click the comment line - // This comment is no longer needed - and choose Remove Comment. The EK9 IDE once this is done: Right-click the comment line - // This comment is no longer needed - and choose Remove Comment The change is in the open file, not yet saved. Choose File > Save. The EK9 ... |
| Toggle Comment, Remove Comment, Reformat | Step 3: Reformat File | A quick edit has left extra spaces inside stdout.println's brackets - stdout.println( greeting ). The program still compiles; it just no longer reads as EK9's canonical layout. The EK9 IDE once this is done: A quick edit has left extra spaces inside stdout.println's brackets - stdout.println( ... |
| Toggle Comment, Remove Comment, Reformat | Step 4: Reformat All Open Files | greet.ek9 - the function tidy.ek9 calls - is now open too, with the same kind of extra spacing: two spaces after rtn as String:. It is not saved either. The EK9 IDE once this is done: greet.ek9 - the function tidy.ek9 calls - is now open too, with the same kind of extra spacing tidy.ek9 is back ... |
| Toggle Comment, Remove Comment, Reformat | The result | That is Toggle Comment, Remove Comment, Reformat File and Reformat All Open Files: the debug print is commented out rather than deleted, the stale note is gone, and every spacing slip in both open files is back to canonical style. Toggle Comment is Code > Toggle Comment (⌘/) or the right-click ... |
| Toggle Comment, Remove Comment, Reformat | Where this lesson comes from | Answers - ek9 -q and the IDE's Answers tab: 18, 625.For AI assistants - the MCP tool ek9_toggle_block_comment, ek9_remove_comments, ek9_format. |
| New EK9 File, New Directory, Delete File, Delete Directory | New EK9 File, New Directory, Delete File, Delete Directory | The Project panel's own right-click menu makes and removes files and directories directly on disk - no dialog preview, no changeset. New EK9 File… writes the three-part EK9 boilerplate before you type a line of your own; New Directory… just makes a folder; Delete File… and Delete Directory… each ... |
| New EK9 File, New Directory, Delete File, Delete Directory | Step 1: A new file | Right-click archive in the Project panel, choose New EK9 File…, name it report.ek9, name its module lesson.archive.report, and choose OK. The EK9 IDE just before choosing OK: Right-click archive in the Project panel, choose New EK9 File…, name it report.ek9, name its module lesson.archive.report, ... |
| New EK9 File, New Directory, Delete File, Delete Directory | Step 2: A new directory | Right-click archive again, choose New Directory…, name it scratch, and choose OK. The EK9 IDE just before choosing OK: Right-click archive again, choose New Directory…, name it scratch, and choose OK |
| New EK9 File, New Directory, Delete File, Delete Directory | Step 3: Delete it again | Right-click scratch and choose Delete Directory… - enabled only because it is empty - then choose OK. The EK9 IDE just before choosing OK: Right-click scratch and choose Delete Directory… - enabled only because it is empty - then choose OK |
| New EK9 File, New Directory, Delete File, Delete Directory | Step 4: Delete the old file | Right-click old_notes.ek9 and choose Delete File…, then choose Delete. The EK9 IDE just before choosing Delete: Right-click old_notes.ek9 and choose Delete File…, then choose Delete |
| New EK9 File, New Directory, Delete File, Delete Directory | The result | That is the Project panel's own file operations: report.ek9 is new in archive, scratch existed only long enough to prove Delete Directory… only ever removes an EMPTY one, and old_notes.ek9 - no longer needed - is gone too. New EK9 File… writes the same three-part boilerplate ek9_write_file does - ... |
| New EK9 File, New Directory, Delete File, Delete Directory | Where this lesson comes from | For AI assistants - the MCP tool ek9_write_file, ek9_delete_file, ek9_delete_directory. |
| Run configurations | Run configurations | Greet takes a person's name as its argument and greets them with whatever the GREETING environment variable says - Hello when nothing sets it. The argument and the environment are two things a run needs that are not in the code. A run configuration keeps them, under a name, so you do not type ... |
| Run configurations | Step 1: A one-off run | Choose Run > Run Program… The EK9 IDE once this is done: Choose Run > Run Program… Type Ada into Arguments (space-separated), then choose Run. The EK9 IDE just before choosing Run: Type Ada into Arguments (space-separated), then choose Run Hello, Ada - nothing sets GREETING, and the argument you ... |
| Run configurations | Step 2: Save two configurations | Choose Run > Configurations… The EK9 IDE once this is done: Choose Run > Configurations… Greet is the only program, so it is already the one a new configuration will belong to. Choose + New Configuration… Name it Formal, type Lovelace into Arguments and, into Environment, GREETING=Good morning. ... |
| Run configurations | Step 3: Switch with the toolbar's picker | In the toolbar's picker, beside the green play icon, choose Casual. The EK9 IDE once this is done: In the toolbar's picker, beside the green play icon, choose Casual Choose the green play icon - Run selected configuration. The EK9 IDE once this is done: Choose the green play icon - Run selected ... |
| Run configurations | Step 4: Edit one, run it again | Choose the gear beside the picker - Edit Configurations… - which opens the same window as Run > Configurations…. The EK9 IDE once this is done: Choose the gear beside the picker - Edit Configurations… - which opens the same window as Run > Configurations… Double-click Casual in the list to edit ... |
| Run configurations | The result | That is a run configuration: a name, an argument line and an environment, kept for one program - as many as you like. Run > Run Program… (or the gutter's play icon) is for a run you will not repeat; Run > Configurations… saves, edits and deletes them; the toolbar's picker switches between them ... |
| Run configurations | Where this lesson comes from | Answers - ek9 -q and the IDE's Answers tab: 2, 947.For AI assistants - the MCP tool ek9_run_program. |
| Running tests | Running tests | maths.ek9 declares three functions - square, cube and classify; dev/tests.ek9 holds three @Test programs that check them. SquareTest and CubeTest are right; ClassifyTest's own claim is wrong, on purpose, so there is a failing test to read. Read both files. To play it in the IDE: Help > Lessons > ... |
| Running tests | Step 1: The ▶ on a test | Open dev/tests.ek9 - the three @Test programs, each with its own ▶. The EK9 IDE once this is done: Open dev/tests.ek9 - the three @Test programs, each with its own ▶ Click the ▶ beside SquareTest, on line 12, to run that one test on its own. The EK9 IDE once this is done: Click the ▶ beside ... |
| Running tests | Step 2: Run every test | The ▶ only ran SquareTest. Run ▸ Run Tests (⌘T) runs every @Test in the project instead - SquareTest, CubeTest and ClassifyTest all three. Choose Run Tests. The EK9 IDE once this is done: The ▶ only ran SquareTest |
| Running tests | Step 3: A failing test | The Tests tab lists all three: SquareTest and CubeTest green, ClassifyTest red, with its own message - the assertion that failed, classify(5) == "positive", and the line it is on - and a link to where ClassifyTest is declared. The EK9 IDE once this is done: The Tests tab lists all three Click the ... |
| Running tests | Step 4: Coverage highlighting | Open maths.ek9 again - coverage shows there, never in the test file itself. The EK9 IDE once this is done: Open maths.ek9 again - coverage shows there, never in the test file itself Coverage highlighting came on by itself the first time a run produced results: square's and cube's lines shade as ... |
| Running tests | The result | That is running and reading tests: the ▶ beside one @Test for a quick check, Run Tests (⌘T) for every @Test in the project, the Tests tab's own pass/fail list with a link from a failure straight to its declaration, and coverage highlighting - turned on by a run itself, or by hand from View ▸ ... |
| Running tests | Where this lesson comes from | Answers - ek9 -q and the IDE's Answers tab: 157.For AI assistants - the MCP tool ek9_run_tests. |
| The Terminal | The Terminal | Hello is a one-program project. The IDE has a Terminal of its own: your login shell, started in this project's folder. Read hello.ek9. To play it in the IDE: Help > Lessons > Running and testing…, or ek9 -ide -lesson the-terminal. The EK9 IDE as the lesson opens |
| The Terminal | Step 1: Open the Terminal | Choose View > Bottom Panes > Terminal The EK9 IDE once this is done: Choose View > Bottom Panes > Terminal A shell is running in the project's folder. Type ls and press Enter - the folder's files are listed. The EK9 IDE once this is done: A shell is running in the project's folder |
| The Terminal | Step 2: ek9 is already on its PATH | Type ek9 -V and press Enter. The EK9 this IDE runs from is first on the shell's PATH, so ek9 needs no setup here. The EK9 IDE once this is done: Type ek9 -V and press Enter |
| The Terminal | Step 3: Compile and run from the shell | Type ek9 hello.ek9 -r Hello and press Enter - it compiles hello.ek9 and runs its Hello program, with nothing but the command line. The EK9 IDE once this is done: Type ek9 hello.ek9 -r Hello and press Enter - it compiles hello.ek9 and runs its Hello program, with nothing but the command line The ... |
| The Terminal | The result | That is the Terminal: a shell of your own, in the project's folder, with the ek9 command this IDE runs from first on its PATH - so a script, a build step or a command from the documentation runs here exactly as it will on a server. + opens another shell in a new tab; closing a tab hangs its shell ... |
| The Terminal | Where this lesson comes from | For AI assistants - the MCP tool ek9_compile, ek9_run_program. |
| The quality report | The quality report | The Driving Test Centre is a small two-module project: candidates, vehicle categories, a fee schedule injected into an application, and three tests that only try a little of it. Read domain.ek9 - a constrained CandidateAge (17 to 70) and isMinimumAge, which checks it. To play it in the IDE: Help ... |
| The quality report | Step 1: Run the quality report | Run > Quality Report (Shift+Cmd+R) compiles the project, runs its three tests, and writes the same report ek9 -t6 writes - opened in your own browser when you play this for real; this lesson suppresses that so the IDE keeps the focus. Choose Quality Report. The EK9 IDE once this is done: Run > ... |
| The quality report | Step 2: The pass/fail pill and Quality at a Glance | On index.html: the header's pill reads "All 3 tests passed" - the three hand-written tests, nothing wrong with them. Quality at a Glance tells a different story: Verification shows three rings - coverage 15.3% (lines that ran), driven 6.6% (input classes actually tried), asserted 6.6% (of those, ... |
| The quality report | Step 3: Coverage Detail | Coverage Detail: Methods 16.7% (3/18), Lines 15.5% (11/71), Branches 0.0% (0/12) - branches is the hand-written tests' real gap, since none of them chooses between anything. Code Quality Metrics, just above it: Complexity max 27, 18 of 45 headroom - StandardFeeSchedule.feeFor, more than half the ... |
| The quality report | Step 4: A module, then a file | Follow quality.centre.domain in the Modules table at the foot of index.html: its own page repeats Glance/Metrics/Coverage for just this module, then lists its Source Files - domain.ek9, scoring.ek9, vehicles.ek9 - and every Function & Method, each with its own CC/I/H/C tokens. The EK9 IDE once ... |
| The quality report | Step 5: DI Wiring | The header's three links - DI Wiring, Module Dependencies, Type Hierarchy - are pages of their own. DI Wiring: CentreApp is HEALTHY, registering StandardFeeSchedule as AbstractFeeSchedule; its one injection site, BookingService.schedule, is ticked - every injected field has something registered ... |
| The quality report | The result | That is the quality report: the pass/fail pill is about tests, the Verification rings beside it are about proof - asserted is the one that matters, because a line can run (covered) with nothing checking what it did. The module and file pages repeat the same CC/I/H/C tokens the editor's own ... |
| The quality report | Where this lesson comes from | Answers - ek9 -q and the IDE's Answers tab: 321, 811.For AI assistants - the MCP tool ek9_run_quality_checks. |
| Generate Edge-Case Tests | Generate Edge-Case Tests | isMinimumAge checks whether a candidate is old enough for a test - age 17 or more, the comment above it says. Three hand-written tests already pass; none of them tries the boundary. Read domain.ek9. To play it in the IDE: Help > Lessons > Quality and reports…, or ek9 -ide -lesson edge-case-tests. ... |
| Generate Edge-Case Tests | Step 1: Generate Edge-Case Tests | Choose Code > Generate > Edge-Case Tests (whole file)… The EK9 IDE once this is done: Choose Code > Generate > Edge-Case Tests (whole file)… Type 42 into Seed, so the result is the same every time, and quality.centre.tests into Test module, so the generated tests join dev/tests.ek9's own module ... |
| Generate Edge-Case Tests | Step 2: Apply, and the scaffolding | The preview lists what would be written - 7 tests ready to write. Nothing is on disk yet. Choose Apply to write them for real. The EK9 IDE just before choosing Apply: The preview lists what would be written - 7 tests ready to write Choose Open generated file. The EK9 IDE just before choosing Open ... |
| Generate Edge-Case Tests | Step 3: Run them | Run > Run Tests (⌘T) runs all ten - the three hand-written and the seven just generated. Choose Run Tests. The EK9 IDE once this is done: Run > Run Tests (⌘T) runs all ten - the three hand-written and the seven just generated Two go red, for two different reasons. ... |
| Generate Edge-Case Tests | Step 4: Decide each one | The requirement says nothing about a candidate with no age at all, so there is no reason to expect a set answer here. Select the live assert line for testFuzz_isMinimumAge_CandidateAge_0 and type the flip its own //AI: line offers: assert not isMinimumAge(age: CandidateAge())?. Saves when typed. ... |
| Generate Edge-Case Tests | Step 5: All green, and the report again | Run > Run Tests (⌘T) again - choose Run Tests. The EK9 IDE once this is done: Run > Run Tests (⌘T) again - choose Run Tests Run > Quality Report (Shift+Cmd+R) writes the report again, now that isMinimumAge is tried at its own boundary. Choose Quality Report. The EK9 IDE once this is done: Run > ... |
| Generate Edge-Case Tests | The result | That is Generate Edge-Case Tests: it writes the calls and the edge values, and leaves every expectation marked //AI: for a person or an AI to set from the REQUIREMENT. One flip and one real code fix later, all ten pass - and the report's Input Variety and Verification both rise, because ... |
| Generate Edge-Case Tests | Where this lesson comes from | Answers - ek9 -q and the IDE's Answers tab: 754.For AI assistants - the MCP tool ek9_generate_edge_case_tests. |
| Complexity limits and budget bars | Complexity limits and budget bars | StandardFeeSchedule.feeFor prices a driving test by age band and vehicle category - twelve branches, built to sit near half the compiler's complexity budget. Read service.ek9. To play it in the IDE: Help > Lessons > Quality and reports…, or ek9 -ide -lesson complexity-limits. The EK9 IDE as the ... |
| Complexity limits and budget bars | Step 1: Complexity badges in the editor | Choose View > Toggles > Complexity Badges (⌥⌘C). The EK9 IDE once this is done: Choose View > Toggles > Complexity Badges (⌥⌘C) A red circle marked C appears beside feeFor's own declaration line - CRITICAL, the editor's tightest severity. Hover it for the exact numbers: cyclomatic, cognitive and ... |
| Complexity limits and budget bars | Step 2: Run the quality report | Run > Quality Report (Shift+Cmd+R) writes the report this lesson reads next. Choose Quality Report. The EK9 IDE once this is done: Run > Quality Report (Shift+Cmd+R) writes the report this lesson reads next |
| Complexity limits and budget bars | Step 3: The budget bars | On index.html, Code Quality Metrics: Complexity shows max 27, avg 2.7, 18 of 45 headroom - the bar itself is amber (warning), because 27 of 45 is 60%, over the report's own 50% line. Cognitive reads max 12 of 35 (34%) - still green on this bar, even though the SAME method read red in the editor a ... |
| Complexity limits and budget bars | The result | That is complexity, read two ways: the editor's badge is an early warning with tight thresholds (15 cyclomatic, 20 cognitive), long before anything is close to failing; the report's bar is the compiler's own hard stop (45, 35) - amber at half, red at 80%. feeFor sits at 60% of the hard limit, ... |
| Complexity limits and budget bars | Where this lesson comes from | Answers - ek9 -q and the IDE's Answers tab: 696, 765.For AI assistants - the MCP tool ek9_query_complexity. |
| Contracts and risk | Contracts and risk | averageScore divides a candidate's total marks by the number of attempts, and requires that attempts is more than zero. A require that could be false is an uncatchable panic in production - exactly what the report's Contracts section counts. Read scoring.ek9. To play it in the IDE: Help > Lessons ... |
| Contracts and risk | Step 1: Run the quality report | Run > Quality Report (Shift+Cmd+R) writes the report this lesson reads. Choose Quality Report. The EK9 IDE once this is done: Run > Quality Report (Shift+Cmd+R) writes the report this lesson reads |
| Contracts and risk | Step 2: Risk: hazard times exposure | On index.html, Risk profile: 18 constructs, each scored hazard x exposure (HEX). Hazard is how much a change here can break, from its complexity and coupling. Exposure is how little the tests would notice. The product has two levers, always: make the code less dangerous, or make the tests notice ... |
| Contracts and risk | Step 3: Contracts: discharged or unproven | Contracts: 2/4 discharged by construction, 2 unproven. An obligation is a point that could fail for some input - a division by zero, a require that could be false, an unguarded container unwrap, a constrained type built out of range. Discharged means the compiler has already proved it safe for ... |
| Contracts and risk | Step 4: Ask the solver | Choose Code > Generate > Edge-Case Tests (whole file)… The EK9 IDE once this is done: Choose Code > Generate > Edge-Case Tests (whole file)… Tick Verify-directed - one @Test per counterexample. It runs the bounded-model solver on every function in scoring.ek9 instead of spraying edge values, so ... |
| Contracts and risk | The result | That is risk and contracts. Risk is hazard times exposure: how much a change can break, times how little the tests would notice - so lower either, by simplifying the code or by testing it harder; a low score on untested code means little can go wrong, not that anything is guarded. Contracts are ... |
| Contracts and risk | Where this lesson comes from | Answers - ek9 -q and the IDE's Answers tab: 304.For AI assistants - the MCP tool ek9_run_quality_checks, ek9_verify_method. |
| Breakpoints and stepping | Breakpoints and stepping | Counting adds double(i) to a running total, once for each i from 1 to 5 - a loop whose own values change every pass, and a function to step into. Read it. To play it in the IDE: Help > Lessons > Debugging and the Journal…, or ek9 -ide -lesson breakpoints-and-stepping. The EK9 IDE as the lesson opens |
| Breakpoints and stepping | Step 1: A breakpoint | Click the breakpoint column beside line 16 (total := total + double(i)). The EK9 IDE once this is done: Click the breakpoint column beside line 16 (total := total + double(i)) |
| Breakpoints and stepping | Step 2: Start debugging | Click the debug (bug) icon beside Counting() - no saved configuration exists for it yet. The EK9 IDE once this is done: Click the debug (bug) icon beside Counting() - no saved configuration exists for it yet The project's only program is already chosen. Choose Debug. The Debug window opened on ... |
| Breakpoints and stepping | Step 3: Step Over | In the Debug window, choose Step Over - the call to double() runs, but stepping stays in Counting(). The EK9 IDE once this is done: In the Debug window, choose Step Over - the call to double() runs, but stepping stays in Counting() |
| Breakpoints and stepping | Step 4: Step Into, and Step Out | Choose Continue - the breakpoint is plain, so it stops again on the loop's next pass, at the same line. The EK9 IDE once this is done: Choose Continue - the breakpoint is plain, so it stops again on the loop's next pass, at the same line This time choose Step Into - stepping follows the call into ... |
| Breakpoints and stepping | Step 5: Run to Cursor, and ending the session | Click the breakpoint column beside line 16 again, to remove it - left there, it would catch the loop's next pass before Run to Cursor ever got to line 18. The EK9 IDE once this is done: Click the breakpoint column beside line 16 again, to remove it - left there, it would catch the loop's next ... |
| Breakpoints and stepping | The result | That is the breakpoint column, the Debug window and the three steps: Over runs one line without leaving it, Into follows a call inside, Out runs the rest of the callee and comes back. Run to Cursor is a breakpoint for one run only - gone the moment it is reached. Breakpoint conditions - stopping ... |
| Breakpoints and stepping | Where this lesson comes from | For AI assistants - the MCP tool ek9_debug_session, ek9_debug_control. |
| Breakpoint conditions | Breakpoint conditions | Counting adds double(i) to a running total, once for each i from 1 to 5. A breakpoint on the loop's own line stops every pass; this lesson adds a condition so it stops on only one. Read it. To play it in the IDE: Help > Lessons > Debugging and the Journal…, or ek9 -ide -lesson ... |
| Breakpoint conditions | Step 1: A breakpoint, every time | Click the breakpoint column beside line 16 (total := total + double(i)). The EK9 IDE once this is done: Click the breakpoint column beside line 16 (total := total + double(i)) Click the debug (bug) icon beside Counting(). The EK9 IDE once this is done: Click the debug (bug) icon beside Counting() ... |
| Breakpoint conditions | Step 2: A condition | In the Debug window's Breakpoints list, right-click the row for conditions.ek9:16 and choose Edit condition… The EK9 IDE once this is done: In the Debug window's Breakpoints list, right-click the row for conditions.ek9:16 and choose Edit condition… Type i == 3 into Condition, then choose OK. The ... |
| Breakpoint conditions | Step 3: Only when it holds | Click the debug (bug) icon beside Counting() again. The EK9 IDE once this is done: Click the debug (bug) icon beside Counting() again Choose Debug. It ran straight past i=1 and i=2, where the condition does not hold - Variables shows i is 3, the first pass where it does. The EK9 IDE once this is ... |
| Breakpoint conditions | The result | That is a breakpoint condition: read from the program's own values, never changing them, checked every time the line runs - a plain breakpoint stops always, a conditional one only when its text holds. The SAME dialog has two more fields, not played here: a hit count (">= 3", stop only from the ... |
| Breakpoint conditions | Where this lesson comes from | For AI assistants - the MCP tool ek9_debug_control. |
| Watches | Watches | A watch reads a value at every stop, without a breakpoint on it - a class field included, even one EK9 itself keeps private. Counter.bump adds to its own total, once for each pass of a loop; apiKey is read from an environment variable with EnvVars().sensitiveGet(...), never written into the ... |
| Watches | Step 1: Stopped, with a secret ready | Click the breakpoint column beside line 23 (counter.bump(i)) - as in Breakpoints and stepping. The EK9 IDE once this is done: Click the breakpoint column beside line 23 (counter.bump(i)) - as in Breakpoints and stepping Click the debug (bug) icon beside Tally() - no saved configuration exists for ... |
| Watches | Step 2: Add a watch | Into "Add a watch" type counter.total and press Enter - counter.total has no visibility of its own outside Counter, but the debugger reads it anyway. The EK9 IDE once this is done: Into "Add a watch" type counter.total and press Enter - counter.total has no visibility of its own outside Counter, ... |
| Watches | Step 3: Break when value changes | Click the breakpoint column beside line 23 again, to remove it - so the next stop is only because counter.total itself changes, never because of a line. The EK9 IDE once this is done: Click the breakpoint column beside line 23 again, to remove it - so the next stop is only because counter.total ... |
| Watches | Step 4: Sensitive, masked | Click the breakpoint column beside line 25 (stdout.println(key set: ...)). The EK9 IDE once this is done: Click the breakpoint column beside line 25 (stdout.println(`key set In the Debug window, choose Continue - the rest of the loop runs on, with no breakpoint left to catch it. The EK9 IDE once ... |
| Watches | The result | That is a watch, a data breakpoint and a Sensitive value, masked. Add to Watches reads any path at every stop - a field a class keeps private included, since the debugger reads fields, not EK9 code. Break when value changes stops the moment that value is actually changed, wherever that happens to ... |
| Watches | Where this lesson comes from | For AI assistants - the MCP tool ek9_debug_inspect, ek9_debug_control. |
| The Journal: one run | The Journal: one run | The Journal records every change to a value while a program runs, so a failure can be read backwards to where it went wrong. This lesson records one run of Orders, a small program that fails late. Read Orders.ek9 first. To play it in the IDE: Help > Lessons > Debugging and the Journal…, or ek9 ... |
| The Journal: one run | Step 1: A program that fails late | Orders runs an order through scenario 1, 2, 3 or 4. Scenario 3 - a discount, then a refund - fails late: the invoice refuses a negative total with a Panic, long after the change that made it negative. Nothing fails where the mistake is. The EK9 IDE once this is done: Orders runs an order through ... |
| The Journal: one run | Step 2: Record a run | Choose Run > New Journal Investigation… The EK9 IDE once this is done: Choose Run > New Journal Investigation… Watch Order.total, and give one input set - 3, the failing scenario: one line is one run. The hypothesis - what you think went wrong - is optional; this lesson gives one. Choose Start. ... |
| The Journal: one run | Step 3: The story | A failed run opens at its story: the run's inputs, then the changes to Order.total that led to the failure, oldest first, each with its tick - t1, t2, ... - the order they happened in. Read it from the bottom: the symptom, then the change just before it. The EK9 IDE once this is done: A failed ... |
| The Journal: one run | Step 4: Where it went wrong | Click Orders.ek9:41 in the story - the refund that took the total from 50 to -30. The editor goes to that line. The EK9 IDE once this is done: Click Orders.ek9:41 in the story - the refund that took the total from 50 to -30 |
| The Journal: one run | Step 5: The marks in the editor | In the editor, each line that changed Order.total shows what it did in this run - total 50 -> -30 and its tick. A count in the margin marks every line that could change it: how often it did in this run (a 0 on one it never reached). The red ! is where it failed. The EK9 IDE once this is done: In ... |
| The Journal: one run | The result | That is one run read backwards: from where it failed to the change that caused it. Comparing it with runs that passed - what only the failing run did - is the next lesson. |
| The Journal: one run | Where this lesson comes from | For AI assistants - the MCP tool ek9_debug_inspect. |
| The Journal: comparing runs | The Journal: comparing runs | Comparing finds what separates the runs that fail from the ones that pass, without reading any one run's story first. This lesson records all four of Orders' scenarios, then compares the one that fails with one that passes. Read Orders.ek9 first. To play it in the IDE: Help > Lessons > Debugging ... |
| The Journal: comparing runs | Step 1: A program with passing and failing runs | Orders runs scenario 1, 2, 3 or 4: an add, then (scenario 2 or 3) a discount, then (scenario 3 or 4) a refund. Scenario 3 - discount, then refund - is the only one that fails: the refund is taken from the discounted total, and the invoice refuses the negative result. The EK9 IDE once this is ... |
| The Journal: comparing runs | Step 2: Record several runs | Choose Run > New Journal Investigation… The EK9 IDE once this is done: Choose Run > New Journal Investigation… Watch Order.total, and give all four scenarios - one input set per line: 1, 2, 3, 4. Choose Start. The EK9 IDE just before choosing Start: Watch Order.total, and give all four scenarios ... |
| The Journal: comparing runs | Step 3: Choose two to compare | Click the FAIL run (scenario 3) to select it alone, then ⌘-click the pass run for scenario 1: now exactly those two are selected, and compared - not all four. The EK9 IDE once this is done: Click the FAIL run (scenario 3) to select it alone, then ⌘-click the pass run for scenario 1 |
| The Journal: comparing runs | Step 4: What only the failing run did | The side by side lines up the failing run against the passing one, step by step. "not in this run" under pass, for the discount and the refund, is what only the failing run did - read from the top: the add is the same in both, then the failing run alone discounts and refunds. The EK9 IDE once ... |
| The Journal: comparing runs | Step 5: The Journal Report | Choose Report… The EK9 IDE once this is done: Choose Report… Say what you think is wrong - citing the step and line that show it - and choose Write Report. It opens as a page: what was run, how each run ended, and the two side by side - with report.json beside it for a model to read. The EK9 IDE ... |
| The Journal: comparing runs | The result | That is comparing: choose the runs, read what separates them, and hand the report to someone who has not seen the IDE. Trying a variation of one run - without filling the whole dialog again - is the next lesson. The EK9 IDE when the lesson has finished |
| The Journal: comparing runs | Where this lesson comes from | For AI assistants - the MCP tool ek9_debug_inspect. |
| The Journal: a new investigation | The Journal: a new investigation | Trying a variation of a run - a different input, everything else the same - usually means filling New Journal Investigation… from scratch. The Journal has a shortcut: run it again with one input changed. This lesson records Orders' failing scenario, then tries scenario 4 instead, with the same ... |
| The Journal: a new investigation | Step 1: Orders, and its defect | Orders runs scenario 1, 2, 3 or 4: an add, then (scenario 2 or 3) a discount, then (scenario 3 or 4) a refund. Only scenario 3 fails - the refund is taken from the discounted total. Scenario 4 refunds too, but with no discount first. The EK9 IDE once this is done: Orders runs scenario 1, 2, 3 or 4 |
| The Journal: a new investigation | Step 2: Record one failing run | Choose Run > New Journal Investigation… The EK9 IDE once this is done: Choose Run > New Journal Investigation… Watch Order.total, and give one input set - 3, the failing scenario. Choose Start. The EK9 IDE just before choosing Start: Watch Order.total, and give one input set - 3, the failing ... |
| The Journal: a new investigation | Step 3: Try it again, one input changed | Right-click the run and choose "Again with one input changed…" The EK9 IDE once this is done: Right-click the run and choose "Again with one input changed…" Change the input to 4 and choose Run. It runs again with the same seed, so only that input differs. The EK9 IDE just before choosing Run: ... |
| The Journal: a new investigation | Step 4: What changed | Both runs are in the Journal tab: scenario 3 - FAIL, with its symptom - and scenario 4 - pass, with none. Same program, same seed, one input changed: the discount is what the failing run did differently. The line above the table sums up the latest investigation only - the one run just made. The ... |
| The Journal: a new investigation | The result | That is the Journal's own way to try a variation of a run - the same seed, one input changed, without filling New Journal Investigation… again. Comparing runs deliberately, and the Journal Report, are the earlier lessons. |
| The Journal: a new investigation | Where this lesson comes from | For AI assistants - the MCP tool ek9_debug_session. |
| Show Blast Radius | Show Blast Radius | Show Blast Radius pictures who a purity change would reach before you make it. Here announce() is pure but calls shout(), which is not (E08130); morningBriefing() and eveningBriefing() are both pure callers of announce(), in two different files - read the code. To play it in the IDE: Help > ... |
| Show Blast Radius | Step 1: Where the change starts | Put the caret on shout(message), on line 12 - where the compiler flagged it. The EK9 IDE once this is done: Put the caret on shout(message), on line 12 - where the compiler flagged it |
| Show Blast Radius | Step 2: Show Blast Radius | Right-click it - or choose Refactor > Refactor This… - and choose Show Blast Radius (purity impact). The EK9 IDE once this is done: Right-click it - or choose Refactor > Refactor This… - and choose Show Blast Radius (purity impact) |
| Show Blast Radius | Step 3: The ripple | The Fix dropdown starts at Drop pure from announce(). announce() sits at the centre, ▼ shout() to its right (the non-pure callee - what Make callee pure would change), and ▲ morningBriefing() and eveningBriefing() to its left (the pure callers that break if pure is dropped from announce()) - a ... |
| Show Blast Radius | Step 4: The other direction | Choose Make callee pure in the Fix dropdown - making shout() pure, instead of announce() not. Apply turns from disabled to enabled: nothing else breaks, so this direction is ready. The EK9 IDE once this is done: Choose Make callee pure in the Fix dropdown - making shout() pure, instead of ... |
| Show Blast Radius | The result | That is Show Blast Radius: removing pure from announce() would break 2 callers in 2 files - morningBriefing() and eveningBriefing() - so EK9 refuses it outright for this direction; adding pure to shout() instead breaks nothing, and is the one Apply offers. Fix Purity Contract plays that Apply, ... |
| Show Blast Radius | Where this lesson comes from | The errors it fixes - each one's explanation offers this lesson: E05150, E05160, E08130.For AI assistants - the MCP tool ek9_query_purity_impact, ek9_query_signature_impact. |
| Five views, one construct | Five views, one construct | Readings is a small class, built only to give the Analyse menu's first five views something real to show: a header and its members (Construct), what names are visible at one point (Scope), everything you can call on it (Effective API), how one method branches (Flow Analysis), and what each stage ... |
| Five views, one construct | Step 1: The construct | Put the caret on Readings' own declaration line, then choose Analyse ▸ Construct (⇧⌘S) - or right-click the same line and choose Inspect ▸ Construct instead. The EK9 IDE once this is done: Put the caret on Readings' own declaration line, then choose Analyse ▸ Construct (⇧⌘S) - or right-click the ... |
| Five views, one construct | Step 2: What's visible here | Put the caret on summary()'s own declaration line, then choose Analyse ▸ Scope (⇧⌘I). The EK9 IDE once this is done: Put the caret on summary()'s own declaration line, then choose Analyse ▸ Scope (⇧⌘I) A yellow badge at the top reads Purity: pure - the innermost pure scope wins, here summary() ... |
| Five views, one construct | Step 3: Its effective API | Put the caret back on Readings' declaration line, then choose Analyse ▸ Effective API (⇧⌘E). The EK9 IDE once this is done: Put the caret back on Readings' declaration line, then choose Analyse ▸ Effective API (⇧⌘E) The same kind of picture Construct drew, but for what you can actually CALL: ... |
| Five views, one construct | Step 4: How it branches | Put the caret back on summary()'s declaration line, then choose Analyse ▸ Flow Analysis (⇧⌘G). The EK9 IDE once this is done: Put the caret back on summary()'s declaration line, then choose Analyse ▸ Flow Analysis (⇧⌘G) The pane heads with summary, marked pure, and a row of small badges giving ... |
| Five views, one construct | Step 5: The pipeline, stage by stage | Put the caret on the pipeline line inside warmReadings - anywhere between cat and the end - then choose Analyse ▸ Pipeline (⇧⌘L). The EK9 IDE once this is done: Put the caret on the pipeline line inside warmReadings - anywhere between cat and the end - then choose Analyse ▸ Pipeline (⇧⌘L) Three ... |
| Five views, one construct | The result | Five lenses, one construct: Construct showed Readings' own shape, Scope showed what summary() can see from where its caret sits, Effective API showed everything you can call on Readings, Flow Analysis showed how summary() branches, and Pipeline decomposed warmReadings' stream chain stage by ... |
| Five views, one construct | Where this lesson comes from | For AI assistants - the MCP tool ek9_query_construct, ek9_list_visible_symbols, ek9_query_effective_api, ek9_query_flow, ek9_query_pipeline. |
| Type Hierarchy and Dispatcher | Type Hierarchy and Dispatcher | Type Hierarchy reads what a type extends and implements, and what extends it in turn; Dispatcher reads which concrete type resolves to which handler. Here Notification is an abstract base with three subtypes - EmailNotification, SmsNotification, PushNotification - and EmailNotification alone ... |
| Type Hierarchy and Dispatcher | Step 1: A subtype's own hierarchy | Put the caret on EmailNotification, in notifications.ek9, then choose Analyse > Type Hierarchy. The EK9 IDE once this is done: Put the caret on EmailNotification, in notifications.ek9, then choose Analyse > Type Hierarchy |
| Type Hierarchy and Dispatcher | Step 2: Reading the diagram | EmailNotification sits in the middle with a thicker border; Notification shows above it, joined by a solid grey line - extends; Loggable shows to its right, joined by a dashed teal line - implements. Every box's border colour is its genus: blue for a class, teal for a trait. Click a box's own ... |
| Type Hierarchy and Dispatcher | Step 3: From the base, looking down | Put the caret on Notification instead, then choose Analyse > Type Hierarchy again - the same menu item, reading whatever construct the caret sits on now. With the caret on the base itself, the diagram turns round: Notification sits at the top this time, with all three subtypes below it, each ... |
| Type Hierarchy and Dispatcher | Step 4: Who handles each type | Put the caret on route() as dispatcher, in NotificationRouter, then choose Analyse > Dispatcher. The EK9 IDE once this is done: Put the caret on route() as dispatcher, in NotificationRouter, then choose Analyse > Dispatcher |
| Type Hierarchy and Dispatcher | Step 5: Reading the resolution table | The resolution table lists all three concrete types route() could be called with. EmailNotification and SmsNotification show a green checkmark - DIRECT - each with an arrow to its own handler; PushNotification shows a red warning - FALLBACK - routed to route()'s own entry-point body instead, ... |
| Type Hierarchy and Dispatcher | The result | That is Type Hierarchy and Dispatcher: EmailNotification's own view showed Notification above it and Loggable beside it; Notification's own view showed all three subtypes below it. NotificationRouter's dispatcher resolves EmailNotification and SmsNotification directly to their own handlers, and ... |
| Type Hierarchy and Dispatcher | Where this lesson comes from | For AI assistants - the MCP tool ek9_query_type_hierarchy, ek9_query_dispatchers. |
| Call Graph and Neighbourhood | Call Graph and Neighbourhood | Call Graph reads who calls a function or method and what it calls in turn; Neighbourhood reads a construct's own structural neighbours - what it extends, implements, composes or references - radiating out by hop. Here deliverAll() (delivery.ek9) calls describeNotification() and the dispatcher ... |
| Call Graph and Neighbourhood | Step 1: Who deliverAll() calls, and who calls it | Open delivery.ek9, put the caret on deliverAll(), then choose Analyse > Call Graph. The EK9 IDE once this is done: Open delivery.ek9, put the caret on deliverAll(), then choose Analyse > Call Graph |
| Call Graph and Neighbourhood | Step 2: Reading the diagram | deliverAll sits in a rose "you are here" box. Above it, Callers (1): Deliver, the program that calls it. Below it, Calls (5), each bordered in its kind's colour from the key at the top: Stdout() and NotificationRouter() teal - constructors; println mauve - a method; describeNotification green - a ... |
| Call Graph and Neighbourhood | Step 3: A construct's own neighbourhood | Open notifications.ek9, put the caret on EmailNotification, then choose Analyse > Neighbourhood. The EK9 IDE once this is done: Open notifications.ek9, put the caret on EmailNotification, then choose Analyse > Neighbourhood |
| Call Graph and Neighbourhood | Step 4: Reading the edges | Neighbourhood of EmailNotification: 9 constructs and 10 edges, two hops out (Hops 2, Dir both), with EmailNotification in the bold box at the centre. Beside it Loggable, the trait it implements, and around it the functions and the router that use it - describeNotification, deliverAll and ... |
| Call Graph and Neighbourhood | The result | That is Call Graph and Neighbourhood: deliverAll() (delivery.ek9) calls describeNotification() and route() - both declared in notifications.ek9, so the graph crosses the project's two files without being told to - and EmailNotification's neighbourhood showed what it extends and implements and ... |
| Call Graph and Neighbourhood | Where this lesson comes from | For AI assistants - the MCP tool ek9_query_call_graph, ek9_query_construct_neighbourhood. |
| Modules and Packages | Modules and Packages | A module is one defines module name, and a project can have many - here a small shop in six: core holds Price and Item, pricing and orders build on it, app is the program on top, and stock and shipping each refer to the other. The code does not draw that; the Analyse views do. Read the files, ... |
| Modules and Packages | Step 1: The landscape | Choose Analyse > Module Landscape. The EK9 IDE once this is done: Choose Analyse > Module Landscape The summary line reads Modules: 6, In cycles: 2 - red, because two modules are in one. Each card is a module: its name, Ce (how many other modules it reaches out to, against the limit of 10), the ... |
| Modules and Packages | Step 2: Who depends on whom | Choose Analyse > Module Dependencies. The EK9 IDE once this is done: Choose Analyse > Module Dependencies The same six modules, this time as layers: a module sits above the ones it depends on, and every dependency is an arrow. The header counts them - Modules, Dependencies, the largest fan-out ... |
| Modules and Packages | Step 3: Packages | Choose Analyse > Package Dependencies. The EK9 IDE once this is done: Choose Analyse > Package Dependencies Package Dependencies asks the same question of packages - the project's own defines package block and the packages it names under deps. This project has one package and depends on none, so ... |
| Modules and Packages | The result | That is the project from above, three ways: Module Landscape (⇧⌘Y) a card per module with its coupling, Module Dependencies (⇧⌘M) the same modules in layers with every dependency drawn, and Package Dependencies, which asks the same question of packages. stock and shipping refer to each other, so ... |
| Modules and Packages | Where this lesson comes from | Answers - ek9 -q and the IDE's Answers tab: 766, 7.For AI assistants - the MCP tool ek9_query_module_landscape, ek9_query_module_dependencies, ek9_check_module_cycles, ek9_check_package_dependency_cycles. |
| Service Routes and DI Wiring | Service Routes and DI Wiring | A small shop: catalogue.ek9 holds two web services - ItemService, behind a security gate called AccountGate, and the open HealthService - and Catalogue, a class that needs a Repository and a Notifier injected; components.ek9 holds those and their implementations; app.ek9 registers everything in ... |
| Service Routes and DI Wiring | Step 1: Service Routes | Choose Analyse > Service Routes. The EK9 IDE once this is done: Choose Analyse > Service Routes The summary line counts the surface: 3 routes, 2 guarded and 1 unguarded, and 1 unsanitised parameter - red, because an unguarded route and an unsanitised input are the two things a security review ... |
| Service Routes and DI Wiring | Step 2: DI Wiring | Choose Analyse > DI Wiring. The EK9 IDE once this is done: Choose Analyse > DI Wiring ShopApp is the application, with a HEALTHY border: everything it needs is provided. Its registrations come first - MemoryRepository registered as Repository and ConsoleNotifier as Notifier, and the two services ... |
| Service Routes and DI Wiring | The result | That is a web service and its wiring, read without running either: Service Routes listed every route the compiler found - with its security gate, or the red unguarded flag - and DI Wiring showed what ShopApp registers and whether every injection site has something to receive. Nothing was served - ... |
| Service Routes and DI Wiring | Where this lesson comes from | Answers - ek9 -q and the IDE's Answers tab: 1292, 203.For AI assistants - the MCP tool ek9_query_service_routes, ek9_query_dependency_injection. |
| Locks and Deadlocks | Locks and Deadlocks | Ledger is a component with two locks of different types - balanceLock guards a balance, auditLock an audit note - and record() takes the audit lock while it holds the balance lock, so the second is always entered inside the first. Nothing here runs: the Analyse views read what the compiler worked ... |
| Locks and Deadlocks | Step 1: Every lock | Choose Analyse > Lock Catalogue. The EK9 IDE once this is done: Choose Analyse > Lock Catalogue 2 lock identities, both FIELD_ROOTED - a lock identity is one lock the compiler can name, and these are named after the fields they live in (the groups would also list ALLOCATION, PARAMETER and CAPTURE ... |
| Locks and Deadlocks | Step 2: One method's locks | Put the caret inside record(), then choose Analyse > Lock Fingerprint. The EK9 IDE once this is done: Put the caret inside record(), then choose Analyse > Lock Fingerprint The fingerprint of record(): Direct Enters (1) - the one enter record() itself makes, on balanceLock (ledger.ek9:20); Direct ... |
| Locks and Deadlocks | Step 3: Deadlocks, while safe | Choose Analyse > Deadlocks. The EK9 IDE once this is done: Choose Analyse > Deadlocks No lock-order cycles detected - your locks are safe, in green. The analysis has seen record() take auditLock inside balanceLock and found nothing that takes them the other way round, so no two threads can each ... |
| Locks and Deadlocks | Step 4: A lock-order cycle | Select the record(10) line in settle(), and below it type a second method, refund(), that takes the locks the OTHER way round: the audit key's body enters the balance lock, and the balance key is held outside it - the mirror of record(). Saves when typed. The EK9 IDE once this is done: Select the ... |
| Locks and Deadlocks | The result | That is the whole lock story, read three ways and then broken on purpose: the Lock Catalogue listed every lock, the Lock Fingerprint one method's locks, and Deadlocks said safe while the two locks were taken in one order - and drew two chains the moment refund() took them in the other. The ... |
| Locks and Deadlocks | Where this lesson comes from | Answers - ek9 -q and the IDE's Answers tab: 158, 1298, 1300.For AI assistants - the MCP tool ek9_query_lock_analysis, ek9_query_lock_identity, ek9_query_deadlock_chain. |
| Localisations | Localisations | Two modules each speak in more than one language. lesson.greetings has its Greeting text in en, fr and de; lesson.farewells has its Farewell text in en and fr. The Localisations window draws that picture across the project. Read greetings.ek9. To play it in the IDE: Help > Lessons > Understanding ... |
| Localisations | Step 1: The Localisations window | Choose View > Tool Windows > Localisations (Cmd+8). The window opens beside the editor. The EK9 IDE once this is done: Choose View > Tool Windows > Localisations (Cmd+8) Under Locales it lists en, fr and de, each with how many modules have it. Under Modules it gives each module's share translated ... |
| Localisations | Step 2: Add the missing locale | Open farewells.ek9 in the Project panel. Add Locale works on the module of the file in front. The EK9 IDE once this is done: Open farewells.ek9 in the Project panel Choose Code > Localisation > Add Locale… The EK9 IDE once this is done: Choose Code > Localisation > Add Locale… Type de as the new ... |
| Localisations | Step 3: Remove a locale | Choose Code > Localisation > Remove Locale… The EK9 IDE once this is done: Choose Code > Localisation > Remove Locale… Choose de as the locale to remove, then Preview. The preview shows the de block deleted from lesson.farewells - and from no other module. Choose Apply. The EK9 IDE just before ... |
| Localisations | The result | The Localisations window shows the locales in play, how far each module is translated and where a locale is missing. Add Locale… cloned de into lesson.farewells from en, stubbed for translation - the stubs are the translation still owed, which ek9_query_translation_completeness counts and the ... |
| Localisations | Where this lesson comes from | Answers - ek9 -q and the IDE's Answers tab: 113.For AI assistants - the MCP tool ek9_edit_localized_text, ek9_query_localisations, ek9_query_translation_completeness. |
| Capabilities | Capabilities | The Capabilities window audits every gated system type the code uses against what the package declares. Here printMessage uses Stdout and logError uses Stderr - neither declared, each its own E12010, explained in the Hovers panel - while the package declares TCP, which nothing ever uses. To play ... |
| Capabilities | Step 1: Open the window | Choose View > Tool Windows > Capabilities. The EK9 IDE once this is done: Choose View > Tool Windows > Capabilities |
| Capabilities | Step 2: The audit | Stdout and Stderr are both listed under ⚠ under-declared - used but not declared, the E12010 set. TCP is listed under ⚠ over-declared, unused - declared but nothing ever calls it. |
| Capabilities | Step 3: Add a capability | Right-click Stdout and choose Add capability 'Stdout' to package. The EK9 IDE once this is done: Right-click Stdout and choose Add capability 'Stdout' to package |
| Capabilities | Step 4: Preview and apply | The preview shows Stdout added to the capabilities list; then the IDE formats the file. Choose Apply. |
| Capabilities | Step 5: Remove an unused capability | Right-click TCP and choose Remove unused capability 'TCP'. The EK9 IDE once this is done: Right-click TCP and choose Remove unused capability 'TCP' |
| Capabilities | Step 6: Preview and apply | The preview shows TCP removed from the capabilities list; then the IDE formats the file. Choose Apply. |
| Capabilities | The result | That is the Capabilities window: Stdout is now declared, so printMessage's own E12010 is gone; TCP is gone from the capabilities list entirely, since nothing ever used it. Stderr's own E12010 - the same fix, one finding down - is left for you to try. Under-declared is the compile-blocking set ... |
| Capabilities | Where this lesson comes from | The errors it fixes - each one's explanation offers this lesson: E12010.Answers - ek9 -q and the IDE's Answers tab: 1271, 1277, 1275.For AI assistants - the MCP tool ek9_query_capability_usage, ek9_add_capability, ek9_remove_capability. |
| Sensitive reveals and environment variables | Sensitive reveals and environment variables | Startup reads three environment variables, one of them a secret: an API key taken with sensitiveGet, so it is a Sensitive value that prints as redacted. Two classes then turn a Sensitive back into text with reveal() - SecureVault, which is Privileged, and LeakyService, which is not. That second ... |
| Sensitive reveals and environment variables | Step 1: Environment Variables | Choose View > Tool Windows > Environment Variables (⌘7). The EK9 IDE once this is done: Choose View > Tool Windows > Environment Variables (⌘7) Every EnvVars read in the project, grouped by how its value enters the program, the ones to audit first at the top: 🔒 Sensitive (SERVICE_API_KEY, read ... |
| Sensitive reveals and environment variables | Step 2: Sensitive Reveals | Choose View > Tool Windows > Sensitive Reveals. The EK9 IDE once this is done: Choose View > Tool Windows > Sensitive Reveals Every reveal() in the project, by legality, the violations first: "2 reveals · 1 violation(s) (E11090)". LeakyService is listed under ⚠ Unprivileged - a class without the ... |
| Sensitive reveals and environment variables | Step 3: Make it Privileged | A class that handles raw secrets must say so. Select LeakyService's declaration line and type it with Privileged added to its traits: LeakyService with trait of Privileged, SecretHandler. Saves when typed. The EK9 IDE once this is done: A class that handles raw secrets must say so The project ... |
| Sensitive reveals and environment variables | The result | That is the audit of a program's secrets, kept up to date by the compiler: Environment Variables says where each value comes in and how clean it is - Sensitive first, then Unsanitized - and Sensitive Reveals says where a secret is turned back into text, and whether that place is Privileged. Both ... |
| Sensitive reveals and environment variables | Where this lesson comes from | The errors it fixes - each one's explanation offers this lesson: E11090.Answers - ek9 -q and the IDE's Answers tab: 701, 271, 1016.For AI assistants - the MCP tool ek9_query_env_vars, ek9_query_sensitive_reveals. |
| The package block | The package block | gateway.ek9 holds a defines package block: the package's version, description, licence and tags, and under deps two modules it needs, each pinned to a version. Right-click anywhere inside that block and the editor's menu gains the package items - versions, dependencies, capabilities and ... |
| The package block | Step 1: Set the version | Right-click inside the package block and choose Set Version… The EK9 IDE once this is done: Right-click inside the package block and choose Set Version… Type 1.1.0 - MAJOR.MINOR.PATCH, with no build counter - and choose Set Version. The EK9 IDE just before choosing Set Version: Type 1.1.0 - ... |
| The package block | Step 2: Increment it | Right-click the version line and choose Increment Patch Version. On the version line the menu leads with Increment Build, Patch, Minor and Major. Patch went from 1.1.0 to 1.1.1. Choose Close. The EK9 IDE just before choosing Close: On the version line the menu leads with Increment Build, Patch, ... |
| The package block | Step 3: Add a dependency | Right-click inside the package block and choose Add Dependency… The EK9 IDE once this is done: Right-click inside the package block and choose Add Dependency… Type ek9open.logging.essentials as the module path and 2.3.0-0 as its version - the bucket stays deps - and choose Preview. The new line ... |
| The package block | Step 4: Exclude a transitive dependency | Right-click inside the package block and choose Exclude Transitive Dependency… The EK9 IDE once this is done: Right-click inside the package block and choose Exclude Transitive Dependency… Type ek9open.legacy.slf4j.bridge as the transitive module and ek9open.logging.essentials as the parent ... |
| The package block | The result | That is the package block's own menu: the version is 1.1.1-0, Add Dependency pinned ek9open.logging.essentials at 2.3.0-0, and the excludeDeps bucket now blocks ek9open.legacy.slf4j.bridge when it arrives through ek9open.logging.essentials. Nothing was fetched or installed, so the three deps ... |
| The package block | Where this lesson comes from | Answers - ek9 -q and the IDE's Answers tab: 15, 11, 7.For AI assistants - the MCP tool ek9_set_version, ek9_increment_version, ek9_set_feature_version, ek9_add_dependency, ek9_remove_dependency, ek9_exclude_transitive_dependency, ek9_remove_transitive_exclusion. |
| Git: stage, commit, push, pull | Git: stage, commit, push, pull | This project is a git repository with three commits of its own and a remote - a folder beside the project, made for this lesson, so nothing here leaves your machine. Its working tree holds three changes: hello.ek9 has been edited, shout.ek9 is new and already staged, and notes.txt has never been ... |
| Git: stage, commit, push, pull | Step 1: The Git window | Choose Git ▸ Commit… (⌘K). The EK9 IDE once this is done: Choose Git ▸ Commit… (⌘K) The Git window names the branch at its top - main, with no arrows: in step with the remote - and counts the changes under it, grouped: Staged holds shout.ek9, Modified holds hello.ek9 and Untracked holds ... |
| Git: stage, commit, push, pull | Step 2: Stage and commit | Right-click hello.ek9 under Modified and choose Stage. The EK9 IDE once this is done: Right-click hello.ek9 under Modified and choose Stage Right-click notes.txt under Untracked and choose Stage - git has never seen it, so staging is also how a new file is added. The EK9 IDE once this is done: ... |
| Git: stage, commit, push, pull | Step 3: Push | Choose Git ▸ Push (⇧⌘K). The EK9 IDE once this is done: Choose Git ▸ Push (⇧⌘K) The ↑1 is gone: the remote - a folder beside this project, made for the lesson - has the commit. Push sends the current branch to origin; it is refused, never forced, when the remote has moved on. The EK9 IDE once ... |
| Git: stage, commit, push, pull | Step 4: Fetch and pull | Someone else has just pushed a commit to the remote. Choose Git ▸ Fetch to look - it brings in what is there and changes none of your files. The EK9 IDE once this is done: Someone else has just pushed a commit to the remote The branch now reads ↓1. Choose Git ▸ Pull (⌘P). The EK9 IDE once this is ... |
| Git: stage, commit, push, pull | Step 5: Branches | Choose Git ▸ Branches…. The EK9 IDE once this is done: Choose Git ▸ Branches… The list shows every branch, the current one marked ● and greyed. Choose New Branch…. The EK9 IDE once this is done: The list shows every branch, the current one marked ● and greyed Type farewell as the branch name and ... |
| Git: stage, commit, push, pull | The result | That is the everyday loop. You staged the two files git did not have yet, committed all three with a message and pushed them - to a folder beside the project, this lesson's own remote - then Fetch and Pull brought in another person's thanks function, and Branches… started farewell from main. ... |
| Git: stage, commit, push, pull | Where this lesson comes from | For AI assistants - the MCP tool ek9_git_status, ek9_git_add, ek9_git_commit, ek9_git_push, ek9_git_pull, ek9_git_branch, ek9_git_switch. |
| Git: history, stash, annotate, merge | Git: history, stash, annotate, merge | This project is a git repository with a history: four commits on main by two people, and a branch called shout that left main after the third commit and has two commits of its own. hello.ek9 has one line more than its last commit. Everything here stays on your machine - there is no remote. To ... |
| Git: history, stash, annotate, merge | Step 1: The log | Choose Git ▸ Show Git Log. The EK9 IDE once this is done: Choose Git ▸ Show Git Log The Git Log tab lists the branches on its left - main and shout - and every commit, newest first, with its subject, author and date; the selected commit's changes show on the right. A graph runs down beside the ... |
| Git: history, stash, annotate, merge | Step 2: Who wrote this line | Right-click the farewell line in greeter.ek9 and choose Annotate (Git blame). The EK9 IDE once this is done: Right-click the farewell line in greeter.ek9 and choose Annotate (Git blame) A column opens beside the line numbers naming, for every line, the commit that last changed it and who made it. ... |
| Git: history, stash, annotate, merge | Step 3: Stash a change | Choose Git ▸ Commit… to open the Git window. The EK9 IDE once this is done: Choose Git ▸ Commit… to open the Git window hello.ek9 is Modified: a third line nobody has committed. Choose the Stash changes… button beside the branch. Type third hello line as the message - it is how you will find the ... |
| Git: history, stash, annotate, merge | Step 4: Merge a branch | Choose Git ▸ Merge Branch…. The EK9 IDE once this is done: Choose Git ▸ Merge Branch… shout is the only other branch, so it is chosen already, and the dialog has asked git what a merge would do - without doing it. A clean merge lists the files it would bring in; a conflict would name them and ... |
| Git: history, stash, annotate, merge | Step 5: Pop the stash | Select the stash in the Stashes window and choose Pop. The EK9 IDE once this is done: Select the stash in the Stashes window and choose Pop |
| Git: history, stash, annotate, merge | The result | That is what a repository remembers. The log drew main and shout leaving it; Annotate named who wrote each line of greeter.ek9 and when; Stash Changes… parked the edit to hello.ek9 so the tree was clean for the merge; Merge Branch… showed what it would do before it did it, and shout.ek9 arrived; ... |
| Git: history, stash, annotate, merge | Where this lesson comes from | For AI assistants - the MCP tool ek9_git_log, ek9_git_blame, ek9_git_stash, ek9_git_merge, ek9_git_diff. |
| Build: package, install, sign, deploy | Build: package, install, sign, deploy | pricing.ek9 holds one function, shippingLabel, and a package block that says what a package needs to be published: a version, a licence and publicAccess. Its two tests, in dev/tests.ek9, cover both branches - packaging refuses a package whose tests fail or whose coverage is too low. The Build ... |
| Build: package, install, sign, deploy | Step 1: Resolve dependencies | Choose Build ▸ Resolve Dependencies. The EK9 IDE once this is done: Choose Build ▸ Resolve Dependencies The package declares no dependencies, so there is nothing to fetch and the report is short. With deps declared, this is where each is found in the library - or reported missing. Choose Close. |
| Build: package, install, sign, deploy | Step 2: Package | Choose Build ▸ Package…. The EK9 IDE once this is done: Choose Build ▸ Package… The report says Success, with nothing more to say: packaging compiled the module, ran its two tests, checked the coverage and wrote shop.pricing-1.0.0-0.zip and its checksum into the project's .ek9 folder. Choose Close. |
| Build: package, install, sign, deploy | Step 3: Install | Choose Build ▸ Install Package. The EK9 IDE once this is done: Choose Build ▸ Install Package Install copied the package into the library, publishing-home/.ek9/lib here - ~/.ek9/lib for you outside this lesson - where another project's dependencies would find it. Choose Close. |
| Build: package, install, sign, deploy | Step 4: Signing keys | Choose Build ▸ Generate Signing Keys. The EK9 IDE once this is done: Choose Build ▸ Generate Signing Keys A key pair now sits in publishing-home/.ek9: the private key signs what you deploy, and stays with you; the public key is what a repository would be given to check it. Had keys already ... |
| Build: package, install, sign, deploy | Step 5: Deploy, and think twice | Choose Build ▸ Deploy Package…. The EK9 IDE once this is done: Choose Build ▸ Deploy Package… A published version cannot be retracted or changed - only superseded - so Deploy asks first, with the version it would publish. This lesson never deploys: choose Cancel. Nothing is sent and no tool has run. |
| Build: package, install, sign, deploy | The result | That is the road from source to a published package. Resolve Dependencies found nothing to fetch; Package… ran the tests, checked their coverage and wrote shop.pricing-1.0.0-0.zip and its checksum into the project's .ek9 folder; Install Package copied them into the library; Generate Signing Keys ... |
| Build: package, install, sign, deploy | Where this lesson comes from | Answers - ek9 -q and the IDE's Answers tab: 7, 14.For AI assistants - the MCP tool ek9_resolve_dependencies, ek9_package, ek9_install_package, ek9_generate_signing_keys, ek9_deploy_package. |