Skip to content
Tcl Source Code Ticket Change Details
Login

Ticket Change Details

Overview

Artifact ID: ff81255e656bc35c6425fba6d5b0ed49b858e52fcb767c848a2471b156f5c930
Ticket: 91b3a5bb14e6e8ae1d1c5349af12e08879ea152d
msgcat with oo: error "self may only be called from inside a method"
User & Date: dkf on 2024-07-15 11:04:15
Changes

  1. icomment:
    I've reviewed this further; "fixing" `namespace inscope` isn't practical. This is because it would involve synthesising a call context, which is a complex entity (which would need to be carried in the `clientData` of the stack frame).
    
    It would be "easier" to "fix" `namespace code` to be aware that it is running in an object, but not actually easy because you still run into the stack frame needing to be special (because `self` uses that info).
    ```
      % oo::object create foo
      ::foo
      % oo::objdefine foo export eval
      % foo eval self
      self may only be called from inside a method
    ```
    I've no idea what will happen if I make the `eval` method used above export its special-ness into the frame it pushes. (It's *one* possibility, and perhaps one that I should have thought about before...)
    
    [`callback`](https://www.tcl-lang.org/man/tcl9.0/TclCmd/callback.html) and using a method for the tooltip showing would seem better. Or passing more arguments from the context that sets up the callback (pre-resolving the namespace). The code to it can be copied for 8.6; it's literally just a small procedure.
    
    I doubt that I'll ever make this "work" for definitions.
    
    ----
    
    I **strongly recommend** adding `try`/`on error` handling to this to fall back to the non-OO way of doing things, as that will be significantly less wrong. I also strongly recommend resolving the namespace prior to registering the callback. In fact, that's likely to be my central recommendation; **resolve the namespace immediately**. (Namespaces can't be renamed, so the resolution should remain the same for however long the context is meaningful for.)
    
  2. login: "dkf"
  3. mimetype: "text/x-markdown"