Re: Its okey or not?

"blogdron (BLOGDRON)" <[email protected]>
Newsgroups gmane.comp.lang.lua.general
Message-ID <[email protected]>
Yes, there's a first time for everything =) Thanks, I'll read your text. It's 
strange that I haven't noticed or encountered this before; I've been 
writing in Lua for several years now. LOL

понедельник, 9 февраля 2026 г. в 19:29:22 UTC+3, Lars Müller: 

> What you're seeing is the difference between "nothing" (the empty vararg) 
> and "nil".
> In general, a vararg containing some nils is not the same as an empty 
> vararg.
> Thus varargs are not quite the same as tables, and you need to store their 
> length when storing them in a table.
>
> Have you ever wondered how "print()" prints just an empty line, whereas 
> "print(nil)" prints "nil"? Well, now you know :)
>
> I have a blog post that covers this: 
> https://luatic.dev/posts/2025-04-12-lua-misconceptions/#varargs
>
> - Lars
>
> On Mon, Feb 9 2026 at 08:21:45 -08:00:00, blogdron (BLOGDRON) <
> [email protected]> wrote:
>
> Test 1 OK
> type(((''):byte())) 
>
> Test 2 ERR bad argument #1 to 'type' (value expected)
> type((''):byte()) 
>
> Test 3 OK
> string.byte = function (s) return nil  end
> type((''):byte())
>
> Test 4 ERR bad argument #1 to 'type' (value expected)
> string.byte = function (s) return  end
> type((''):byte())
>
> "function x() return end" not equal "function x() return nil end"? 
> This case is for all Lua versions.  
>
> This behavior is probably well-known, but I've never encountered it before. I 
> thought if a type received a nil, it would simply return a nil, but 
> sometimes there's literally nothing there, not a nil. Now I'm paranoid 
> about wrapping everything in parentheses, even if the function returns only 
> one value :D  haha and/or if function return nothing im force wrote return 
> nil
>
> I thought I'd share. It seems I still don't know Lua ::)
>
> -- 
> 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/ff009071-c489-4e98-9bc6-4046fcce63dbn%40googlegroups.com 
> <https://groups.google.com/d/msgid/lua-l/ff009071-c489-4e98-9bc6-4046fcce63dbn%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
>
>

-- 
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/b91e31e7-d5e7-42b9-9b72-11fe28bdc7ban%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.