====== Type proposal ====== There's a bunch of informal types in folk, such as quads, spaces, libraries, etc. It would be useful to have a standard representation between different parts of the system, to aid in introspection and consistency. Goals: * Automatic visualization (รก la Glamorous Toolkit) * Type descriptions * Automatic preconditions and verification * Extensible (don't want to be locked in with a bad design) * Flexible (this is tcl after all) Non goals: * Complex types * Soundness * One Unified Type System Types will be tagged with their type name, and optionally with type parameters. ===== Basic operations ===== Types can be manually created with `[list typeName typeValue]`, or with helper functions like `[$box::typeName typeValue]`. Types are NOT verified when boxed. Types are unboxed using `[$unbox::typeName $thing]`. This is where values are verified, if a type verifier has been registered. To check if a type is a certain type, use `[$is::typeName $type]` or `[expr {[$typeName $type] == typeLookingFor}]`. 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 "m", and a type name for acceleration could be "{accel m s}" (note meters and seconds as type parameters). All the type parameters specific to the type, and should not be assumed to be referencing an existing type. Inline type names are a mixture of wildcards and symbol/number characters. For example, the type signature of acceleration could be expressed as "*/*^2". One thing that signature would match to is "m/s^2", with "m" and "s" as the types' parameters. The canonical form would be "{accel m s}". Not all types have inline representations. ===== 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? ===== I'm not sure which way to go. Pros of postfix: * Types like "10 mm" are automatically a two item list, and as such are a full type. Cons of postfix: * If the value is long, it will often exceed the renderer's boundaries, and as such the tag won't be seen. (Somewhat mitigated by having something like `[$typeName $foo]`) Pros of prefix: * A lot of current types are already in the prefix form. Cons of prefix: * Makes constructing some types harder (like "10 mm").