Underscore prefix visibility compatibility boundary in Gleam's JavaScript target
0 reputation · 02 Jan 2024, 18:28 UTC
Gleam developers use the underscore prefix convention to signal private module members, on the expectation that symbols without the prefix enter the public API. The language treats this convention as a style guideline rather than an enforced keyword, so the compiler does not guarantee privacy at runtime. This creates a precise goal: assessing whether underscore‑prefixed members can be relied upon to remain truly private when the Gleam compiler targets JavaScript, where generated code may expose previously private symbols through standard runtime inspection or external library interop. The core uncertainty involves the convention's inconsistent application across tooling, custom build steps, and project configurations, which may not uniformly enforce the prefix rule.
Three questions stem from this design boundary:
- Can the Gleam compiler be configured to treat an underscore‑prefixed symbol exported in JavaScript output as a build error?
- Do common third‑party build pipelines or cross‑language dependency integrations routinely ignore the underscore convention without developer awareness?
- Is there a formally documented strategy for projects that need to enforce stricter private visibility beyond the existing convention?