Jump to content

Talk:Z21

From Wikifunctions

Documentation

layout:
data:

Unit (Z21): a simple type that can take on only one form, one value, all copies being identical; a persistent copy of this value is at void (Z24); for 'unit of measure', see Wikidata quantity (Z6010)/Wikidata item reference (Z6091)

Wikidata Item (sitelink) unit type (Q1307872)Template:I18n/info/edit-on-wikidata
Enumeration members/options
Search for usages of this type
Queries for Function (Z8) declarations
() Z21 Search for "Z8K2 Z21" in mainspace
(Z21, ) Search for "Z8K1 Z17 Z1K1 Z17 Z17K1 Z21" in mainspace
(¬Z21, , Z21, ) Search for "Z17K1 Z21" -"Z8K1 Z17 Z1K1 Z17 Z17K1 Z21" in mainspace
(, Z21, ) Z21 Search for "Z8K2 Z21" "Z17K1 Z21" in mainspace
() <Z21>[] Search for "Z8K2 Z1K1 Z7 Z7K1 Z881 Z881K1 Z21" in mainspace
(, <Z21>[], ) Search for "Z17K1 Z1K1 Z7 Z7K1 Z881 Z881K1 Z21" in mainspace
(, <Z21>[], ) <Z21>[] Search for "Z8K2 Z1K1 Z7 Z7K1 Z881 Z881K1 Z21" "Z17K1 Z1K1 Z7 Z7K1 Z881 Z881K1 Z21" in mainspace
More info at WF:Find
[Create translatable long-form documentation to be included here]

No way to differentiate between different unit type

Unit type does not have identity or something like that that would allow to differentiate different kind of Unit object between them. Z30601 show that any unit is considered a void.

Or maybe that’s just the function that is mis-named and should be named "void type"?


(I’m used to Rust. Here, there are not really void, as it prefer to uses an enum with two value, one without the value, and one with the value, and the enum need to be deconstructed in some way, guaranteing you can’t access that absent value if it isn’t present)

(It does have unit type, thought. But they are type, not value. Of course, you can then instantiate a unit type. They are called zero-sized, due to fact they don’t need to allocate memory. And they are mostly usefull for certain specific complicated stuff with types and generics. Such as using typed Map to a typed Set, which is just a Map with a Zero-sized value, which can be turned into no-op)

(that is different than empty types, which can’t be allocated, and so can never exist. Usefull if you are forced to provide an error by the API, but your code is unfaillible. Not that it matter much when an empty type can implement pretty much all interfaces that doesn’t implement a function that create this type, and so the "!" type is used most of the time in those case.)

(that said. Rust is strongly typed. Unlike wikifunctions. As evidenced by the presence of reify and abstract that allow to create arbritrary invalid structure) Marius851000 (talk) 08:30, 15 December 2025 (UTC)Reply

Wikifunctions supports only a single object whose Type (Z4) is set to Z21. This follows from the fact that no keys are defined for that Type beyond the mandatory Z1K1 that identifies the object’s Type. There is therefore no notion of a “different kind of Unit object”, and no meaningful differentiation is possible.
It is not quite accurate to say that “any unit is considered a void”; rather, any valid representation of the Unit instance is necessarily void by definition, and all such representations are equivalent. In both theory and practice, “is void” and “object’s Type is Unit” are the same function, and this should be reflected in its aliases [to-do]. GrounderUK (talk) 11:51, 15 December 2025 (UTC)Reply