Index: doc/Class.3 =================================================================== diff -u -rc210a16eea562921715652f023bc6d07e4e25ed2 -r8f64a468d8bb53f2ba317c8c738c2d3a24243980 --- doc/Class.3 (.../Class.3) (revision c210a16eea562921715652f023bc6d07e4e25ed2) +++ doc/Class.3 (.../Class.3) (revision 8f64a468d8bb53f2ba317c8c738c2d3a24243980) @@ -988,8 +988,11 @@ \fIobj\fR \fIpropertyName\fR \fBadd\fR \fIelement\fR ?\fIindex\fR? Adding \fIelement\fR to the managed list value, at the list position given by \fIindex\fR (by default: 0)\&. .TP -\fIobj\fR \fIpropertyName\fR \fBdelete\fR \fIelementPattern\fR -Removing one or multiple elements from the managed list value which match \fIelementPattern\fR\&. \fIelementPattern\fR can contain matching characters (see \fBstring match\fR)\&. +\fIobj\fR \fIpropertyName\fR \fBdelete\fR ?\fB-nocomplain\fR? \fIelementPattern\fR +Removing the first occurrence of an element from the managed list +value which matches \fIelementPattern\fR\&. \fIelementPattern\fR can +contain matching characters (see \fBstring match\fR)\&. An error will +be thrown if there is no match, unless \fB-nocomplain\fR is set\&. .RE .sp By setting \fB-configurable\fR to \fBtrue\fR (the default), the @@ -1093,10 +1096,11 @@ \fIobj\fR \fIvariableName\fR \fBadd\fR \fIelement\fR ?\fIindex\fR? Adding \fIelement\fR to the managed list value, at the list position given by \fIindex\fR (by default: 0)\&. .TP -\fIobj\fR \fIvariableName\fR \fBdelete\fR \fIelementPattern\fR -Removing one or multiple elements from the managed list value which -match \fIelementPattern\fR\&. \fIelementPattern\fR can contain matching -characters (see \fBstring match\fR)\&. +\fIobj\fR \fIvariableName\fR \fBdelete\fR ?\fB-nocomplain\fR? \fIelementPattern\fR +Removing the first occurrence of an element from the managed list +value which matches \fIelementPattern\fR\&. \fIelementPattern\fR can +contain matching characters (see \fBstring match\fR)\&. An error will +be thrown if there is no match, unless \fB-nocomplain\fR is set\&. .RE .sp By setting \fB-configurable\fR to \fBtrue\fR, the variable can be Index: doc/Object.3 =================================================================== diff -u -rc210a16eea562921715652f023bc6d07e4e25ed2 -r8f64a468d8bb53f2ba317c8c738c2d3a24243980 --- doc/Object.3 (.../Object.3) (revision c210a16eea562921715652f023bc6d07e4e25ed2) +++ doc/Object.3 (.../Object.3) (revision 8f64a468d8bb53f2ba317c8c738c2d3a24243980) @@ -1287,8 +1287,11 @@ \fIobj\fR \fIpropertyName\fR \fBadd\fR \fIelement\fR ?\fIindex\fR? Adding \fIelement\fR to the managed list value, at the list position given by \fIindex\fR (by default: 0)\&. .TP -\fIobj\fR \fIpropertyName\fR \fBdelete\fR \fIelementPattern\fR -Removing one or multiple elements from the managed list value which match \fIelementPattern\fR\&. \fIelementPattern\fR can contain matching characters (see \fBstring match\fR)\&. +\fIobj\fR \fIpropertyName\fR \fBdelete\fR ?\fB-nocomplain\fR? \fIelementPattern\fR +Removing the first occurrence of an element from the managed list +value which matches \fIelementPattern\fR\&. \fIelementPattern\fR can +contain matching characters (see \fBstring match\fR)\&. An error will +be thrown if there is no match, unless \fB-nocomplain\fR is set\&. .RE .sp By setting \fB-configurable\fR to \fBtrue\fR (the default), the @@ -1430,10 +1433,11 @@ \fIobj\fR \fIvariableName\fR \fBadd\fR \fIelement\fR ?\fIindex\fR? Adding \fIelement\fR to the managed list value, at the list position given by \fIindex\fR (by default: 0)\&. .TP -\fIobj\fR \fIvariableName\fR \fBdelete\fR \fIelementPattern\fR -Removing one or multiple elements from the managed list value which -match \fIelementPattern\fR\&. \fIelementPattern\fR can contain matching -characters (see \fBstring match\fR)\&. +\fIobj\fR \fIvariableName\fR \fBdelete\fR ?\fB-nocomplain\fR? \fIelementPattern\fR +Removing the first occurrence of an element from the managed list +value which matches \fIelementPattern\fR\&. \fIelementPattern\fR can +contain matching characters (see \fBstring match\fR)\&. An error will +be thrown if there is no match, unless \fB-nocomplain\fR is set\&. .RE .sp By setting \fB-configurable\fR to \fBtrue\fR, the variable can be Index: doc/property.man.inc =================================================================== diff -u -rc210a16eea562921715652f023bc6d07e4e25ed2 -r8f64a468d8bb53f2ba317c8c738c2d3a24243980 --- doc/property.man.inc (.../property.man.inc) (revision c210a16eea562921715652f023bc6d07e4e25ed2) +++ doc/property.man.inc (.../property.man.inc) (revision 8f64a468d8bb53f2ba317c8c738c2d3a24243980) @@ -57,8 +57,12 @@ [list_begin definitions] [def "[arg obj] [arg propertyName] [method add] [arg element] [opt [arg index]]"] Adding [arg element] to the managed list value, at the list position given by [arg index] (by default: 0). -[def "[arg obj] [arg propertyName] [method delete] [arg elementPattern]"] -Removing one or multiple elements from the managed list value which match [arg elementPattern]. [arg elementPattern] can contain matching characters (see [cmd "string match"]). +[def "[arg obj] [arg propertyName] [method delete] [opt [option -nocomplain]] [arg elementPattern]"] +Removing the first occurrence of an element from the managed list +value which matches [arg elementPattern]. [arg elementPattern] can +contain matching characters (see [cmd "string match"]). An error will +be thrown if there is no match, unless [option -nocomplain] is set. + [list_end] Index: doc/variable.man.inc =================================================================== diff -u -rc210a16eea562921715652f023bc6d07e4e25ed2 -r8f64a468d8bb53f2ba317c8c738c2d3a24243980 --- doc/variable.man.inc (.../variable.man.inc) (revision c210a16eea562921715652f023bc6d07e4e25ed2) +++ doc/variable.man.inc (.../variable.man.inc) (revision 8f64a468d8bb53f2ba317c8c738c2d3a24243980) @@ -50,10 +50,12 @@ [list_begin definitions] [def "[arg obj] [arg variableName] [method add] [arg element] [opt [arg index]]"] Adding [arg element] to the managed list value, at the list position given by [arg index] (by default: 0). -[def "[arg obj] [arg variableName] [method delete] [arg elementPattern]"] -Removing one or multiple elements from the managed list value which -match [arg elementPattern]. [arg elementPattern] can contain matching -characters (see [cmd "string match"]). +[def "[arg obj] [arg variableName] [method delete] [opt [option -nocomplain]] [arg elementPattern]"] +Removing the first occurrence of an element from the managed list +value which matches [arg elementPattern]. [arg elementPattern] can +contain matching characters (see [cmd "string match"]). An error will +be thrown if there is no match, unless [option -nocomplain] is set. + [list_end] [para] Index: library/nx/nx.tcl =================================================================== diff -u -r470bd5f54e0da47e4eda094ee9f4aa2ba7af18f1 -r8f64a468d8bb53f2ba317c8c738c2d3a24243980 --- library/nx/nx.tcl (.../nx.tcl) (revision 470bd5f54e0da47e4eda094ee9f4aa2ba7af18f1) +++ library/nx/nx.tcl (.../nx.tcl) (revision 8f64a468d8bb53f2ba317c8c738c2d3a24243980) @@ -2040,8 +2040,8 @@ set vspec [:namedParameterSpec {} value $options_single] set addArgs [list obj prop $vspec {pos 0}] :public object method value=add $addArgs {::nsf::next [list $obj $prop $value $pos]} - set delArgs [list -nocomplain:switch obj prop $vspec] - :public object method value=delete $delArgs {::nsf::next [list -nocomplain=$nocomplain $obj $prop $value]} + set delArgs [list obj prop -nocomplain:switch $vspec] + :public object method value=delete $delArgs {::nsf::next [list $obj $prop -nocomplain=$nocomplain $value]} } else { # TODO should we deactivate add/delete? } @@ -2198,11 +2198,15 @@ } } - ::nx::VariableSlot public method value=delete {-nocomplain:switch obj prop value} { + ::nx::VariableSlot public method value=delete {obj prop -nocomplain:switch value} { set old [::nsf::var::get $obj $prop] set p [lsearch -glob $old $value] - if {$p>-1} {::nsf::var::set $obj $prop [lreplace $old $p $p]} else { - return -code error "$value is not a $prop of $obj (valid are: $old)" + if {$p > -1} { + ::nsf::var::set $obj $prop [lreplace $old $p $p] + } elseif {!$nocomplain} { + return -code error "$obj: '$value' is not in variable '$prop' (values are: '$old')" + } else { + return $old } } Index: tests/parameters.test =================================================================== diff -u -r470bd5f54e0da47e4eda094ee9f4aa2ba7af18f1 -r8f64a468d8bb53f2ba317c8c738c2d3a24243980 --- tests/parameters.test (.../parameters.test) (revision 470bd5f54e0da47e4eda094ee9f4aa2ba7af18f1) +++ tests/parameters.test (.../parameters.test) (revision 8f64a468d8bb53f2ba317c8c738c2d3a24243980) @@ -1298,6 +1298,10 @@ set count [nx::test cget -count] nx::test configure -count 1 ? {p2 sexes delete female} {m m} + ? {p2 sexes delete female} {::p2: 'f' is not in variable 'sexes' (values are: 'm m')} + ? {p2 sexes delete -nocomplain female} {m m} + ? {p2 sexes delete -nocomplain male} {m} + ? {p2 sexes get} {m} nx::test configure -count $count Person public method bar {s:sex,0..*,slot=::Person::slot::sexes,convert} {return $s} Index: tests/properties.test =================================================================== diff -u -r275da34d3d7a874a451eced58242b738c8a37d1a -r8f64a468d8bb53f2ba317c8c738c2d3a24243980 --- tests/properties.test (.../properties.test) (revision 275da34d3d7a874a451eced58242b738c8a37d1a) +++ tests/properties.test (.../properties.test) (revision 8f64a468d8bb53f2ba317c8c738c2d3a24243980) @@ -342,6 +342,14 @@ ? {c1 eval {:d add x}} {::c1: unable to dispatch method 'd'} ? {c1 add-local d x} {x d1} ? {c1 e add x} {x e1} + ? {c1 e delete x} {e1} + ? {c1 e get} {e1} + ? {c1 e delete -nocomplain x} {e1} + ? {c1 e delete x} "::c1: 'x' is not in variable 'e' (values are: 'e1')" + ? {c1 e delete -nocomplain e1} "" + ? {c1 e get} "" + ? {c1 e unset} "" + ? {c1 e get} {can't read "e": no such variable} # # check incremental operations for variables @@ -355,8 +363,15 @@ ? {c1 eval {:vd add x}} {::c1: unable to dispatch method 'vd'} ? {c1 add-local vd x} {x vd1} ? {c1 ve add x} {x ve1} + ? {c1 ve delete x} {ve1} + ? {c1 ve get} {ve1} + ? {c1 ve delete -nocomplain x} {ve1} + ? {c1 ve delete x} "::c1: 'x' is not in variable 've' (values are: 've1')" + ? {c1 ve delete -nocomplain ve1} "" + ? {c1 ve get} "" + ? {c1 ve unset} "" + ? {c1 ve get} {can't read "ve": no such variable} - # # The accessor should be a forwarder due to incremental #