Namespaces

Organizing your code into logical groups.

Organizing Code

As your project grows, keeping everything in the global scope can lead to name collisions. Ry provides Namespaces to help you organize your code into logical units.

Defining a Namespace

Use the namespace keyword to define a new namespace. You can define variables, functions, and classes inside it.

namespace Math {
    data PI = 3.14159

    func circleArea(data radius) {
        return PI * radius * radius
    }
}

Using Namespaces

You can access the members of a namespace using the dot . operator.

out(Math.PI)
out(Math.circleArea(10))

Namespaces are a great step towards modular applications. For even more performance and system access, check out C++ Modules.

Next: C++ Modules!