Thread Tools Display Modes
Prev Previous Post   Next Post Next
05-08-15, 09:53 PM   #1
Digital_Utopia
A Flamescale Wyrmkin
 
Digital_Utopia's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2012
Posts: 110
A question for the Lua experts

I'm not very knowledgeable about what goes on underneath Lua's hood, so I'm hoping that someone who is, can clear something up for me.

It seems that no matter where I go, any discussion regarding pseudo namespaces/"static" classes in Lua, always boils down to something like this:

Code:
foo = {}
foo.a = "something"
foo.b = function() return "bob" end
I mean, basic - straightforward assignments.

But, see - I was playing around today, and noticed that it's possible to pull off a Javascript Module Pattern in Lua.
eg:

Code:
foo = (function()
     local a="something";
     function b()
          return "bob";
     end
     return{
          ["a"] = a,
          ["b"] = b,
     }
end)();
I mean obviously, for something as simple as the example, it's a bit overkill - but why isn't this a thing? Is there some performance hit involved? Or is it just a case of what people are used to?
__________________
  Reply With Quote
 

WoWInterface » Developer Discussions » General Authoring Discussion » A question for the Lua experts

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off