WICG / uuid

UUID V4
Other
63 stars 10 forks source link

Describe algorithm for randomUUID #5

Closed bcoe closed 3 years ago

bcoe commented 3 years ago

We should, in steps, describe the algorithm for randomUUID(). Some good references for the level of detail we should use, and for the spec markup language are:

Open Question?

How detailed should we be?

Is it worth fully defining the v4 algorithm (given its simplicity), with direct reference to getRandomValues(), or

Should we just indicate that we return a DOMString, generated using the RFC4122.

Who'd like to write this part of the spec?

@broofa or @ctavan, either of you interested in writing up this part of the document?

domenic commented 3 years ago

Is it worth fully defining the v4 algorithm (given its simplicity), with direct reference to getRandomValues(),

This is attractive, especially for implementers. However, some caveats:

Should we just indicate that we return a DOMString, generated using the RFC4122.

This was my initial instinct before reading this issue. However, actually reading https://tools.ietf.org/html/rfc4122 made me reconsider. I can't find any reasonable algorithm in there; https://tools.ietf.org/html/rfc4122#section-4.4 seems almost useless in isolation, and rather non-algorithmic.

Plus, the entire RFC seems to be in terms of bits, not strings, so (unless I'm missing part of it) you'd need an algorithm for converting bit sequences into strings on top of RFC4122.

So, my instinct is now toward the first option.

bcoe commented 3 years ago

Plus, the entire RFC seems to be in terms of bits, not strings, so (unless I'm missing part of it) you'd need an algorithm for converting bit sequences into strings on top of RFC4122.

When I was reading through the spec today, I came across this section, which codifies the string representation.

Edit: added a note to the spec pointing to this section of RFC4122.