x


pragma strict on iOS: if no errors does it improve anything?

I've been adding #pragma strict to scripts & never get any errors.

Guess I'm doing things right?

Anyways just curious if it is still invisibly doing wonderful things to my code with the "static typing", is adding #pragma strict actually improving the code in these cases where there is no errors?

more ▼

asked Apr 12 '12 at 10:37 AM

citycrusher gravatar image

citycrusher
105 4 6 8

(comments are locked)
10|3000 characters needed characters left

2 answers: sort voted first

The #pragma in itself doesn't improve the performance (it is not a compiler flag such as -O3 on GCC). But the fact that your code respect the #pragma strict ensure that the code works better because the runtime does not need to guess the type of each variable (amongst other improvement).

In conclusion a script that pass the #pragma strict is most of the time faster than a script that don't, easier to debug and less error-prone.

more ▼

answered Apr 12 '12 at 12:01 PM

Kryptos gravatar image

Kryptos
7.2k 5 32

(comments are locked)
10|3000 characters needed characters left

When the build platform is iOS, all JS scripts are compiled with #pragma strict anyway, so adding it manually does nothing. And no it doesn't improve code, all it does is prevent dynamic-typed code from compiling.

more ▼

answered Apr 12 '12 at 01:40 PM

Eric5h5 gravatar image

Eric5h5
80.3k 42 132 521

(comments are locked)
10|3000 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Topics:

x9

asked: Apr 12 '12 at 10:37 AM

Seen: 420 times

Last Updated: Apr 12 '12 at 01:40 PM