• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

Probably a stupid Idea but tell me what you think

Evanski

Raccoon Lord
Forum Staff
Moderator
So what if... ? was a symbol for "if"

for example:
Normal-
Code:
if potatoes = 666
{
       potatoes -= 1;
}
Symbol-
Code:
?potatoes = 666
{
       potatoes -= 1;
}
waste of time? most likely.
Fun new idea to try when messing around with code? yes.

What do you think?
 
Last edited:

ElectroMan

Jack of All Shades
Reminds me of the ternary operator. In some languages, a quick "if" statement can be inserted directly into the assignment of variable. Instead of...
Code:
if (*condition*)
{
     x = something;
}
else
{
     x = somethingElse;
}
...you can write
Code:
x = (*condition*) ? something : somethingElse;
It's debatable whether GML can benefit from introducing this, if it's not in the language yet. It saves some lines of code and can promote readability in some cases.
 
Reminds me of the ternary operator. In some languages, a quick "if" statement can be inserted directly into the assignment of variable. Instead of...
Code:
if (*condition*)
{
     x = something;
}
else
{
     x = somethingElse;
}
...you can write
Code:
x = (*condition*) ? something : somethingElse;
It's debatable whether GML can benefit from introducing this, if it's not in the language yet. It saves some lines of code and can promote readability in some cases.
Ternary operator is available in GMS 2, not sure about GMS 1.4
 
E

ethian

Guest
(Watchs the normal code)
Not a stupid idea, it's almost good for me, as if potatoes reachs the number of the devil, potatoes seem to not want to reach that diabolic number, so their amount decreases...
It's almost good because it's bad if they reach to 0, so, what if they jusg reach a number that is not so near and not so far of the diabolic number? Can't be 660 or 670?
 
M

Misty

Guest
(Watchs the normal code)
Not a stupid idea, it's almost good for me, as if potatoes reachs the number of the devil, potatoes seem to not want to reach that diabolic number, so their amount decreases...
It's almost good because it's bad if they reach to 0, so, what if they jusg reach a number that is not so near and not so far of the diabolic number? Can't be 660 or 670?
666 is not the devil's number.

The Bible says it is the number the beast, and the beast is Man.

6=Carbon 6 protons 6 neutrons 6 electrons

Humans are carbon based forms.
 

Mercerenies

Member
So what if... ? was a symbol for "if"
Aside from the already mentioned ternary operator, the language Factor actually provides a ? operator which does more or less what you describe. The equivalent of
Code:
if (argument0 < 666) {
  return "Less than 666";
} else {
  return "Not less";
}
in Factor would be
Code:
666 < "Less than 666" "Not less" ?
It's debatable whether GML can benefit from introducing this, if it's not in the language yet. It saves some lines of code and can promote readability in some cases.
As for this, I find the ?: syntax to be particularly unfortunate, as it is absolutely awful at describing what it does. I prefer the approach of Ruby and languages like it, where the keyword "if" begins an expression, rather than a statement,so you can do either
Code:
if (argument0 < 666) {
  return "Less than 666";
} else {
  return "Not less";
}
or
Code:
return if (argument0 < 666)
    "Less than 666"
  else
    "Not less"
  end
Then you still get the keyword "if" which is very clear, together with the nice expression syntax.

Language snobbery rant over.
 

curato

Member
I don't think the variants with ? instead of if promote and kind of readability in the code and to me readability > brevity
 
Top