Tcl Library Source Code

View Ticket
Login
Ticket UUID: e4d95d4ea0f97ab7e2be9e830b5f36a37b77e100
Title: TEPAM: using both -default and -multiple always includes default
Type: Bug Version: 0.5.2
Submitter: anonymous Created on: 2019-07-31 19:39:26
Subsystem: tepam Assigned To: droll
Priority: 7 High Severity: Important
Status: Open Last Modified: 2019-12-01 09:48:33
Resolution: None Closed By: nobody
    Closed on:
Description:
If I define a procedure argument using both the -default and -multiple flags, then the default value is always included in the list of argument values in the body, even if one or more actual values are defined on the command line.

I expected that the default would only be used if no actual values were specified on the command line.

Ex:

tepam::procedure mytest {
	-args {
		{-myarg -default mydefault -multiple
		}
	}
}  {
	puts $myarg
}


% mytest
mydefault

% mytest -myarg testval1 ; # expect "testval1"
mydefault testval1

% mytest -myarg testval1 -myarg testval2 ; # expect "testval1 testval2"
mydefault testval1 testval2
User Comments: droll added on 2019-12-01 09:48:33:
Comment by 'droll':
The behavior is indeed weird and not expected.
I am questioning if it makes sense to support the -default and -multiple options at the same time, since an argument that can be multiple times used has always the form of a list. So the argument/variable has always a default value in form of an empty list.
I will check how a default value can be supported for these multiple times used arguments, in the way you are expecting it.

aku added on 2019-11-19 22:00:15:
Reassigned to main dev (Andreas Drollinger) for assessment.