WESL Logo

#Imports Design

This document records design decisions behind WESL’s import system. The normative spec lives in Imports.md.

#Why the @! module attribute form?

@!wildcardable is module-level metadata. WESL will likely want module-level annotations for other module-scoped features, and libraries and users will want a place to attach their own metadata to a whole module. A general-purpose syntax for module metadata avoids inventing one ad-hoc form per feature.

@!wildcardable mirrors the item-level attribute convention (@group, @binding, @if, @diagnostic, …), but the ! marks the attribute as scoped to the whole module. Unlike an item attribute, it doesn’t attach to a following element, so a trailing ; terminates it.

Module attributes sit below the imports so that they can use imported names (for example a hypothetical @!play_version(2);).

See @!wildcardable annotation for the normative spec.

#Aren’t wildcards an anti-pattern?

Many language communities discourage wildcard imports. TypeScript, Go, Zig, and Carbon disallow wildcards entirely or restrict them to narrow cases. Java and Rust permit them syntactically but discourage broad use by convention; Rust’s prelude modules are one curated pattern in that style. The general concerns are practical:

The WESL environment adds further concerns:

These concerns motivate guardrails for WESL wildcard defaults.

#Wildcards in WESL: when to allow, when to gate

WESL keeps wildcards available because some libraries are designed to feel pervasive. Game engines, test frameworks, and math libraries expect a domain-specific API where prefixing every call with test::expect:: or similar would obscure the shader rather than help it. Concise import syntax matters even where an IDE can autocomplete: not every editor has a language server, and long import blocks add noise regardless of how they were typed.

But the concerns in Aren’t wildcards an anti-pattern? still apply, especially across package boundaries. WESL’s defaults try to keep the benefits while limiting the risk: