Recent Changes - Search:





Q - How does one find the namespace an object belongs to?

A - Use [namespace qualifiers $_]

Q - Can dispatch use sub-namespaces?

A - Yes. Use a call like $_ subns::foo

Q - Can a dispatched call use upvar 1?

A - Yes.

Q - What happens to errors from ~New or ~Delete?

A - If ~tod-ndebug=1, then the object is cleaned up before the error is thrown.

Q - How can the object initializer array be accessed inside a method:

A - Use something like upvar [namespace current]:_ _i

Q - What about non-dispatched callbacks in say bind/after/etc.

A - Use [namespace current]::foo $_

Q - Why would a regexp kick an error inside a method?

A - Don't use {}. Use regexp $pat $str NA rather than regexp $pat $str {}.

Q - How do you change options globally for TOD, like say ndebug?

A - At the top of program use: package require Tod; set ::Tod::_(~tod-ndebug) 1. Or use set env(TOD_OPTS) "ndebug 1 strict 1"

Q - Can Tod's New be used with any-old namespace?

A - Probably, but procs won't work without the _ arg. For non-Tod namespaces you could use: array set ::foo::_ {}; New ::foo

Q - What's the relative performance of dispatching versus proc calls.

A - Depends on version of Tcl, speed of processor, whether upvar is done, etc. However, dispatch is definitely slower so time critical code should be careful. For Tcl 8.5 on a 1700Mhz CPU produces these (rounded) results, in microseconds:

PROC:  3  direct proc call
PROCU: 6  direct proc call + upvar
DISP:  12 dispatch call
DISPU: 17 dispatch call + upvar

Edit - History - Print - Recent Changes - Search
Page last modified on November 08, 2007, at 07:19 PM