Thread Tools Display Modes
11-03-14, 01:45 AM   #1
AlleyKat
A Warpwood Thunder Caller
 
AlleyKat's Avatar
AddOn Author - Click to view addons
Join Date: Jan 2010
Posts: 93
In my way I can access to my frame via
Code:
local title, M = ...;
in your way I must

Code:
local title = ...;
local M = _G[title];

Last edited by AlleyKat : 11-03-14 at 01:48 AM.
  Reply With Quote
11-03-14, 05:24 AM   #2
Lombra
A Molten Giant
 
Lombra's Avatar
AddOn Author - Click to view addons
Join Date: Nov 2006
Posts: 554
Originally Posted by AlleyKat View Post
In my way I can access to my frame via
Code:
local title, M = ...;
in your way I must

Code:
local title = ...;
local M = _G[title];
Just do this then:
Code:
local title, M = ...;
M.frame = CreateFrame("Frame")
__________________
Grab your sword and fight the Horde!
  Reply With Quote
11-03-14, 06:25 AM   #3
Phanx
Cat.
 
Phanx's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 5,617
Originally Posted by AlleyKat View Post
in your way I must
Code:
local title = ...;
local M = _G[title];
So... adding one line of code is worse, in your mind, than adding multiple extra lines of code and adding the overhead of multiple metatables in your original example?

Originally Posted by AlleyKat View Post
Standard metatable functions
in frame case we redirect all get and set notfound operations to build-in
in build-in we adding frame api
and now we don't care what table to use, coz they are same
This is just bad programming. If you want to be able to use two variables to refer to the "same" object, just create one object and point two variables to it. Creating two objects and using metatables to make them act like the same object is just ... I don't even know where you came up with such a convoluted idea. There's no benefit to doing this whatsoever. Then again, there's no benefit to having two variables in the same scope that refer to the "same" object, either, other than purposefully making your code more complicated and difficult to read.
__________________
Retired author of too many addons.
Message me if you're interested in taking over one of my addons.
Don’t message me about addon bugs or programming questions.
  Reply With Quote
11-03-14, 09:02 AM   #4
AlleyKat
A Warpwood Thunder Caller
 
AlleyKat's Avatar
AddOn Author - Click to view addons
Join Date: Jan 2010
Posts: 93
There are no objects in lua, frame is metatable with userdata, where userdata is real frame object, we are not coping userdata, so we are not creating two objects, we are just using object from another instance (another table)

Last edited by AlleyKat : 11-03-14 at 09:28 AM.
  Reply With Quote
11-03-14, 10:18 AM   #5
Phanx
Cat.
 
Phanx's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 5,617
Yes, but for all practical purposes, they are two different objects in Lua:

Code:
local t = {}
local f = CreateFrame("Frame")
print(t == f)
That will print "false" even after all you apply all your pointless hacks. You're completely missing the forest for the trees here.
__________________
Retired author of too many addons.
Message me if you're interested in taking over one of my addons.
Don’t message me about addon bugs or programming questions.
  Reply With Quote
11-03-14, 07:09 PM   #6
AlleyKat
A Warpwood Thunder Caller
 
AlleyKat's Avatar
AddOn Author - Click to view addons
Join Date: Jan 2010
Posts: 93
I said about userdata, not tables
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » Global vars ?


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