File: utils.tcl

package info (click to toggle)
chiark-tcl-applet 1.0-2
  • links: PTS
  • area: main
  • in suites: bullseye, sid
  • size: 144 kB
  • sloc: tcl: 860; makefile: 32
file content (38 lines) | stat: -rw-r--r-- 713 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38

# Copyright 2016,2020 Ian Jackson
# SPDX-License-Identifier: GPL-3.0-or-later
# There is NO WARRANTY.

proc manyset {list args} {
    foreach val $list var $args {
        upvar 1 $var my
        set my $val
    }
}

namespace eval debug {

# Debug:
# 
#    Caller may call
#       debug::setup ON-DEBUG
#    which will result in calls to [concat ON-DEBUG [list MESSAGE]]
#    (or ON-DEBUG may be "" in which case messages are discarded)
#
#    And caller may call
#       debug::debug MSG

variable debug {}

proc debug {m} {
    variable debug
    if {![llength $debug]} return
    set ns [uplevel 1 namespace current]
    uplevel #0 $debug [list "DEBUG $ns $m"]
}

proc setup {d} {
    variable debug $d
}

}