zeeboo | 2 months ago | on: The most famous transcendental numbers
zeeboo's comments
zeeboo | 1 year ago | on: Good-bye core types; Hello Go as we know and love it
zeeboo | 2 years ago | on: What is gained and lost with 63-bit integers? (2014)
zeeboo | 3 years ago | on: Go 1.20 released
zeeboo | 4 years ago | on: The Ironclad Argument Against Racism
zeeboo | 4 years ago | on: How Go mitigates supply chain attacks
zeeboo | 4 years ago | on: How Go mitigates supply chain attacks
zeeboo | 4 years ago | on: How Go mitigates supply chain attacks
The reason why older is better than newer has more to do with the fact that the author has actually tested their software with that specific version, and so there's more of a chance that it actually works as they intended.
zeeboo | 4 years ago | on: A new ProtoBuf generator for Go
zeeboo | 4 years ago | on: DRPC: A full replacement for gRPC in under 3kloc
Granted, one person's unnecessary is another person's necessary. But since DRPC has a modular design based on small interfaces, many features that are rarely used in gRPC can be excluded and left up to third parties to implement if they want.
zeeboo | 5 years ago | on: Proposal: expression to create pointer to simple types
zeeboo | 5 years ago | on: Proposal: expression to create pointer to simple types
zeeboo | 5 years ago | on: Proposal: expression to create pointer to simple types
Maybe to you, but to me, a pointer going from modifying the value inside of the map to no longer modifying the value inside of the map during any operation is quite a bit different than requiring a reassignment of the slice header. In other words:
x := make([]int, 5)
y := &x[0]
x[3] = 8
*y = 5
print(x[0]) // always prints 5
as compared to x := make(map[int]int)
y = &x[0] // btw, is this even valid? let's assume it implicitly does x[0] = 0
x[3] = 8
*y = 5
print(x[0]) // maybe sometimes prints 5?
is meaningfully different. For slices, we know that x[0] will always print 5 until the value of x is reassigned in some way.> Also technically nothing prevents a GC from reallocating the slice.
It would have the same problem the map does: you'd have to update any pointers into the slice to point to the new slice, otherwise the semantics of the program changes. That is not something the GC currently does, and would require an awful lot of metadata and scanning.
> I've never heard of a hashmap implementation which would do otherwise.
I'm not sure what this is referring to. I agree every map implementation has to reallocate the backing store of values periodically. I was trying to say that keeping the flexibility to reallocate the backing store of the map during GC means that you cannot choose the "writes through pointer are observed in the map" option (at least without a lot of complication around updating pointers) because as a programmer, you would not be able to know if it would do that or not, which is a fairly useless primitive.
zeeboo | 5 years ago | on: Proposal: expression to create pointer to simple types
That's true, but I don't think it's very comparable to slices. With slices, you have to explicitly reallocate either by creating a whole new slice or using append. Reslicing, indexing, or other operations do not reallocate. On the other hand, maps may end up resizing on any operation that involves them, or even theoretically in the background without any operations (during GC, for example). It would be unfortunate to lose that implementation flexibility, and keeping it means that you're essentially picking the "make a copy" option.
zeeboo | 5 years ago | on: Proposal: expression to create pointer to simple types
x := make(map[int]int)
x[0] = 5
y := &x[0]
*y = 10
print(x[0]) // 5 or 10?
x[0] = 6
print(*y) // 6 or 10?
// force the map to grow and reallocate the buckets
for j := 1; j < 100; j++ {
x[j] = j
}
*y = 11
print(x[0]) // 5, 6, 10, or 11?
The crux of the problem is answering what y actually points at: the value in the map bucket, or some freshly allocated value? There are problems with whichever one you pick.edit: changed the second print to *y instead of x[0]. thanks masklinn for catching this error.
zeeboo | 5 years ago | on: Proposal: expression to create pointer to simple types
zeeboo | 5 years ago | on: netaddr.IP: a new IP address type for Go
zeeboo | 5 years ago | on: netaddr.IP: a new IP address type for Go
zeeboo | 5 years ago | on: netaddr.IP: a new IP address type for Go
zeeboo | 5 years ago | on: netaddr.IP: a new IP address type for Go
I think your statement reflects more on your own biases than reality.