Search Unity

#pragma strict?

Discussion in 'Scripting' started by User340, Dec 5, 2007.

  1. User340

    User340

    Joined:
    Feb 28, 2007
    Posts:
    3,001
  2. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    It prevents Javascript from using dynamic typing. If you try, you get a compiler error.

    --Eric
     
  3. Foxxis

    Foxxis

    Joined:
    Jun 27, 2006
    Posts:
    1,108

    Which is good, since dynamic typing is slower than strict, though how much depends on the circumstances (IIRC).
     
  4. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    Yep, but if I'm writing functions that aren't called often, then I'll leave "#pragma strict" off, since trying to avoid dynamic typing can occasionally be annoying, and the performance difference won't be noticeable in this case.

    --Eric