Clarify uniqueness

This commit is contained in:
Qualadore 2023-07-11 10:59:34 +00:00
parent d07a8e531d
commit c014c6a882
No known key found for this signature in database
GPG key ID: 1F55CCE2A638948F

View file

@ -2,7 +2,7 @@
## Summary ## Summary
Add `debug.id` which accepts a value and always returns the identifier unique to that value. Add `debug.id` which accepts a value and always returns the identifier unique to all values that haven't been garbage collected.
## Motivation ## Motivation
@ -12,7 +12,7 @@ When debugging, it is often useful to compare identity. Usually `print` will pri
## Design ## Design
`debug.id(value: string | userdata | table | thread | function): number` always returns the identifier unique to that value, and is not possible to override. `debug.id(value: string | userdata | table | thread | function): number` always returns the identifier unique to that value, and is not possible to override. Uniqueness is only guaranteed for values that haven't been garbage collected.
While tables and userdata have individualized metatables, also allowing functions and threads to be passed to `debug.id` would let their type-level `__tostring` be redefined. Strings are useful to accept because of long, similar strings. While tables and userdata have individualized metatables, also allowing functions and threads to be passed to `debug.id` would let their type-level `__tostring` be redefined. Strings are useful to accept because of long, similar strings.