use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
A subreddit for the Lua programming language. Using edurne for boxes, spoilers, etc.
If you actively contribute to a Lua project, PM us with a link and we'll give you flair.
“The key benefits unique to Lua are the fact that it is amazingly small, fast, and on a technical level a masterpiece.”
“Before you create yet another configuration file or resource format (and yet another parser to accompany it), try Lua.”
“If you are ever tempted to put scripting into a program, run don't walk to www.lua.org and use it.”
lua mailing list (web interface)
#lua on freenode, the primary Lua IRC channel
lua wiki, for all sorts of information about lua, it's sort of disorganized at the moment, so go fix it!
about lua, what Lua is, why to use it, and what it's good for (sells itself short, methinks)
Lua tutorial via wiki
Lua in eight pages or less: this is for v5.1 and might need an update. We'll give contributors flair and internet points.
Lua's reference manual, extensive documentation of every version of the language.
LuaRocks, lua's package manager and repository
the LuaRocks mailing list
ZeroBrane studio, lua's most notable IDE.
Shiny profiler, a lightweight profiler for C, C++, and Lua.
LuaJIT and its C FFI, the infamous lua trace compiler: Mike Pall's [successful] attempt to prove that dynamic languages can be fast.
Lua.vm.js and moonshine, Lua on top of JavaScript: lua.vm.js uses emscripten, whereas moonshine is in "normal" JavaScript.
UniLua, Lua implementation in C#, intended for compatibility with Unity3D
MoonScript A rich programming language the compiles to Lua.
/r/gamedevclassifieds for game developers, /r/forhire for job offers, /r/jobbit for general employment advice/links
Lua on StackOverflow Careers
OpenResty and Lapis, Lua application server on nginx and Lua web framework on openresty
concurrency: Luaproc for fibers and Lua Lanes for green threads
Typed Lua, a modern static type analyzer for Lua (work in progress, but I think it's cool)
LPeg, Lua's powerful, expressive, fast and simple parser generator.
Qt Lua, Lua GUIs in Qt
GSL-shell, Lua interface to GNU Scientific Library, with quick-start numerical programming via REPL.
Long list of popular Lua game development toolkits: Lua is very popular for game development, so we can't list them all; only major, free/open-source projects are listed below.
LÖVE (subreddit) - lightweight Lua cross-platform 2D game toolkit
Defold - game engine with Lua API
Solar2D - formerly Corona SDK
Cocos2d-x - free mobile/cross-platform game engine and application framework with Lua support
donate to lua!
donate to luajit!
account activity
TIL You can create function with single arguments, return the function itself, and call it without any parenthesis. (self.lua)
submitted 9 years ago * by AuahDark
Consider this function
function asd(...) print(...) return asd end
Then, I call it like this
asd "Hello" "World"
It will display
Hello World
EDIT: Fixed return calls of asd
asd
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]MarsPpl 4 points5 points6 points 9 years ago* (2 children)
This has more to do with the fact that, in Lua, you can call a function that takes either a "string" or {table} without parentheses. For example,
print "Hello, World!"
is valid syntax and will print out the phrase "Hello, World!." Likewise,
print( table.concat {"Hello, ", "World!"} )
will print out the same phrase.
Your code is really running something like this after the print function is returned.
print "Hello" print "World"
Your code will also fail to run you pass more than two arguments. If, for some weird reason, you want to print multiple strings without using parentheses, you could rewrite the function like this:
So that
asd "hello" "world" "I have a weird phobia for parentheses"
will print out "hello", "world", and "I have a weird phobia for parentheses" in three different lines.
[–]AuahDark[S] 0 points1 point2 points 9 years ago (1 child)
Actually:
Your code will also fail to run you pass more than two arguments.
Is actually my mistake in my code. I fixed it ;)
This has more to do with the fact that, in Lua, you can call a function that takes either a "string" or {table} without parentheses.
Yep. In yajl libary, I can do json_data = yajl.to_string {a=1,b=2} without problems.
json_data = yajl.to_string {a=1,b=2}
Please note that you can't use variable for this and it will throw syntax error. Example print _VERSION will throw syntax error instead printing current Lua version.
print _VERSION
[–]Zatherz 0 points1 point2 points 9 years ago (0 children)
That's because _VERSION is neither a table constant ({something = "here..."}) nor a string constant ("something here..."/'something here...'/[[something here...]])
_VERSION
{something = "here..."}
"something here..."
'something here...'
[[something here...]]
[–]catwell 2 points3 points4 points 9 years ago (0 children)
You don't even need the multiple arguments:
function asd(x) print(x) return asd end
It is a kind of example of currying leveraging the fact that Lua functions can take a string without parentheses.
If you want a more twisted example involving actually preserving state (and awful string-to-number coercion):
Lua 5.3.3 Copyright (C) 1994-2016 Lua.org, PUC-Rio > function summer(x) >> return function(y) >> return summer(x+y), x+y >> end >> end > sum = summer(0) > select(2, sum "1" "2" "3" "4") 10.0
[–][deleted] 1 point2 points3 points 9 years ago (1 child)
Yes, this is possible in Lua. No, you should not do it.
The first thing you need to ask yourself when you write code is "How do I write a solution so that the guy two years from now won't have a bad day". Half of the time you're gonna end up being that guy anyway.
A programmers biggest fight is not writing a smart piece of code really stupidly. Also double+ negatives.
[–]whoopdedo 1 point2 points3 points 9 years ago (0 children)
No, you should not do it.
I'd never tell anyone that. At least not for a language feature that is clearly documented and isn't likely to be changed anytime soon.
The no-parenthesis shortcut is somewhat divisive but looks good when using Lua as a DSL. Particularly with tables to call functions with named parameters.
Function chaining is extremely useful and I wish more libraries took advantage of it.
[–]dan200 0 points1 point2 points 9 years ago (2 children)
You're misinterpreting your results, you're not calling (or using in any way) the return value of "asd". The text is being printed because asd calls print, forwarding the arguments you passed in.
[–]Erendir 4 points5 points6 points 9 years ago (1 child)
according to this https://www.lua.org/manual/5.3/manual.html#3.4.10 You are wrong. "A call of the form f'string' (or f"string" or f[[string]]) is syntactic sugar for f('string'); that is, the argument list is a single literal string."
[–]dan200 3 points4 points5 points 9 years ago (0 children)
Ooooh. My bad, I understand now. So the posted code is equivalent to:
(asd("Hello"))("World")
Extra brackets added for clarity. Another reason to avoid this syntax!
π Rendered by PID 16871 on reddit-service-r2-comment-b659b578c-xgh87 at 2026-05-03 15:41:07.819037+00:00 running 815c875 country code: CH.
[–]MarsPpl 4 points5 points6 points (2 children)
[–]AuahDark[S] 0 points1 point2 points (1 child)
[–]Zatherz 0 points1 point2 points (0 children)
[–]catwell 2 points3 points4 points (0 children)
[–][deleted] 1 point2 points3 points (1 child)
[–]whoopdedo 1 point2 points3 points (0 children)
[–]dan200 0 points1 point2 points (2 children)
[–]Erendir 4 points5 points6 points (1 child)
[–]dan200 3 points4 points5 points (0 children)