Posted to tcl by sebres at Tue Jul 24 13:59:34 GMT 2018view pretty

The question is: should the TIP 283 provide an opportunity to switch back to the caller-resolution: caller (special-area below) wins, so interacts like a global here, and decides which unknown should be used).
Possibly like an option `configure ?-resolve caller|ensemble|...?` or similar.

If the TIP, as it currently is, gets accepted, someone can't implement anymore the things like in example.

```tcl
proc create-request {} {
  catch {namespace delete ::req}
  namespace eval ::req {
    namespace ensemble create
    namespace ensemble configure [namespace current] -prefixes 1 -unknown inplace-mixin
  }
  return ::req
}

namespace eval special-area {
  proc inplace-mixin {args} {
    ::puts "we are in inplace-mixin, called $args"
    # reset handler (or set to other):
    namespace ensemble configure [lindex $args 0] -unknown ""
    # create input/output handler:
    namespace eval [lindex $args 0] {
      proc puts {args} {::puts [list RESPONSE {*}$args]}
      proc gets {args} {return INPUT; #::gets}
      namespace export *
    }
    # uplevel $args
  }
}

namespace eval special-area-test {
  proc log {args} {::puts "# \[DEBUG\] [info level [info level]]"}
  namespace export log
  proc inplace-mixin {args} {
    log "we are in inplace-mixin of test, called $args"
    # reset handler (or set to other):
    namespace ensemble configure [lindex $args 0] -unknown ""
    # create log handler:
    namespace eval [lindex $args 0] [list namespace import [namespace current]::*]
    # create input/output handler:
    namespace eval [lindex $args 0] {
      proc puts {args} {log $args}
      proc gets {args} {return TEST; #::gets}
      namespace export *
    }
    # uplevel $args
  }
}

set code [list {r} { $r puts "test response for [$r gets]" }]
apply [linsert $code end [namespace current]::special-area] [create-request]
apply [linsert $code end [namespace current]::special-area-test] [create-request]
```

Comments

Posted by sebres at Tue Jul 24 15:46:33 GMT 2018 [text] [code]

Just small amend, as the consistence question: ```tcl % proc unknown {args} {::puts global} % namespace eval foo {namespace unknown unknown; proc unknown {args} {::puts local}} % namespace inscope foo {some-thing} local % foo::some-thing global # and if it'll be an ensemble with same unknown-handler: % foo some-thing ????? ``` Therefore, I would like to make it consistently for all unknown-handler, and provide an option to decide... Among other things to allow: ```tcl namespace eval xxx {foo::boom; bar::boom} namespace eval xxx { foo boom; bar boom } ``` where "foo" can call unknown in caller, "bar" can call unknown in ensemble/namespace. In this case "foo boom" invokes method "boom" of "xxx", and "bar boom" invokes its own "boom" method (both after unknown callee); And the strategy is simple: only the namespaces/ensembles know, what they should call, only the caller knows about its unknown handling.