type-proposal
Differences
This shows you the differences between two versions of the page.
Next revision | Previous revision | ||
type-proposal [2025/08/06 20:41] – created smj-edison | type-proposal [2025/08/06 21:24] (current) – [Types are reactive] smj-edison | ||
---|---|---|---|
Line 16: | Line 16: | ||
Types will be tagged with their type name, and optionally with type parameters. | Types will be tagged with their type name, and optionally with type parameters. | ||
+ | |||
+ | ===== Basic operations ===== | ||
+ | Types can be manually created with `[list typeName typeValue]`, | ||
+ | |||
+ | Types are unboxed using `[$unbox:: | ||
+ | |||
+ | To check if a type is a certain type, use `[$is:: | ||
+ | |||
+ | To get details of a type, use `[$details $typeName]`. It should return a doc string or similar. | ||
+ | ===== Type names ===== | ||
+ | Type names come in two forms: canonical and inline. Canonical type names are either a name, or a list with the first parameter as its name. For example, a type name for meters could be " | ||
+ | |||
+ | Inline type names are a mixture of wildcards and symbol/ | ||
+ | |||
+ | ===== Types are reactive ===== | ||
+ | To get the type list (or any type list, lists can coexist), use < | ||
+ | When the types are /types/ { | ||
+ | lassign $types box unbox is typeName details | ||
+ | | ||
+ | # example using the newly imported types | ||
+ | puts [$unbox::mm "10 mm"] | ||
+ | } | ||
+ | </ | ||
===== Postfix or prefix? ===== | ===== Postfix or prefix? ===== | ||
Line 21: | Line 44: | ||
Pros of postfix: | Pros of postfix: | ||
- | * Types like "10 mm" are automatically a two item list, and as such are a full type | + | * Types like "10 mm" are automatically a two item list, and as such are a full type. |
Cons of postfix: | Cons of postfix: | ||
- | * If the value is long, it will exceed the text boundaries, and as such the tag won't be rendered. (Somewhat mitigated by having something like `[typeof | + | * If the value is long, it will often exceed the renderer' |
Pros of prefix: | Pros of prefix: | ||
- | * A lot of current types are already in the prefix form | + | * A lot of current types are already in the prefix form. |
Cons of prefix: | Cons of prefix: | ||
- | * Makes constructing some types harder (like "10 mm") | + | * Makes constructing some types harder (like "10 mm"). |
type-proposal.1754512905.txt.gz · Last modified: 2025/08/06 20:41 by smj-edison