Tcl Source Code

Ticket Change Details
Login
Overview

Artifact ID: a37f40ea3cd9abd442f1678b4a2043ea3dd79f4020497574c38355bd1a439693
Ticket: effa2e2346f8372ad4982d16bad189fab96ceb56
RFE - lazy loading of TclOO for faster interp creation
User & Date: sebres 2025-08-16 14:30:26
Changes

  1. icomment:
    You're welcome.
    
    [6a997a7f19eaa6fa] provides several improvements:
    
      *  <code>package require tcl::oo</code> forces the initialization through new oo::_init command (so one could circumvent the delayed init issues for mockup, injection etc);
      *  update of mocked-up command by execution (although it wouldn't "fix" every case sane, see below);
      *  code review, dedeplication, etc.
    
    As for mz previous mocked-up example, it'd work now, and would not enter endless loop anymore, but the mock-up becomes outdated (replaced by mentioned update after lazy load), see the new diff (<b style="color:red">red</b> is lazy branch):
    <code><pre>
      % rename ::oo::class ::oo::_mocked_class;
      % proc ::oo::class args { puts "mockup $args"; tailcall ::oo::_mocked_class {*}$args }
      % ::oo::class create A
      mockup create A
      ::A
      % ::oo::class create B
    <b style="color:red">- mockup create B</b>
      ::B
    </pre></code>
    
    So as one can see, the mock-up is quasi removed here.
    And the only solution would be to use <code>package require tcl::oo</code> before mocking-up or injection to force the initialization.
    
    Alternative would to create all this command properly (to point to correct handler).<br/>
    Or as already said, a new facility able to load NS on demand by first access to it (in any resolver, etc). In my opinion, that would be the only right way.
    
  2. login: "sebres"
  3. mimetype: "text/x-fossil-wiki"