aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormescalinum <mescalinum@users.sourceforge.net>2009-09-03 10:29:45 +0000
committermescalinum <mescalinum@users.sourceforge.net>2009-09-03 10:29:45 +0000
commit2ce041bbd2fcb71a461ad3f10c8fc5afd1eef60c (patch)
tree418dc39f6273e26a5b81bc94d06b95f47849c424
parent2e5f65d784c11ae62c2a317ba6ee98697cd7fff1 (diff)
add default_arg proc, for writing nicer code
svn path=/trunk/externals/tclpd/; revision=12204
-rw-r--r--pdlib.tcl8
1 files changed, 8 insertions, 0 deletions
diff --git a/pdlib.tcl b/pdlib.tcl
index 4c3a63e..2f97b03 100644
--- a/pdlib.tcl
+++ b/pdlib.tcl
@@ -174,6 +174,14 @@ namespace eval ::pd {
}
}
+ proc default_arg {n assertion defval} {
+ if {$n < [uplevel "pd::args"]} {
+ return [uplevel "pd::arg $n $assertion"]
+ } else {
+ return $defval
+ }
+ }
+
# mechanism for uploading procs to gui interp, without the hassle of escaping [encoder]
proc guiproc {name argz body} {
# upload the decoder