Scope of Pragma Clarification?

I know pragmas only affect the method they are in, but what about within the method?

A) Are they only effective from the point in the method they were set, or for the whole method (I have always assumed from that point onward but he docs don’t explicitly say that last I looked.)

B) If defined in an if block like this:

If usePragmas Then
  #Pragma BackgroundTasks False
  #Pragma BoundsChecking False
End if

are they:

  1. only effective in that block
  2. only if set in block, they are effective from that point onward
  3. the if block ignored and they are set anyway

I always assumed 2 but again I just realized that might not be the case

Thanks,
-karen

Where encountered to the end of the method
Unless of course you out another that countermands the effects
I dont know of any that arent that way

#Pragma BreakOnExceptions is the only one I tend to toggle

Thanks,

What made we wonder is that unlike #if#endif blocks, plain If…end statements are executed at run time, but Pragmas are a compile time thing.

Thinking about that made we wonder what happens with Pragmas in IF…END blocks rather than being in #IF#ENDIF blocks

-Karen

1 Like

BTW In my code use UsePragmas is a variable passed into the method

  • Karen

in your case UsePragmas should still control whether the code that gets generated for those pragmas gets executed

#PRAGMAS were initially INTENDED to be “compile time” only but thats become less & less the case over the years so they can be traded much like any other code
They just generate code that switches the runtimes behaviour as opposed to normal dojo code which really doesnt have that ability