Page MenuHomePhabricator

Shared global scope + implicit globals are a bad fit for wiki templates
Closed, ResolvedPublic

Description

It's inelegant to have to explicitly export things when there is already a "local" keyword. Why not export everything non-local by default?

If that is not possible for some reason, why not initialize an empty table for each module, assign it a reserved name, and export it implicitly? I imagine something like this implicitly wrapping each module:

local module = {};
<<module code>>
return module;


Version: unspecified
Severity: normal

Details

Reference
bz39494

Event Timeline

bzimport raised the priority of this task from to Low.Nov 22 2014, 12:59 AM
bzimport added a project: Scribunto.
bzimport set Reference to bz39494.
bzimport added a subscriber: Unknown Object (MLST).

If you called the default module object "this", it'd behave exactly like a JavaScript constructor. I'd still prefer the former option, though (i.e., relying on the local keyword to assign to module or global scope).

I did not articulate myself clearly in this report and bug 39610 has meanwhile become the locus of the conversation about scoping, so I'm closing this as a duplicate of that bug.

  • This bug has been marked as a duplicate of bug 39610 ***