Hacker Newsnew | past | comments | ask | show | jobs | submit | occamrazor's commentslogin

I’m curious, what was the rationale for forbidding it?

I interpret this as asking "why can't you get the address of a value in a map?"

There are two reasons, and we could also ask "why can't you get the address of a key in a map?"

The first reason is flexibility in implementation. Maps are fairly opaque, their implementation details are some of the least exposed in the language (see also: channels), and this is done on purpose to discourage users of the language from mucking with the internals and thus making it harder for the developers of the language to change them. Denying access to internal pointers makes it a lot easier to change the implementation of a map.

The second reason is that most ways of implementing a map move the value around copiously. Supposing you could get a pointer p := &m[k] for some map m and key k, what would it even point to? Just the value position of a slot in a hash table. If you do delete(m, k) now what does it point to? If you assign m[k2] but hash(k2) == hash(k) and the map handles the collision by picking a new slot for k, now what does it point to? And eventually you may assign so many keys that the old hash table is too small and so a new one somewhere else in memory has to be allocated, leaving the pointer dangling.

While the above also apply to pointers-to-keys, there is another reason you can't get one of those: if you mutated the key, you would (with high probability) violate the core invariant of a hash table, namely that the slot for an entry is determined exactly by the hash of its key. The exact consequences of violating this would depend on the specific implementation, but they are mostly quite bad.

For comparison, Rust, with its strong control over mutability and lifetimes, can give you safe references to the entries of a HashMap in a way Go cannot.


I was burnt by the mutability of keys in go maps a few months ago, I'm not sure exactly how go handles it internally but it ended up with the map growing and duplicate keys in the key list when looking at it with a debugger.

The footgun was that url.QueryUnescape returned a slice of the original string if nothing needed to be escaped so if the original string was modified, it would modify the key in the map if you put the returned slice directly into the map.


This sounds like a bug, whether it be in your code, the map implementation, or even the debugger. Map keys are not mutable, and neither are strings.

This shouldn't be a race condition, reads were done by taking a RLock() from a mutex in a struct with the map, and defer RUnlock(), writes were similar where a Lock() was taken on the same mutex with a defer Unlock(). All these functions did was get/set values in the map and operated on a struct with just a mutex and the map. Unless I have a fundamental misunderstanding of how to use mutexes to avoid race conditions this shouldn't have been the case. This also feels a lot like a llm response with the Hypotheses section.

edit: this part below was originally a part of the comment I'm replying to

Hypotheses: you were modifying the map in another goroutine (do not share maps between goroutines unless they all treat it as read-only), the map implementation had some short-circuit logic for strings which was broken (file a bug report/it's probably already fixed), the debugger paused execution at an unsafe location (e.g. in the middle of non-user code), or the debugger incorrectly interpreted the contents of the map.


That just means fiber is a bad library that abuses unsafe, resulting in real bugs.

Just how are you modifying strings? Cause that's your bug to fix.

That was probably done by fiber[1] the code specifically took the param from it in the function passed to the Get(path string, handlers ...Handler) Router function. c is the *fiber.Ctx passed by fiber to the handler. My code took the string from c.Param("name") passed it to url.QueryUnescape then another function which had a mutex around setting the key/value in the map. I got the hint it was slices and something modifying the keys when I found truncated keys in the key list.

My guess is fiber used the same string for the param to avoid allocations. The fix for it is just to create a copy of the string with strings.Clone() to ensure it does not get mutated when it is used as a key. I understand it was an issue with my code, it just wasn't something I expected to be the case so it took several hours and using the debugger to find the root cause. Probably didn't help that a lot of the code was generated by Grok-4-Code/Sonic as a vibe coding test when I decided to go back a few months later and try and fix some of the issues I had myself.

[1] https://github.com/gofiber/fiber


Go strings are supposed to be immutable.

I see that fiber goes behind your back and produces potentially mutable strings behind your back: https://github.com/gofiber/utils/blob/c338034/convert.go#L18

And… I actually don't have an issue with it to be honest. I've done the same myself.

But this mutability should never escape. I'd never persist in using a library that would let it escape. But apparently… it's intentional: https://github.com/gofiber/fiber/issues/185

Oh well. You get what you ask for. Please don't complain about maps if you're using a broken library.


Apple group of companies, rather than a specific legal entity. A common distinction in financial journalism.


Pretty sure the labor disputes in question are with a specific legal entity, the US corporation, and not any of its subsidiaries.


FYI: Lex, not Rex.

But a Rex Talionis is an interesting concept too.


Oops, brain fart. Fixing it, thanks!


On prompts only, with answers presumably from the teacher model (Gemini).

It was not trained or RLHFd on Arena replies or user preferences.


Yes, answers were distilled from a much stronger model. On the one hand, you can argue that this is exactly what the LMSYS, WildBench etc datasets are for (to improve performance/alignment on real-world use cases), but on the other hand, it's clear that training on the questions (most of which are repeatedly used by the (largely non-representative of general population) users of the ChatArena for comparing/testing models) makes ChatArena ELO less useful as a model comparison tool and artificially elevates Gemma 2's ChatArena score relative to its OOD performance.

At the end of the day, by optimizing for leaderboard scoring, it makes the leaderboard ranking less useful as a benchmark (Goodhart's law strikes again). The Gemma team obviously isn't the only one doing it, but it's important to be clear-eyed about the consequences.


How so? Maybe in the past, but nothing announced today is open.


For Tao, spending 10x time on aproof still means spending 5x less time than an average postdoc. He is incredibly fast and productive.


On all flights I have taken the flight attendants count the passengers on board before taxiing and check the lavatories. This method wouldn't have worked even with available free seats.


Just had to go back to the gate the other day because the manifest didn’t match the count. I can see them overlooking this with flippant flight attendants, especially on smaller flights, but on my flight we were next in line for take off when they sent us back to the gate. So we almost made it to the sky. Also, I don’t know what happened, they checked one seat and then we were off. Missed connecting flight because of it.


This is also for weight and balance / performance calculations. If the calculations are done for 150 passengers and you count only 149 (or 151), you can't legally take off without new paperwork.


Zopf means “braid” and it also denotes a medium-size bread type, made with some milk and glazed with yolk, shaped like a braid, traditionally eaten on Sunday.


I like:

- “open weights” for no training data and no restrictions on use,

- “weights available” for no training data and restrictions on use, like in this case.


It‘s more likely to be incompetence than malice: even their 73.7% is closer to 72% than to 74%.


Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: