4 # This file provides example cases for testing the Tcl autoloading
5 # facility. Things are much more complicated with namespaces and classes.
6 # The "auto_mkindex" facility can no longer be built on top of a simple
7 # regular expression parser. It must recognize constructs like this:
10 # proc test {x y} { ... }
11 # namespace eval bar {
12 # proc another {args} { ... }
16 # Note that procedures and itcl class definitions can be nested inside
19 # Copyright (c) 1993-1998 Lucent Technologies, Inc.
21 # This shouldn't cause any problems
22 namespace import -force blt::*
24 # Should be able to handle "proc" definitions, even if they are
25 # preceded by white space.
27 proc normal {x y} {return [expr $x+$y]}
28 proc indented {x y} {return [expr $x+$y]}
31 # Should be able to handle proc declarations within namespaces,
32 # even if they have explicit namespace paths.
34 namespace eval buried {
35 proc inside {args} {return "inside: $args"}
37 namespace export pub_*
38 proc pub_one {args} {return "one: $args"}
39 proc pub_two {args} {return "two: $args"}
41 proc buried::within {args} {return "within: $args"}
43 namespace eval buried {
44 namespace eval under {
45 proc neath {args} {return "neath: $args"}
47 namespace eval ::buried {
48 proc relative {args} {return "relative: $args"}
49 proc ::top {args} {return "top: $args"}
50 proc ::buried::explicit {args} {return "explicit: $args"}
54 # With proper hooks, we should be able to support other commands
55 # that create procedures
57 proc buried::myproc {name body args} {
58 ::proc $name $body $args
60 namespace eval ::buried {
61 proc mycmd1 args {return "mycmd"}
62 myproc mycmd2 args {return "mycmd"}
64 ::buried::myproc mycmd3 args {return "another"}
66 proc {buried::my proc} {name body args} {
67 ::proc $name $body $args
69 namespace eval ::buried {
70 proc mycmd4 args {return "mycmd"}
71 {my proc} mycmd5 args {return "mycmd"}
73 {::buried::my proc} mycmd6 args {return "another"}