20
$\begingroup$

One of my (many) mottos:

private const success:int = 0;  
attempt(success);  
private function attempt(success:int):void {
    success = success;  
    do {  
        TRY(success);  
    } while (success < 1);
}  

private function TRY(success:int):void {  
    trace("try",success);  
    success += 1;  
}

OUTPUT:

try 0  
try 0  
try 0  
try 0  
try 0  

...ad infinitum

$\endgroup$
12
  • 10
    $\begingroup$ Does this language pass by reference or by value by default? :) $\endgroup$
    – LeppyR64
    May 20, 2016 at 1:08
  • 1
    $\begingroup$ @Chowzen I attempted to format your code using the Code formatting tools provided by the editor. The edit currently is in peer review, but in case it doesn't come through (or anyone else wants to use code in their question or answer), you can use 4 spaces at the start of your line to tell the text editor to use a fixed-width font and preserve formatting. it means you don't have to use nested quote formatting. $\endgroup$
    – Nzall
    May 20, 2016 at 7:51
  • 8
    $\begingroup$ Using += with a const makes me instantly hate this language. $\endgroup$ May 20, 2016 at 12:56
  • 2
    $\begingroup$ Except the += is being used on a local variable that has not been declared as a const. $\endgroup$
    – Dancrumb
    May 20, 2016 at 13:51
  • 1
    $\begingroup$ @Dancrumb, the poster of this question has verified that it is passed by reference, not by value, meaning that this local variable is a reference to the original constant, implying that it should also be constant (or that += would act to increment a memory address, which is also gross). $\endgroup$ May 20, 2016 at 15:48

10 Answers 10

23
$\begingroup$

Is it:

If at first you don't succeed, try try again? or alternatively No matter how many times you try you will never succeed

New Reasoning:

The success variable is a const so it will never change (as shown in the output). That leads me to believe it is if at first you don't succeed try try again, as it will infinitely loop calling the Try method, and succeed is always 0, which is some language represents false (the "don't")

Old Reasoning:

If the language is pass by value, try will keep being called since you will never succeed (success never actually becomes 1)
If the language is pass by reference, try will be called once, and then you break out of the while loop so i'm not sure about this one

$\endgroup$
10
  • 2
    $\begingroup$ I don't think so. Based on my quick analysis, this code will never succeed. $\endgroup$
    – LeppyR64
    May 20, 2016 at 1:09
  • 1
    $\begingroup$ The edit should tell you which it is :) $\endgroup$
    – LeppyR64
    May 20, 2016 at 2:01
  • 2
    $\begingroup$ It shouldn't matter if it's by value or reference. If it's by value, then the value gets lost at the end of TRY. However, if it's by reference, then both methods would be passing by reference, and it wouldn't change, due to the constant value of the variable. Regardless of language setting, this value's never going to chance, from what I see. $\endgroup$ May 20, 2016 at 12:21
  • 1
    $\begingroup$ @LeppyR64 - Hey, this code might succeed. All you have to do is wait for a stray bit of cosmic radiation to flip that memory location to true... $\endgroup$ May 20, 2016 at 18:15
  • 2
    $\begingroup$ It does, in fact, "try Try again". $\endgroup$
    – user253751
    May 21, 2016 at 6:49
29
$\begingroup$

My guess is:

The definition of insanity is doing the same thing over and over again expecting different results.

Beacuse:

If the code is pass-by-value then success+=1 within TRY increases the local variable but will not increase the variable in attempt, therefore the while loop will never exit.

$\endgroup$
3
  • 1
    $\begingroup$ I like the answer, but not the justification. I think the const is the part that makes it fail, here. And, you know, constant kinda are always the same thing. $\endgroup$
    – Édouard
    May 20, 2016 at 12:45
  • 1
    $\begingroup$ @Édouard When the answer was posted we didn't have all the information about what language it was. Later when that was revealed it was clear that Gordon's answer was the correct one. $\endgroup$
    – LeppyR64
    May 21, 2016 at 10:57
  • $\begingroup$ When i posted my comment, Gordon’s answer was lacking any justification. $\endgroup$
    – Édouard
    May 21, 2016 at 11:21
17
$\begingroup$

My bet is (sorry for the poor formulation) :

No matter how hard you try, you will never succeed if you don't define "success" correctly

Explanation :

I don't know ActionScript, but it seems like the only thing blocking success from happening is that you defined it as a constant value equals 0. No matter what, a const cannot change value => infinite tries => no success :(

$\endgroup$
6
$\begingroup$

My guess is:

"Do or do not, there is no try." -Yoda

Reasoning:

Yoda's point was that in order to succeed you must believe in yourself and commit fully. To doubt oneself by only considering the attempt as "trying" is fruitless. In the program, calling TRY does not meaningfully affect success, because when TRY is called the success variable in the outer context remains 0 and the loop is not broken. The only thing that will achieve success and complete the program is by modifying success in the do block, or in other words, by doing.

$\endgroup$
4
$\begingroup$

My guess is

Do until you die

the do loop keep on attempt/executes until it success/die

$\endgroup$
0
4
$\begingroup$

My guess:

Nothing ventured, nothing gained.

Explanation:

"try 0" means "try nothing", that is, "venture nothing", and nothing is gained from this program as it never terminates.

$\endgroup$
1
  • $\begingroup$ The programmer isn't instructing the program to "try 0," "try 0" is merely the output, the result of the executed code. It would be more appropriate to say that "try 0" means "I tried and got a result of nothing." $\endgroup$
    – Chowzen
    May 20, 2016 at 14:14
4
$\begingroup$

I have a motto

"You lose some, you lose some" I never win at anything.

Pretty much, this code replicates my life. If I win this, that will be an oxymoron, if I don't the code is true.

$\endgroup$
4
$\begingroup$

As a software developer who has worked at or otherwise helped a start-up or two, this immediately reminded me of a quote I've heard at a few of them:

Samuel Beckett, from Westward Ho: "Ever tried. Ever failed. No matter. Try again. Fail again. Fail better.".
As every time I hear it I think: "Have you ever seen the rest of that piece or his other stuff? This was not a call to success this was a call to the hopelessness of constant failure (0)."

A more complete quote btw:

"Ever tried. Ever failed. No matter. Try again. Fail again. Fail better. Or better worse. Fail worse again. Still worse again. Till sick for good. Throw up for good. Go for good.”

With the last part being a reference to how this program will fail until it either runs out of memory, overflows, or is otherwise killed off

$\endgroup$
2
$\begingroup$

My answer is

Never stop trying, because the program will execute "try" forever. SafetySuit agrees with me.

$\endgroup$
2
  • $\begingroup$ Who (or what?) is SafetySuit? $\endgroup$
    – LeppyR64
    May 20, 2016 at 14:15
  • $\begingroup$ @LeppyR64 A band. They had a song by that name. $\endgroup$ May 20, 2016 at 15:21
2
$\begingroup$

Whosoever desires constant success must change his conduct with the times. – Niccolò Machiavelli

.

The only way to achieve constant success is to be yourself not constant - if you only try the same thing every time, you will fail.

$\endgroup$

Not the answer you're looking for? Browse other questions tagged or ask your own question.