PART II
Instruction & guided example
Follow a call until it returns
A program is a sequence of precisely described operations, but a definition is not itself a request to perform every operation inside it. A function definition gives a reusable rule. A call supplies inputs to that rule. For this paper exercise, assume a host calls main once and observes its returned integer; do not assume that the website launches main.
Start in main. The expression add(2, 3) supplies a = 2 and b = 3. Enter add with those local names, evaluate a + b as 5, and return 5 to the waiting call in main. main then returns that same 5 to its caller. Write the chain as main → add(2,3) → 5 → main returns 5.
Nothing here prints a message or draws a screen. Returning 5 is the observable result only because this exercise explicitly says the host reads the return value. Reading the file from the first line and treating each definition as an immediate call would incorrectly invent an add invocation without any arguments.
Worked reasoning and supplied artifact
fnc add(a: i32, b: i32) -> i32 {
return a + b;
}
fnc main() -> i32 {
return add(2, 3);
}Illustrative example from the proposed WillowScript design. The language and WUIX/WMATH/WDB/WAUDIO/WTMP services are not implemented in the supplied source. This site has no interpreter, VM or native host and does not execute or certify the snippet.
Walk through the example, one line at a time
fnc add(a: i32, b: i32) -> i32 {Read the function name, its parameter names/types and the result type after ->. This is the contract the body must satisfy.
return a + b;Evaluate the following expression using the current values, then send its result to the caller. Explain the value; do not confuse it with printed output.
}Close the nested block or value begun earlier. Match it to its opening boundary to keep the structure readable.
fnc main() -> i32 {Read the function name, its parameter names/types and the result type after ->. This is the contract the body must satisfy.
return add(2, 3);Evaluate the following expression using the current values, then send its result to the caller. Explain the value; do not confuse it with printed output.
}Close the nested block or value begun earlier. Match it to its opening boundary to keep the structure readable.
Try the guided change
Trace add(4, 6) using separate rows for argument binding, addition and each return. Your final paper prediction should be 10.
- Write the supplied inputs and initial state before following the example.
- Reconstruct each intermediate calculation or host decision, then compare with the worked artifact.
- Explain why the contrasting alternative fails before attempting the changed inputs in Part IV.
PART III
Take a breather
Step back after the guided example. Look away from the screen, stretch, or reread your prediction. This is an optional learning pause, not a timer or an assessment gate.
When you return, try to name the lesson’s key idea without copying its wording. If that feels difficult, return to Part II and trace one line rather than restarting the entire lesson.
PART IV
Independent practice
Project context: Snack-shop calculator. Build a small, understandable change around instructions and observable results.
A checkpoint editor needs to combine 7 existing gates and 2 newly placed gates. Change main’s call, keep the helper unchanged, and give a four-row call/return trace. State exactly what the hypothetical host observes.
What to produce
A .ws draft, four trace rows, and one sentence separating a returned value from visible output.
- State the intended behavior in a sentence before editing.
- Use only source-backed syntax and the host services whose contract you have been given.
- Record a normal case and a boundary or unavailable-resource case.
- Label hand predictions separately from anything actually measured in a supplied toolchain.
Syntax colors are a reading aid, not a compiler. The line you are editing stays uncolored until you move to a different line; capitalization is never changed. Drafts stay on this browser and code is not executed.
Need a hint?
Start in main. The expression add(2, 3) supplies a = 2 and b = 3. Enter add with those local names, evaluate a + b as 5, and return 5 to the waiting call in main. main then returns that same 5 to its caller. Write the chain as main → add(2,3) → 5 → main returns 5.
Nothing here prints a message or draws a screen. Returning 5 is the observable result only because this exercise explicitly says the host reads the return value. Reading the file from the first line and treating each definition as an immediate call would incorrectly invent an add invocation without any arguments.
Original learning-path task and reference
In a research data workstation, demonstrate instructions and observable results. Read the source-grounded example and predict its observable behavior before making changes. Include .ws source and a host-resource contract; compare at least one normal case and one edge case.
Where the original task needs a host API that is not supplied here, write the contract and predictions. Do not invent a runtime result.
PART V
Self-check
Use this check to notice what to revisit. It does not award a private course grade, block another page or claim to verify compiled code. Every answer has a learning explanation.
You may keep exploring even if you are unsure. Use the hint, compare the trace, and revise your explanation.
PART VI
Recap & small task
Bring the idea back to the mod feature you are building. A useful recap connects the mechanism to a decision you can make in your own code.
- Follow a call until it returns
- A program is a sequence of precisely described operations, but a definition is not itself a request to perform every operation inside it. A function definition gives a reusable rule. A call supplies inputs to that rule. For this paper exercise, assume a host calls main once and observes its returned integer; do not assume that the website launches main.
- Separate source-backed behavior, host requirements and untested predictions.
One small recap task
Name the caller waiting for add’s result, then predict add(0, 3).
This marks your personal practice record only. It is not a certification or an official workspace assessment.
