Skip to content
Tcl Source Code Ticket Change Details
Login

Ticket Change Details

Overview

Artifact ID: 3a41bd60af5737282bb994727f87178034bc09e5adb60dd171aacf4cffdfe874
Ticket: 2c519736077ac092dbbce446759063f5f8427084
Having Tcl_WrongNumArgs return TCL_ERROR makes extension writing a little nicer
User & Date: sebres on 2018-07-05 10:33:21
Changes

  1. icomment:
    > neither should anyone else. :D
    
    Why not?...
    
    Explicit looks always better as implicit... 
    Despite the function would not return anything else as TCL_ERROR, so IMHO no return code expected also.
    So as regards the readability of the source code.
    
    At first glance, the one reason speak for the implicit return code inside Tcl_WrongNumArgs - the minimization of resulting assembler code (if it's the last function in the simple stack block, modern compiler will replace "call Tcl_WrongNumArgs" with "jmp Tcl_WrongNumArgs")...
    
    So:
    
    <code><pre style="padding-left:10pt">
    test(Tcl_Interp*, int, Tcl_Obj*):
      sub rsp, 8
      xor ecx, ecx
      call Tcl_WrongNumArgs
      xor eax, eax
      add rsp, 8
      ret
    <pre></code>
    
    resulting to:
    
    <code><pre style="padding-left:10pt">
    test(Tcl_Interp*, int, Tcl_Obj*):
      xor ecx, ecx
      jmp Tcl_WrongNumArgs; 
    <pre></code>
    
    But only if nothing else is to do (free stack, decrement references, etc).
    
    Otherwise it may be bad, because steals a register (eax) for return code from function (because the compiler does not know that it's always the same return code).
    
    And as Harald correct said, you could simply write your own macro resp. inliner.
    
  2. login: "sebres"
  3. mimetype: "text/x-fossil-wiki"