Types, constants and methods are private by default. When such a symbol is private, it's only available to modules that are in the same root namespace. For example, private symbols defined in are available to, as both are located in the same std root namespace.

Making types public

For types and constants, making them public is done as follows:

Constantslet Example = 10let pub Example = 10
Classesclass Example {}class pub Example {}
Traitstrait Example {}trait pub Example {}

Making methods public

For methods the syntax is as follows:

Immutablefn example {}fn pub example {}
Mutablefn mut example {}fn pub mut example {}
Immutable asyncfn async example {}fn pub async example {}
Mutable asyncfn async mut example {}fn pub async mut example {}

pub always comes after the keyword used to define a symbol (e.g. fn), constants or method. The mut keyword in turn always comes directly before the name of the method.


The fields and regular (non-async) instance methods of a process are private to the type, meaning only the process itself can access them:

class async Cat {
  let @name: String

  fn give_food {}

class async Main {
  fn async main {
    let garfield = Cat { @name = 'Garfield' }

If you try to run this program, the following compile-time errors are produced:

test.inko:11:5 error(invalid-symbol): the field 'name' can only be used by the owning process
test.inko:12:5 error(invalid-call): the method 'give_food' exists but is private

This rule is enforced to ensure no data race conditions are possible as a result of different processes trying to access and/or mutate the same data.