Re: __update metamethod — intercept wr ites to existing keys (patch for 5.5.0)

Yan <[email protected]>
Newsgroups gmane.comp.lang.lua.general
Message-ID <[email protected]>
It seems that in Lua 5.5, the `isrealasize` is no longer in use, and the 
corresponding comments should be able to be removed.

```
src/ltable.c:** dummy bit must be exchanged: The 'isrealasize' is not 
related
src/ltm.h:** the table is using the dummy node; bit 7 is used for 
'isrealasize'.)
```

在2026年4月8日星期三 UTC+8 18:23:46<chen chen> 写道:

Hello,

I've been thinking about the gap between `__newindex` (new keys only) and 
the need to intercept updates to existing keys. The proxy-table workaround 
works but has notable overhead. I put together a small patch (~95 lines) 
for Lua 5.5.0 to explore what a native solution might look like — I'd love 
to hear if this direction has been considered or if there are concerns I'm 
missing.

The patch adds an `__update` metamethod that fires when assigning to an 
existing key (including deletion via nil), complementing `__newindex`. 
Same-value writes are skipped as a fast-path optimization.

-- 
You received this message because you are subscribed to the Google Groups "lua-l" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].
To view this discussion visit https://groups.google.com/d/msgid/lua-l/fd95e974-b0db-483d-b91b-fc0350fed64cn%40googlegroups.com.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.