5 Replies Latest reply on May 10, 2018 4:14 AM by Trevorׅ

    Bitwise operators | and & precedence

    Anton Petrov

      I still can't believe this is possible. After few days (and nights) of debugging, I found that JSX doesn't confirms with JS specifications about '&' and  '|' operators precedence. 

      In ESTK "1 | 1 & 0" results in 0. It should be the same as "1 | (1 & 0)", which is 1.

      The issue I had was with an external minified library crypto-js and the debugging was real pain.

      As I could't find this fact documented, I'm still wondering is that by design or it's Adobe's implementation bug?

        • 1. Re: Bitwise operators | and & precedence
          BarlaeDC Adobe Community Professional



          As per this thread it is stated that the scripting engine doesn't conform in all ways, so it could be either a bug or a implementation issue, Does Adobe have any plans to update JavaScript .


          At the moment, I guess it is just best to be explicit with your JavaScript.





          • 2. Re: Bitwise operators | and & precedence
            Trevorׅ Adobe Community Professional

            It sounds very much like the should be some major changes. I would expect some announcement within the next month or 2 but it might well be covered by an NDA.

            • 3. Re: Bitwise operators | and & precedence
              Anton Petrov Level 1

              Hi, Malcolm,

              Thanks for your replay. I have read the whole thread you mentioned, but there is no a single word about that issue.

              I feel a bit more clarification is needed. Operators precedence is obviously considered too basic topic, to be covered in any InDesign Scripting Guide which I could find. In fact, the only place I found something on that subject is this After Effects CS6 Scripting Guide, which explicitly states on page 11, that '&' is with higher precedence than '|' operator. In fact, math operators are doing as expected, but logical operators have the same issue.

              For me, there are two major lines:

              1. This is not a bug but it's by jsx design. In that case no action from Adobe developers is needed, just to be explicitly pointed in the references and tutorials. AFAIK, any programming or scripting language conforms with the known mathematical, logical and bitwise order of operations. So this would be of a great difference.

              2. It's a specific Adobe implementation bug. It must be addressed to Adobe team for resolution.

              In both cases, i'd wish I knew that. Maybe not a big deal, but in my case the main problem is with the minified js libraries, where unnecessary (according to js specs) parentheses are removed. And there is no easy solution.



              • 4. Re: Bitwise operators | and & precedence
                BarlaeDC Adobe Community Professional



                I posted the thread so you could see 2 points, 1 - that ExtendScript does not conform to the specifications, and hence you get some anomalies in how code functions. and 2 - that there is a debate about what to do with Scripting going forward, do Adobe update extendscript or move to a different framework (nodejs ........ ).


                This was just to give you some understanding of where the ExtendScript library is, and the problems that can arise because of this.


                I agree that it should be fixed/updated to match the specification but until such time as there is a approach chosen by Adobe as to how to move forward with ExtendScript, we pretty much have to work around the issues.


                As always you can log the issue officially with Adobe here - Feature Request/Bug Report Form





                • 5. Re: Bitwise operators | and & precedence
                  Trevorׅ Adobe Community Professional

                  Marked as correct