Targets · Go · Naming considerations

Naming considerations

A Program name nests to any depth — Ui.Button.Integer.Increment. This page is how that dotted name is carried into Go, which has no matching nesting.

Contents

How a Program becomes Go, in parts. Start with the introduction, then follow each part into the rendered output and the runtime it links against.

How it looks

Go keeps the last segment as a member and joins everything before it with an underscore.

Ui_Button_Integer.Increment(count, func() { … })   // was Ui.Button.Integer.Increment

The natural idiom

Go groups code by package, and a package cannot nest into another with a dot path. Within a package, exported functions are flat (maths.Add), and export is decided by capitalisation, not a keyword. There is no way to write four real dots for Ui.Button.Integer.Increment.

Can the real dotting be faked?

Only the final dot is real. Each top module becomes one lowercase Go package; the segments below it are joined with an underscore into a zero-field “static” struct, and the leaf is a method on it — giving one genuine dot at the call.

package ui

type Ui_Button_IntegerStatic struct{}
var Ui_Button_Integer = Ui_Button_IntegerStatic{}

func (Ui_Button_IntegerStatic) Increment(count ReactiveValue[int64], body func()) { … }

// the call keeps one real dot:
Ui_Button_Integer.Increment(count, func() { … })

Because _ is illegal in a Program identifier the join can never collide with a written name, and Go's PascalCase leaves the names already exported. A record TYPE type becomes a struct named the same way, or a native type for a built-in (Maths.Integerint64).

Recommendation

Use the underscore join with one package per top module. Only the last access is a real dot, but it is unambiguous and reads closely to the source — the same compromise Dart makes, and unlike Rust, Swift and Zig, which keep every dot.