|
| 19 Dec 2012 08:03 PM |
This thread is to talk about the pros and/or cons of Lua 5.2. Roblox runs 5.1, if you didnt already know. I also want to ask you a question. Along the 5.2 release(or is it still beta?), came the "go to", or as in its proper syntax "goto" statement. Do you see any pros? I dont think it was even necessary to bring into Lua, you can do the same with booleans and if-statements. Heres an example of the "goto" statement.
function fact_(n, ans) ::call:: if n == 0 then return ans else n, ans = n - 1, ans * n goto call end end print(fact_(5, 1)) --> 120 |
|
|
| Report Abuse |
|
|
|
| 19 Dec 2012 08:09 PM |
Pros: There's a 2 in the name
Cons: goto sucks |
|
|
| Report Abuse |
|
|
|
| 19 Dec 2012 08:11 PM |
| Well, atleast you said it out loud :D |
|
|
| Report Abuse |
|
|
|
| 19 Dec 2012 08:15 PM |
goto is for people that want to use functions but don't want to write readable code
goto is just functions without functions
goto is the hipster's while
goto will not get you a job
goto isn't even a real word |
|
|
| Report Abuse |
|
|
|
| 19 Dec 2012 08:17 PM |
"goto is bad"
yeah, okay, buddy
Mind telling me why? |
|
|
| Report Abuse |
|
|
UnAdmin
|
  |
| Joined: 10 Jul 2012 |
| Total Posts: 4706 |
|
|
| 19 Dec 2012 08:19 PM |
Brb got to goto the store. I'll be there a while.
~Domo Arigoto Mr. Roboto |
|
|
| Report Abuse |
|
|
|
| 19 Dec 2012 08:22 PM |
| It sounds like they ripped goto from Batch. |
|
|
| Report Abuse |
|
|
UnAdmin
|
  |
| Joined: 10 Jul 2012 |
| Total Posts: 4706 |
|
|
| 19 Dec 2012 08:28 PM |
Get it? I added while too.
~Domo Arigoto Mr. Roboto |
|
|
| Report Abuse |
|
|
|
| 19 Dec 2012 08:28 PM |
"Mind telling me why?"
It is exactly like functions except requires extra work if you want to go backwards
function hi() print("ok") end
hi()
-- or
::hi:: print("ok") did_hi = true
if not did_hi then goto hi end
---- or it is just another way to use while
x=1 while x < 10 do wait() x=x+1 end
-- or
x=1 ::hi:: wait() x=x+1 if x < 10 then goto hi
and if you want to go forward, you lose all sense of flow control because you're skipping code, and there's no reason to do that if you don't have unnecessary code. The fact that you had unnecessary code at all meant that you already had no idea what you were doing and you should probably rewrite that entire portion of your script. |
|
|
| Report Abuse |
|
|
Aerideyn
|
  |
| Joined: 16 Jan 2010 |
| Total Posts: 1882 |
|
|
| 19 Dec 2012 08:30 PM |
goto is nice to break straight out of multiple nested for loops (if something if found for example) where the alternative would be to set a variable for the loops above it to check each iteration and break if it is true..
beyond that - i don't know of any situation where goto actually improves readability and tidiness at all. |
|
|
| Report Abuse |
|
|
|
| 19 Dec 2012 08:33 PM |
"goto is nice to break straight out of multiple nested for loops (if something if found for example) where the alternative would be to set a variable for the loops above it to check each iteration and break if it is true.."
Wouldn't you still have to check variables even if you were using goto? |
|
|
| Report Abuse |
|
|
Tenal
|
  |
| Joined: 15 May 2011 |
| Total Posts: 18684 |
|
|
| 19 Dec 2012 08:48 PM |
| >mfw kids hate on goto even though it's not 100% bad |
|
|
| Report Abuse |
|
|
oxcool1
|
  |
| Joined: 05 Nov 2009 |
| Total Posts: 15444 |
|
| |
|
oxcool1
|
  |
| Joined: 05 Nov 2009 |
| Total Posts: 15444 |
|
| |
|
Tenal
|
  |
| Joined: 15 May 2011 |
| Total Posts: 18684 |
|
|
| 19 Dec 2012 08:59 PM |
@oxcool >implying I'm welcome in C&G Y'see, just because I may disagree with literally all of the people in this forum doesn't make me belong in C&G (which makes no sense considering the fact that people are allowed to forum in multiple forums and also makes no sense because clans have nothing to do with the subject).
Now that I've knocked some actual logic onto you, what is not only prettier, but more efficient?
if true then ::tacos:: if true then if true then if not true then goto tacos end end end end
or..
if true then local function tacos() ..and you probably get the point by now.
If you can notice, I had to spend a minute brainstorming how the structuring for the second script would have looked like, and I still didn't manage to successfully finish it and make it work. The first example was simple and straightforward, and what took me the longest time to write was not the structuring of the script but instead the way of how gotos are written. |
|
|
| Report Abuse |
|
|
Merely
|
  |
| Joined: 07 Dec 2010 |
| Total Posts: 17266 |
|
|
| 19 Dec 2012 09:05 PM |
Y'see, just because I may have a lot of virtual wealth on Roblox doesn't mean I'm automatically a snotty, arrogant brat who needs to be called that every time I visit Scripters. People are allowed to forum in multiple forums and also makes no sense because robux and limiteds have nothing to do with the subject.
Now that I've knocked some actual logic onto you, why do you think gotos are necessary in Lua? |
|
|
| Report Abuse |
|
|
|
| 19 Dec 2012 09:05 PM |
| In actual programming, the usage goto is frowned upon. I don't see why Lua added it. |
|
|
| Report Abuse |
|
|
Tenal
|
  |
| Joined: 15 May 2011 |
| Total Posts: 18684 |
|
|
| 19 Dec 2012 09:06 PM |
@Merely Did I mention *anything* about you being another one of those snooty Telamon worshiping rich kid? |
|
|
| Report Abuse |
|
|
Merely
|
  |
| Joined: 07 Dec 2010 |
| Total Posts: 17266 |
|
|
| 19 Dec 2012 09:08 PM |
| @Tenal - Almost every time I post here, you say something about LMaD or robux or virtual items. You need to stop that, you don't like it when people tell you to go back to C&G, so why do you tell me to go back to LMaD? |
|
|
| Report Abuse |
|
|
|
| 19 Dec 2012 09:08 PM |
| You can do the exact same with a while-loop, so whats the difference? I am trying to stay neutral in this subject, but I find it hard to put "goto" to any use |
|
|
| Report Abuse |
|
|
Tenal
|
  |
| Joined: 15 May 2011 |
| Total Posts: 18684 |
|
|
| 19 Dec 2012 09:09 PM |
What I'm trying to say is that people in C&G equally hate me as much as the people in Scripters do. Apparently they are mature enough to simply ignore me as if I don't exist. |
|
|
| Report Abuse |
|
|
Aerideyn
|
  |
| Joined: 16 Jan 2010 |
| Total Posts: 1882 |
|
|
| 19 Dec 2012 09:10 PM |
well think of it like this:
Without GoTo:
function findFirstValidPoint() breakout = false for x = 1,10000 do if breakout == true then break end for y = 1,10000 do if breakout == true then break end for z = 1,10000 do if breakout == true then break end point = TestIfPointIsWhatWeWant(x,y,z) if point == true then breakout = true end end end end return point end
With GoTo
function findFirstValidPoint() for x = 1,10000 do for y = 1,10000 do for z = 1,10000 do point = TestIfPointIsWhatWeWant(x,y,z) if point == true then goto onBreakOut end end end end ::onBreakOut:: return point end |
|
|
| Report Abuse |
|
|
Tenal
|
  |
| Joined: 15 May 2011 |
| Total Posts: 18684 |
|
|
| 19 Dec 2012 09:19 PM |
@Stealth In that case, what's the point of if statements?
if true then print() end
is the same thing as
while true do print() break end
The idea is, gotos make life easier (and more efficient!) in certain cases. |
|
|
| Report Abuse |
|
|
|
| 19 Dec 2012 09:20 PM |
>this thread again
tl;dr goto haters are ignorant bigots |
|
|
| Report Abuse |
|
|
Lombardo3
|
  |
| Joined: 15 Dec 2012 |
| Total Posts: 271 |
|
|
| 19 Dec 2012 09:23 PM |
| Goto is just like x86 Assembly jmp. What's the problem with digesting it? It just "Goes to" the specified label. |
|
|
| Report Abuse |
|
|