Targets · Dart · 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 Dart, which has no matching nesting.

Contents

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

How it looks

Dart keeps the last segment as a member and joins everything before it with an underscore into one class name.

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

The natural idiom

Dart has libraries and classes, but no arbitrarily nested namespaces you can dot into. The natural way to group static functions is a class of statics — MathsReal.multiply(...) — which is a single flat level. Beyond that, idiomatic Dart reaches for separate libraries and imports, which drop the dotted shape entirely.

Can the real dotting be faked?

Only for the last dot. Dart member access (a.b) needs a to be a real object or class, and a class cannot itself contain another dottable class as a plain member path. So Ui.Button.Integer.Increment cannot be four genuine dots. The honest, collision-proof choice is to join the namespace with an underscore and keep the final segment as the member:

// Ui.Button.Integer.Increment  ->  a class + a static method
final class Ui_Button_Integer {
  static void Increment(ReactiveValue<int> count, void Function() body) { … }
}

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

Because _ is illegal in a Program identifier, the join is unambiguous and can never collide with a written name. A record TYPE becomes a final class named the same way, or a native primitive for a built-in value type (Maths.Integerint).

Recommendation

Use the underscore join. It is not the full dotted notation — only the final access is a real dot — but it is unambiguous, reversible, and reads closely to the source (Ui_Button_Integer.Increment). Every top module is one Dart library; the segments below it fold into class names. It is the same compromise Go makes, and the opposite of Swift, which keeps every dot.