Skip to content
Tcl Source Code Ticket Change Details
Login

Ticket Change Details

Overview

Artifact ID: 224c75f059523baeb2bf12af291cfe3a13ef91b7e6a67e231186fee59f0a39c6
Ticket: 91b3a5bb14e6e8ae1d1c5349af12e08879ea152d
msgcat with oo: error "self may only be called from inside a method"
User & Date: dkf on 2024-07-15 08:23:00
Changes

  1. icomment:
    The `self` commands all require that the current stack frame at point of invocation be one made by TclOO. This is used to look up context information that can't be minted otherwise by Tcl scripts (it's some flags and the clientData pointer, not just some undocumented Tcl variable).
    
    The proposed changes might not work; object names aren't matched to namespace names under quite a few common circumstances. (Objects can be `rename`d; namespaces cannot.) It's wise to check these things with an object made with `oo::object create foo`, the simplest case where such a match doesn't occur.
    
    I suspect that the *real* fix is to alter what the specific `namespace inscope` does (i.e., the `namespace code` call). In particular, `show .toolbar.one` should probably become something more like a method call (`.toolbar.one show`). This is why Tcl 8.7 and 9.0 have a `callback` command, so that one can write:
    
    ```
       after idle [callback Show ...]
    ```
    
    Where `Show` is a non-exported method. (The `callback` command is a short procedure.)
    
  2. login: "dkf"
  3. mimetype: "text/x-markdown"