What is the trade-off between optimization and semantics of final call?

In

functional programming, one method often calls another, for example:

function test(){
    a();
    return b();
}

but personally, it seems that although it reduces memory footprint, it is semantically unreasonable. For example, here, I don"t need a return return value.

so how to choose? Or is there a better way? Thank you for answering the questions

Jun.04,2022

  1. tail tones are meaningful only for recursion, because recursion requires constant stack pressing.
  2. The

    tail tune does not support browsers other than safari (including nodejs ) although they have implemented this feature a long time ago, folding is just a good idea, and there are still a lot of problems.
    such as stack loss

    function foo(n) {
      return bar(n*2);
    }
    
    function bar() {
      throw new Error();
    }
    
    foo(1);//foo

browser supports
tc39 proposal-ptc-syntax discussion


according to my own experience, clear code intentions in a general project are far better than masturbation techniques that are difficult for others to understand

Menu