I wonât mind! My contract is that you can ping me liberally for whatever reason at whatever time without thinking twice, but, symmetrically, I reserve the right to not feel bad if I donât respond!
I wouldnât say that handles are particularly âhotâ in temporal locality sense â this is quite an old trick. I personally first learned about it from the famous https://gameprogrammingpatterns.com book (though I âspoke proseâ before that in the small, when working with graphs).
I would also maybe caution against talking about âthe Handle patternâ. As with terms like OOP and FP, this is a nebulous concept which can be applied to many quite different patterns & language features, and, while it is useful to refer to an element of this cloud, if you want to think about it, you have to think very concretely about a specific implementation, as details matter a lot. Are compressed pointers in HotSpot JVM handles?
From this point of view:
Zigâs enum(usize) { _ } is âa happy accident of language designâ (heard this memorable turn of the phrase from yole). It is a way to give an integer a fancy, snobbish top-hat, which prevents its mingling with lowly ints. I donât think _ was meant for that, I think the original use-case was âI want to have an enum with a list of known variants, but sometimes I want to store an unknown oneâ, and then later it was discovered that you can flip it around and make _ the 99% percent use-case.
This is a distinct feature than newtypes as found in Haskell/Go/Odin. Those languages allow for
type email = string;
but you canât const email = enum([]const u8) { _ } in Zig. At the same time, in low-level languages 99% of the time you want to newtype, you want to newtype a handle/index, so Zig gets to eat 80% of cake using 0% of extra features.
Adaâs Access types are something else entirely. They are nominal pointers and the interesting thing about them is not whether they are indexes or pointers internally (I actually donât know that!), but the associated memory management machinery. This is something Iâd love to understand better: how Ada actually manages memory? I think it sits âbetweenâ pure stack allocation and general RAII, but I am confused by everything Iâve read so far. I canât concisely explain how Ada does unbounded strings, how it returns dynamically-sized values.