title: MATLAB `builtin` calls overloaded function
body: <pre class="lang-matlab prettyprint-override"><code>% Dog.m -------------------------------------------------
  classdef Dog
      methods
          function varargout = subsref(obj, x)
              varargout = subsref_overloaded(obj, x);
          end
      end
  end
  </code></pre>
  <pre class="lang-matlab prettyprint-override"><code>% subsref_overloaded.m ----------------------------------
  function varargout = subsref_overloaded(obj, x)
      [varargout{1:nargout}] = builtin('subsref', obj, x);
  end
  </code></pre>
  <p><code>d=Dog()</code>, and <code>d()</code> yields</p>
  <pre class="lang-matlab prettyprint-override"><code>Maximum recursion limit of 500 reached.
  
  Error in Dog (line 2)
      [varargout{1:nargout}] = builtin('subsref', obj, x);
  
  Caused by:
      Maximum recursion limit of 500 reached.
  </code></pre>
  <p>Why, and can it be fixed? It's strange since it copies code straight from <a href="https://www.mathworks.com/help/matlab/matlab_oop/code-patterns-for-subsref-and-subsasgn-methods.html#bu7rrk_" rel="nofollow noreferrer">implementation</a>, and in debugger, <code>builtin('subsref', obj, x)</code> called while in <code>Dog.m</code> works as expected, but not while in <code>subsref_overloaded.m</code>.</p>
  <hr>
  <p><strong>Context</strong>: I'm overloading <code>subsref</code> <a href="https://stackoverflow.com/a/73521919/10133797">like here</a>, but that's verbose to reuse so I want to make something like <code>subsref_overloaded(obj, x, fn)</code> and output <code>fn(x)</code>.</p>