LearnMusi for DevelopersMusi for C++ DevelopersValues, Functions, and Expressions

Values, Functions, and Expressions

Read Values, Functions, and Expressions as a C++17 habit shift, with links to the Musi Book definition.

A C++ reader brings habits from RAII, overload sets, templates, references, optional values, exceptions, and object hierarchies. That helps with ownership stories, value categories, and compile-time abstractions, but the Musi page asks a narrower question: what contract should this local values and calls example make visible?

cpp
auto receipt_total(int latte_cents, int croissant_cents) -> int {
    return latte_cents + croissant_cents;
}

auto total = receipt_total(450, 120);

Reading Values, Functions, and Expressions from C++17

On the Musi side, Musi lets a calculation be a let, a function, or a final expression without wrapping it in an object or framework first. Read the shared example through C++17 eyes: keep the useful instinct, then let Musi name shape, behavior, absence, and outside work in separate places.

False friend

Do not preserve call ceremony just because the source language needs it for methods, receivers, overloads, or closures. For a C++ reader, the trap is turning every Musi value into a class-shaped design; Musi class is closer to a concept or trait than a C++ class; records/data store shape, instances satisfy behavior.

When this pays off

Use this shape when a receipt total, label, distance, or score is pure data moving through named calls. The C++17 instinct still helps here: Keep the C++ habit of asking which operation is generic and which value owns shape.

Keep close