Language | How to Load | Reference |
---|---|---|
Elixir | Pin operator (^) in front of variable | 1 |
F# | Enum (with type) or tag variable with [<Literal>] |
2 |
OCaml | Constant, enum type, or manual if guard (eg. a when a = var_to_load )* |
3 |
Rust | Marked as enum, struct, or constant. Can also use fully qualified name (ie with module) to force. | 4 |
Scala | Capitalize or surround with backticks | 5 |
(* nearly all the languages above support manual loads with if guards)
Note: The Ecmascript proposal includes pinning as a followup rather than part of their main proposal.
- Imagine you have
let y = 1
- Current proposed JS syntax with no followup:
when x if (x === y)
- Idea 1: use pin operator like Elixir
- Idea 2: wrap constants a custom matcher class like
ByVal
(* this is also supported in nearly all the languages above but not really used since they have special syntax)