Thread Tools Display Modes
12-04-09, 04:20 AM   #1
nightcracker
A Molten Giant
 
nightcracker's Avatar
AddOn Author - Click to view addons
Join Date: Sep 2009
Posts: 716
Semicolon

Hi all!
To instantly get to the point, is there any use for the semicolon (;)? I know that it kind of "forces" an end of line. But is there any situation it is needed?

Thanks in advance,
Nightcracker
__________________
Three things are certain,
Death, taxes and site not found,
You, victim of one.
  Reply With Quote
12-04-09, 04:28 AM   #2
Katae
A Cobalt Mageweaver
AddOn Author - Click to view addons
Join Date: Jun 2007
Posts: 208
Not in any cases I've had to deal with. Mashed up one liners don't even need semicolons to indicate a new line, but they do help with readability.
  Reply With Quote
12-04-09, 02:21 PM   #3
Seerah
Fishing Trainer
 
Seerah's Avatar
WoWInterface Super Mod
Featured
Join Date: Oct 2006
Posts: 10,860
Any semicolons you see in Lua code come from authors who either a) have a background in a different coding language which uses semicolons, or b) learned Lua by looking at code written by the authors in a.

Semicolons don't hurt anything - as Katae pointed out, sometimes people use them for readability. But they're 100% not necessary (unless I'm missing something, in which case they'd be 99% not necessary ).
__________________
"You'd be surprised how many people violate this simple principle every day of their lives and try to fit square pegs into round holes, ignoring the clear reality that Things Are As They Are." -Benjamin Hoff, The Tao of Pooh

  Reply With Quote
12-04-09, 02:27 PM   #4
haste
Featured Artist
 
haste's Avatar
Premium Member
Featured
Join Date: Dec 2005
Posts: 1,027
Sometimes you'll which it was enforced however...
__________________
「貴方は1人じゃないよ」
  Reply With Quote
12-04-09, 02:46 PM   #5
Seerah
Fishing Trainer
 
Seerah's Avatar
WoWInterface Super Mod
Featured
Join Date: Oct 2006
Posts: 10,860
/me is confused

What does having a semicolon ( ; ) at the end of a line have to do with your forgetting to separate your vars with a comma?
__________________
"You'd be surprised how many people violate this simple principle every day of their lives and try to fit square pegs into round holes, ignoring the clear reality that Things Are As They Are." -Benjamin Hoff, The Tao of Pooh

  Reply With Quote
12-04-09, 03:02 PM   #6
Maul
Ion Engines, Engage!
 
Maul's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2005
Posts: 401
I use them to condense 2 or 3 short lines into one line -

r = 255
g = 255
b = 255

r = 255; g = 255; b =255
__________________

Twitter: @IonMaul | Windows Live: [email protected] | Google Talk: [email protected]
  Reply With Quote
12-04-09, 03:36 PM   #7
haste
Featured Artist
 
haste's Avatar
Premium Member
Featured
Join Date: Dec 2005
Posts: 1,027
Originally Posted by Seerah View Post
/me is confused

What does having a semicolon ( ; ) at the end of a line have to do with your forgetting to separate your vars with a comma?
If they had been enforced that would have been a syntax error.
__________________
「貴方は1人じゃないよ」
  Reply With Quote
12-04-09, 03:39 PM   #8
nightcracker
A Molten Giant
 
nightcracker's Avatar
AddOn Author - Click to view addons
Join Date: Sep 2009
Posts: 716
Originally Posted by Maul View Post
I use them to condense 2 or 3 short lines into one line -

r = 255
g = 255
b = 255

r = 255; g = 255; b =255
r, g, b = 255, 255, 255
__________________
Three things are certain,
Death, taxes and site not found,
You, victim of one.
  Reply With Quote
12-04-09, 04:16 PM   #9
lilsparky
A Flamescale Wyrmkin
AddOn Author - Click to view addons
Join Date: Oct 2007
Posts: 117
people put ;'s simply because that's their habit and it helps keep them sane when coding in lua then going back and coding in C.
  Reply With Quote
12-04-09, 04:31 PM   #10
Torhal
A Pyroguard Emberseer
 
Torhal's Avatar
AddOn Author - Click to view addons
Join Date: Aug 2008
Posts: 1,196
Semicolons seem like such little consolation when curly-braces mean table creation rather than scope and therefore you must use "then" and "end".
__________________
Whenever someone says "pls" because it's shorter than "please", I say "no" because it's shorter than "yes".

Author of NPCScan and many other AddOns.
  Reply With Quote
12-04-09, 04:45 PM   #11
Maul
Ion Engines, Engage!
 
Maul's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2005
Posts: 401
Originally Posted by nightcracker View Post
r, g, b = 255, 255, 255
I suppose that was not a good example

I still use them to make things condensed where my OCD thinks multiple lines are sticking out like a sore thumb -

macroButton_ShowGrid(self); self.hidegrid = true
__________________

Twitter: @IonMaul | Windows Live: [email protected] | Google Talk: [email protected]
  Reply With Quote
12-04-09, 05:44 PM   #12
wurmfood
A Flamescale Wyrmkin
AddOn Author - Click to view addons
Join Date: Apr 2009
Posts: 122
Originally Posted by Torhal View Post
Semicolons seem like such little consolation when curly-braces mean table creation rather than scope and therefore you must use "then" and "end".
The scope and script aspect were the hardest for me to get used to. The endline stuff wasn't too bad, though having gotten used to not using it made function consolidation more annoying. It's a fun language once you get used to it, but moving to and from C-based languages can definitely be confusing.
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » Semicolon


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