generic image
Processing...
  • Games
  • Catalog
  • Develop
  • Robux
  • Search in Players
  • Search in Games
  • Search in Catalog
  • Search in Groups
  • Search in Library
  • Log In
  • Sign Up
  • Games
  • Catalog
  • Develop
  • Robux
   
ROBLOX Forum » Game Creation and Development » Scripters
Home Search
 

Re: Lua 5.2 - "goto"

Previous Thread :: Next Thread 
StealthKing95 is online. StealthKing95
Joined: 13 Dec 2008
Total Posts: 4263
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
ArceusInator is not online. ArceusInator
Joined: 10 Oct 2009
Total Posts: 30553
19 Dec 2012 08:09 PM
Pros: There's a 2 in the name

Cons: goto sucks
Report Abuse
StealthKing95 is online. StealthKing95
Joined: 13 Dec 2008
Total Posts: 4263
19 Dec 2012 08:11 PM
Well, atleast you said it out loud :D
Report Abuse
ArceusInator is not online. ArceusInator
Joined: 10 Oct 2009
Total Posts: 30553
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
awsumpwner27 is not online. awsumpwner27
Joined: 03 Sep 2011
Total Posts: 4389
19 Dec 2012 08:17 PM
"goto is bad"

yeah, okay, buddy

Mind telling me why?
Report Abuse
UnAdmin is not online. 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
StealthKing95 is online. StealthKing95
Joined: 13 Dec 2008
Total Posts: 4263
19 Dec 2012 08:22 PM
It sounds like they ripped goto from Batch.
Report Abuse
UnAdmin is not online. 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
ArceusInator is not online. ArceusInator
Joined: 10 Oct 2009
Total Posts: 30553
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 is not online. 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
ArceusInator is not online. ArceusInator
Joined: 10 Oct 2009
Total Posts: 30553
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 is not online. 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 is not online. oxcool1
Joined: 05 Nov 2009
Total Posts: 15444
19 Dec 2012 08:51 PM
[ Content Deleted ]
Report Abuse
oxcool1 is not online. oxcool1
Joined: 05 Nov 2009
Total Posts: 15444
19 Dec 2012 08:52 PM
[ Content Deleted ]
Report Abuse
Tenal is not online. 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 is not online. 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
NINJAKID09 is not online. NINJAKID09
Joined: 27 Aug 2009
Total Posts: 14392
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 is not online. 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 is not online. 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
StealthKing95 is online. StealthKing95
Joined: 13 Dec 2008
Total Posts: 4263
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 is not online. 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 is not online. 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 is not online. 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
NecroBumpist is not online. NecroBumpist
Joined: 12 Sep 2010
Total Posts: 4198
19 Dec 2012 09:20 PM
>this thread again

tl;dr goto haters are ignorant bigots
Report Abuse
Lombardo3 is not online. 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
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripters
   
 
   
  • About Us
  • Jobs
  • Blog
  • Parents
  • Help
  • Terms
  • Privacy

©2017 Roblox Corporation. Roblox, the Roblox logo, Robux, Bloxy, and Powering Imagination are among our registered and unregistered trademarks in the U.S. and other countries.



Progress
Starting Roblox...
Connecting to Players...
R R

Roblox is now loading. Get ready to play!

R R

You're moments away from getting into the game!

Click here for help

Check Remember my choice and click Launch Application in the dialog box above to join games faster in the future!

Gameplay sponsored by:
Loading 0% - Starting game...
Get more with Builders Club! Join Builders Club
Choose Your Avatar
I have an account
generic image