externalstring and to-be-closed

38 views
Skip to first unread message

Marc Balmer

unread,
Feb 6, 2026, 9:34:50 AM (5 days ago) Feb 6
to lu...@googlegroups.com
Trying to better understand external strings…

Can external strings, pushed to a Lua state using lua_pushexternalstring(), somehow be marked as to-be-closed (<close> in Lua) so that the allocf function passed to lua_pushexternalstring() gets called when the variable goes out of scope and not only at garbage collection time?

- Marc

Sergey Zakharchenko

unread,
Feb 6, 2026, 9:44:45 AM (5 days ago) Feb 6
to lu...@googlegroups.com
Hello Marc,


On Fri, Feb 6, 2026, 17:34 Marc Balmer <mhba...@gmail.com> wrote:
Trying to better understand external strings…

Can external strings, pushed to a Lua state using lua_pushexternalstring(), somehow be marked as to-be-closed (<close> in Lua) so that  the allocf function passed to lua_pushexternalstring() gets called when the variable goes out of scope and not only at garbage collection time?

A similar suggestion was discussed in July and it looks impossible without seriuosly changing string semantics.

Best regards,

-- 
DoubleF
Reply all
Reply to author
Forward
0 new messages