Comments (3)
Yes, this is the documented behavior. The return statement is implied at the end of the block. It is mainly intended for top-level functions, but it's also useful in function bodies to push into package.preloaded.
from pluto.
The documentation only states
The return statement is automatically generated.
not if this happens at the end of the function or the end of a block (end of if, end of loop, end of switch).
So it does not state how my example is translated.
local function f(extended)
local function r1() end
if extended then
local function r2() end
return {r2=r2}
end
return {r1=r1}
end
or
local function f(extended)
local function r1() end
if extended then
local function r2() end
return {r1=r1, r2=r2}
end
return {r1=r1}
end
or
local function f(extended)
local exports = {}
local function r1() end
exports.r1 = r1
if extended then
local function r2() end
exports.r2 = r2
end
return exports
end
from pluto.
Well, it does have the example:
-- end of scope; 'return' is automatically generated
Maybe can be a bit more explicit.
from pluto.
Related Issues (20)
- Socket: Get remote address
- Failed to compile v0.9.1 on aarch64 linux. HOT 4
- Walrus operator regression with # operator
- Read of uninitialized variable
- New Warning: Attempted necromancy
- unreachable-code false-positive
- Better error message for invalid pipe operator syntax
- Lua header files cannot be included in a C project HOT 1
- Makefile with MinGW doesn't work (missing syslibs, etc.) HOT 2
- Get rid of LUA_USE_{POSIX,_LINUX} macros
- Requesting new feature 'async'. HOT 1
- Switch expression does not reset pinnedreg
- Switch statement parsing confusion
- Evaluation order of cases HOT 7
- Single fallthrough not allowed HOT 2
- Switch optimisation HOT 1
- Compatibility mode through executable name HOT 1
- segfault using string.dump and debug.getinfo HOT 1
- Null Coalesce Issue
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from pluto.