How to annotate function to be accessible in glance but only in debug?

As in subject. Without :glance ina app my code looks like:

(:debug) function foo1(){...}//A

(:debug) function foo2(a){return foo1();}//B

(:release) function foo2(a){return a.x;}//C

... somewhere in code

var x = foo2(a);

I need only C in release but also in glance.

  • If I'm understanding correctly, try this:

    (:debug :glance) function foo1(){...}//A

    (:debug :glance) function foo2(a){return foo1();}//B

    (:release :glance) function foo2(a){return a.x;}//C

  • I've already tested this case and know it chooses good function but I think foo1 will be include in code segment always.

    Unless annotations runs different

    - for debug :release :glance there is AND between them

    - and OR when exclude annotations runs

  • I think as written above, foo1() wil be excluded from the release build because it's annotated with debug.

    If you doubt that foo1() will be excluded from the release build:

    - Add some code which unconditionally calls foo1() on the press of a button (or selection of a menu item, or add some code which displays the result of "$. has :foo1" (replace "$" with the correct scope, if necessary). You may have to disable the type checker for the first option to build.

    - Build in release mode

    - Sideload to device and test. If you chose the first test, your app should crash. If you chose the second test, it should display "false".

    I think foo1 will be include in code segment always.

    Unless annotations runs different

    - for debug :release :glance there is AND between them

    - and OR when exclude annotations runs

    My understanding is that annotated code such as "(:X :Y Z:) function foo1()" means "only include foo1 when X, Y and Z are all defined". That means if any one of X, Y or Z are not defined, foo1 will be excluded. (The two statements are logically equivalent).

    If I'm understanding it correctly, the behavior is totally logical (no special cases or inconsistencies).

    I guess some of the default behavior for including symbols could be described as special cases, such as the fact that any code which is not annotated with "glance" is unavailable to glances. Same goes for "background".

    I sort of get where you're coming from. Maybe it makes more sense if you think of it in terms of what annotations are defined on a given symbol, as opposed to how things are excluded? (Regardless of how it actually works.)

    It could be that under the covers, the rules look like this, for example:

    - A given build excludes any symbol that has an annotation specified by excludeAnnotations in monkey.jungle

    - Debug builds exclude anything that has the release annotation

    - Release builds exclude anything that has the debug annotation

    - Glances have no access to symbols that do *not* have the glance annotation (iirc, glance code goes at the beginning of the PRG, so that a glance can load the code it needs by loading the first part of the PRG)

    - Background code has no access to symbols that do *not* have the background annotation

    IOW, I'm guessing not every built-in annotation works like user-specified excludeAnnotations (namely, glances and background code have to work differently)

  • Yes, you are right, after few tests (:debug :glance) function foo1() excludes foo1 when release building.