-
Notifications
You must be signed in to change notification settings - Fork 106
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
add max uuid with all bits set. #120
Comments
Hi @james-lawrence , thanks for the suggestion. Could you elaborate a little on the use cases such a constant might provide? The nil UUID is useful for modeling uninitialized uuids for certain situations, but I'm not sure intuitively what a max UUID would grant. Thanks! |
Thinking about this a bit, a value with all bits set won't be valid for all UUID versions. One specific edge case is the 4 bits that contain the UUID version. Currently, the highest published version is 5 (with 6 and 7 in draft), which is 0101. Setting those other 2 bits would create a version 16, which doesn't exist. |
Thinking about this a little more... because there are version specific bits in the UUID, this would imply that we'd need a maximum per version, no? |
Its useful for comparisons, ranges, etc. The utility of it has nothing to do with the method you use to generate uuids (dont need a definition per version). Its useful in the same way 0,max int/neg,pos infinity (both numerically and for timestamps). I use it a ton for signalling that a set is finished for example. (Since its the largest possible value in lexographical order) |
You're thinking too hard about what it means per a arbitrary spec definition vs the utility it has in code ;). |
Thanks, but if we chose to ignore the upstream RFCs that define UUIDs to create random functionality, that would be deleterious to the functionality of this package. Ill close this for now until there's additional interest. Thanks for the suggestion. |
@james-lawrence for me it's about correctness, not utility. A value with all bits set is not a valid UUID. Also, version 1-5 UUIDs are not sortable, so the concept of a "max" value doesn't make sense. If you want/need a sentinel value use I just don't think this provides enough value to offset these inconsistencies it introduces. |
@dylan-bourque because you're viewing it through the lens of an arbitrary specification vs the actual values being generated. which are 128 bits and have a natural order. through this lens the max value I described is always correct no matter what uuid version you'd use. you can't generate a uuid larger than it. @cameracker shrug your choice. thanks for listening. |
@cameracker The current rev for RFC 4122 does define, in sec 5.4. Max UUID the following:
|
Wow! I totally missed that. Thank you very much for identifying that. In that case, let's reopen and see if someone contributes :) I might throw it in there in a couple of weeks if I can dig up some time. Things to keep in mind:
|
@cameracker contribute being like the definition of the variable that represents the max uuid? |
the opposite of the nil, its useful constant to have around.
i'll also note both should be better served by functions as global vars are mutable.
The text was updated successfully, but these errors were encountered: