Cooper.Ref.Var (Cooper v0.4.0)

Copy Markdown View Source

An unresolved @{name} variable reference (CASC.md §5.2, §7.2). Eager, same timing as Cooper.Ref.Env -- resolved by Cooper.Resolver.

scope carries the identity of the file this reference was written in, stamped by Cooper.Scope.stamp/2 as soon as that file finishes parsing. It exists because visibility is a per-file property but resolution is not: Cooper.Loader splices every imported file's entries into one flat tree, and Cooper.Resolver then resolves the whole thing against a single variable environment. Without the stamp there is no way, at resolve time, to tell which file a given @{name} came from -- which is exactly what deciding whether it may see a private @*name requires. See Cooper.Scope's own moduledoc for the full visibility model.

Summary

Types

t()

@type t() :: %Cooper.Ref.Var{
  filters: [term()],
  index: non_neg_integer() | nil,
  name: String.t(),
  scope: String.t() | nil,
  suffix: Cooper.Ref.Env.suffix()
}