Skip to content
Xen / docs

Search documentation

English · v0.1.0-demo.2

Type to search the documentation.

    한국어
    Xen / coding-class v0.1.0-demo.2

    Working with multiple files · Coding Class

    Apply the chapter in three steps: an exercise, a program project, and a debugging task. Implement first, then consult the hints and completion criteria. Use a separate file or working directory for each task.

    Write module declarations for app.xen, shop/model.xen, and shop/view.xen, and the import needed for view to use model.

    Completion: app, shop.model, and shop.view match the paths; view imports model directly.

    Hint: An import in app does not introduce names in view.

    Start from the chapter’s three files. Create model.Item values for tea priced 3 and bread priced 5. Print tea: 3 and bread: 5 through view, then total 8 from app.

    Completion: xen check app.xen succeeds and output is three lines. Define Item only once, in model.

    Hint: Keep display functions and data declarations in their respective modules.

    3. Debug · Fix a module declaration mismatch

    Section titled “3. Debug · Fix a module declaration mismatch”

    A file at shop/model.xen begins with module model;. Import it from the chapter’s app, check the project, and fix the declaration.

    Completion: Checking succeeds without moving the file or changing the import path.

    Hint: Reflect the path with module shop.model;.

    Use xen check file.xen followed by xen run file.xen for ordinary programs; use xen test file.xen for test-only files. Record the original error, its cause, and the corrected result, then rerun every input in the completion criteria.