Are codebox functions always being calculated?

    Jun 03 2017 | 6:46 pm
    I apologize if this is a dumb question, but my knowledge of how things work under the hood in traditional programming isn't very deep, but I've been curious about times where codebox might be more efficient computationally as opposed to just organizationally. This also might be a bit of an abstract question, so I hope it makes sense.
    When I'm using the codebox, if I declare a function, and it hasn't been called by a conditional, is gen still doing the work to calculate its result?
    For example, this code:
    return atanh(blah*yadda);
    return cos(bar/foo);
    if(in3 > 0){
    out1= Y(in1, in2);
    out2= X(in1, in2);
    in this case, if in3 is 0, is gen still calculating the math in the "Y" function, or is it waiting until in3 is greater than 0 to start doing that?

    • Jun 03 2017 | 8:59 pm
      To my knowledge gen will calculate that function at audio rate. If a conditional is missing, gen assumes zero. I had a similar question some days ago, got answered here.
    • Jun 05 2017 | 10:48 am
      In your example, the if() condition test is called at audio rate, but the function X or Y here is not... Y is only called when the if() condition is true, X is only called when the condition is false.
      You can verify this by looking at the generated code (send an "exportcode" or a "full_source_code" message to the gen~ object).
      Jayrope is correct in the sense that if you didn't assign anything to out1, it would have a default value of zero.