View Single Post
12-04-12, 12:11 AM   #5
Phanx
Cat.
 
Phanx's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 5,617
You should always define your variables as local. Global variables -- especially ones with single-letter or underscore names -- are extremely likely to collide (overwrite each other) and break addons, other macros, or even the default UI.

After the MoP release, for example, Blizzard was leaking a global variable _ from their UI code, which was colliding with leaked globals of the same name in many addons (it was pretty shocking to realize how many well-known addons are blatantly leaking globals), which was breaking everything.

Code:
/run local m,u,c,_={5,1,1,1,8,1,1,5,3,1,2}for i=0,GetNumGroupMembers()do u=i>0 and 'party'..i or 'player';_,_,c=UnitClass(u)SetRaidTarget(u,m[c])end
Still only 148 characters, giving you plenty of room for additions.

Also, you can omit spaces after closing brackets and parentheses to save more space. The green semicolon highlighted above is interchangable with a space, but I think using a semicolon improves readability and makes it less likely you'll accidentally delete the delimiter while trying to condense things.
__________________
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