11 ms·
Because they're not the same thing. One is a record/field lookup, the other is a map lookup. For record lookups, there is no key. What would you pass to the ge
by wtetzner 11y ago
Because they're not the same thing. One is a record/field lookup, the other is a map lookup.
For record lookups, there is no key. What would you pass to the get function as the key? A string? Now the compiler can't reason about it at compile time. It turns into a runtime lookup. In languages like OCaml, there is no reflection, so there is no way to do a runtime lookup of a key. It has to know the name at compile time, and the name is then translated to a byte offset into the record.