V5.5 Manual: a small error and 2-3 wishes...

155 views
Skip to first unread message

bil til

unread,
Oct 9, 2025, 1:51:31 PM (9 days ago) Oct 9
to lu...@googlegroups.com
Your reference manual really is very impressively compact and correct.

So I am proud that I found a small error in your new "global
description" 2.2 under the example 2:
"...so the x in the left-hand side refers to the outside..." - here it
must say "in the RIGHT-hand side...".

I think this new global keyword is extremely useful for safe
programming in larger programs, and these 2 examples in the manual are
very helpful. Just in first reading I could not understand clearly
what you mean by "...inside the scope of any other global declaration"
("other" here can be interpreted ambigiously I think..). Maybe better
write it more in detail, e. g. : "...inside any scope, in which a
global variable is declared / in which 'global' is used".

Further wish concerning registry (4.3): It would be nice, if you could
add a sentence like "To protect userdata against garbage collection,
typically the user data will be written into the registry with
lua_setfield and a unique key. To free this link / allow garbage
collection after end of lifetime, write nil to this key." (as this is
very important and it is somehow nowhere clearly specified how to
delete a key, though of course "overwrite by nil" is quite clear).
Also maybe a short addition to the function description of
"lua_setfield" like this: "To delete a key entry from a table, use
lua_setfield and write nil to this key.".


Further I am quite curious about these "fixed strings" - I also saw
quite a bit of interesting things when I searched for the "variable
fixed" in the source code. Could you give some "example hints", in
which applications this typically should be very useful (and for which
applications they better should NOT be used?).

Thanks a lot for this great update... .

Roberto Ierusalimschy

unread,
Oct 12, 2025, 10:40:18 AM (6 days ago) Oct 12
to lu...@googlegroups.com
> So I am proud that I found a small error in your new "global
> description" 2.2 under the example 2:
> "...so the x in the left-hand side refers to the outside..." - here it
> must say "in the RIGHT-hand side...".

Thanks for the feedback, but this typo was already reported :-)
(Benoit Germain, 2 Jul 2025).

-- Roberto

Roberto Ierusalimschy

unread,
Oct 12, 2025, 10:45:49 AM (6 days ago) Oct 12
to lu...@googlegroups.com
> Further I am quite curious about these "fixed strings" - I also saw
> quite a bit of interesting things when I searched for the "variable
> fixed" in the source code. Could you give some "example hints", in
> which applications this typically should be very useful (and for which
> applications they better should NOT be used?).

By "fixed strings" do you mean "external strings"?

-- Roberto

bil til

unread,
Oct 12, 2025, 2:00:12 PM (6 days ago) Oct 12
to lu...@googlegroups.com
Yes, exactly, these are the "external strings" from manual I think.

(with "fixed" I meat the LuaStatus variable S.fixed, which I saw in
source code at quite a bit of interesting points concerning string
handling...).

Am So., 12. Okt. 2025 um 16:45 Uhr schrieb Roberto Ierusalimschy
<rob...@inf.puc-rio.br>:
> --
> 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 lua-l+un...@googlegroups.com.
> To view this discussion visit https://groups.google.com/d/msgid/lua-l/20251012144542.GC1068260%40arraial.inf.puc-rio.br.

Roberto Ierusalimschy

unread,
Oct 14, 2025, 2:01:36 PM (4 days ago) Oct 14
to lu...@googlegroups.com
I guess the main uses for external strings are all related to avoid
duplicating a large string with a new copy inside Lua.

One typical case is for large constant strings (e.g., bitmap images).
If the string is a constant in memory, Lua can use that same memory.
Another typical case is when C code has to allocate a buffer for the
string. Again, Lua can now reuse that same buffer, instead of making
a new copy. (The aux library now uses this technique for its string
buffers.)
> To view this discussion visit https://groups.google.com/d/msgid/lua-l/CAOnDXmF06uBFXadQzTY9AE9_wNwwkPubWJtC2p4A7Mcxy7OZfw%40mail.gmail.com.


-- Roberto

bil til

unread,
Oct 15, 2025, 1:52:35 AM (3 days ago) Oct 15
to lu...@googlegroups.com
Thank you for this clear example description. Possibly it would be
good to add such a "short example application sentence" also in the
ref manual in the description of function "lua_pushexternalstring"
(this is the only find result, looking for "external string" in the
ref manual).

Although of course reference manual is no "example storybook", for
such a special new variable type, such example of "large chunk of
memory, e. g. bitmap data" enhances understanding VERY much... .

Am Di., 14. Okt. 2025 um 20:01 Uhr schrieb Roberto Ierusalimschy
<rob...@inf.puc-rio.br>:
>
>
> One typical case is for large constant strings (e.g., bitmap images).
> If the string is a constant in memory, Lua can use that same memory.
> To unsubscribe from this group and stop receiving emails from it, send an email to lua-l+un...@googlegroups.com.
> To view this discussion visit https://groups.google.com/d/msgid/lua-l/20251014180127.GB1216041%40arraial.inf.puc-rio.br.
Reply all
Reply to author
Forward
0 new messages