From 2ce041bbd2fcb71a461ad3f10c8fc5afd1eef60c Mon Sep 17 00:00:00 2001 From: mescalinum Date: Thu, 3 Sep 2009 10:29:45 +0000 Subject: add default_arg proc, for writing nicer code svn path=/trunk/externals/tclpd/; revision=12204 --- pdlib.tcl | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'pdlib.tcl') 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 -- cgit v1.2.1