Jump to content


Photo

Now is a good time to start disallowing this


  • Please log in to reply
5 replies to this topic

#1 Erik Leppen

Erik Leppen

    GMC Member

  • GMC Member
  • 2507 posts
  • Version:GM:Studio

Posted 11 March 2012 - 03:19 PM

It seems that it's possible to have variables with the same name as built-in functions.
var cos, min;
min = 3
cos = min + 1
show_message(string(cos))
To me this doesn't sound like a smart move. Is the advent of GM:Studio a good time to start disallowing this, alongside the other bad practices that are already taken care of?
  • 3

#2 alexandervrs

alexandervrs

    GMC Member

  • GMC Member
  • 679 posts
  • Version:GM:Studio

Posted 11 March 2012 - 03:31 PM

o.O I wasn't even aware of that...
  • 0

#3 Manuel777

Manuel777

    InvaderGames

  • GMC Member
  • 3534 posts
  • Version:GM:Studio

Posted 11 March 2012 - 07:06 PM

C++ runner should be able to notice the difference between those two, right?
  • 0

#4 cotycrg

cotycrg

    GMC Member

  • GMC Member
  • 873 posts
  • Version:GM:Studio

Posted 11 March 2012 - 07:22 PM

I..why would you even do that?
  • 0

#5 NakedPaulToast

NakedPaulToast

    GM Studio/Mac/Win

  • GMC Member
  • 8210 posts
  • Version:GM:Studio

Posted 11 March 2012 - 07:28 PM

I..why would you even do that?

It's not a question of wanting to do that, it's a question of happening to do that, or accidently doing that.

I don't WANT to not initiallize variables, but should I forget or mistype a variable name, I want an error message.
  • 0

#6 chance

chance

    GMC Member

  • Global Moderators
  • 7184 posts
  • Version:GM:Studio

Posted 11 March 2012 - 08:15 PM

Fortunately, the color-coded editor flags these names. Unfortunately, it doesn't disallow their use. But you must admit, it can lead to some interesting looking code:

sin = pi/2;
cos = sin(sin);
abs = -abs(-1);
abs = abs(abs);
exp = exp(cos(sin)/abs);
  • 1




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users