JeffreyBenjaminBrown / hode

rslt, take five-ish
GNU General Public License v3.0
147 stars 4 forks source link

`Addr` should be a UUID #8

Open JeffreyBenjaminBrown opened 4 years ago

JeffreyBenjaminBrown commented 4 years ago

Using a UUID instead of an Int for the Addr type synonym would be better, as they are less prone to collision[1].

There are some conditions under which a user needs to actually know the address of an expression -- when deleting an Expr, for example. If Addr was a UUID, that would become awkward. A solution would be for the UI to define temporary low-digit synonyms for each Addr.

Footnote 1

(If a billion people each had a billion 128-bit UUIDs, the probability that any two UUIDs would be the same is about 0.15%:

> let n = 1e9**2 in 1 - exp( -(n**2) / (2 * 2**128) )
1.4682889460021498e-3

See the approximations section of the Wikipedia article on the birthday problem for where that formula comes from.)

no-identd commented 4 years ago

In case you want sortability, you'll probably want something like this to generate the UUIDs:

https://docs.microsoft.com/en-us/sql/t-sql/functions/newsequentialid-transact-sql

The byte shuffling & reason for it gets explained here:

https://docs.microsoft.com/en-us/archive/blogs/dbrowne/how-to-generate-sequential-guids-for-sql-server-in-net