[yast-devel] 'remove' builtin: strange behavior?
Hi! During bug fixing, Jozo came with interesting observation: the default behavior of 'remove' builtin for maps if a map does not contain key, is strange. Documentation: "Remove the value with the key KEY from a map. Returns nil if the key is invalid." The definition for list is similar. So, this means the following code will break quite a bit, if "this key" does not exist. a = remove( a, "this key" ) The proposal is to change the behavior to return the original (unchanged) map/list for CODE11 (openSUSE >= 11.1). Seems code in SVN seems to be quite OK (either uses haskey() or is safe by other means, or broken just because of this behavior ;-)) Any comments or objections? Stano -- To unsubscribe, e-mail: yast-devel+unsubscribe@opensuse.org For additional commands, e-mail: yast-devel+help@opensuse.org
On pá 3. října 2008, Stanislav Visnovsky wrote:
Hi!
During bug fixing, Jozo came with interesting observation: the default behavior of 'remove' builtin for maps if a map does not contain key, is strange.
Documentation: "Remove the value with the key KEY from a map. Returns nil if the key is invalid."
The definition for list is similar. So, this means the following code will break quite a bit, if "this key" does not exist.
a = remove( a, "this key" )
The proposal is to change the behavior to return the original (unchanged) map/list for CODE11 (openSUSE >= 11.1). Seems code in SVN seems to be quite OK (either uses haskey() or is safe by other means, or broken just because of this behavior ;-))
Any comments or objections?
See also bug 396697 j -- Jiri Suchomel SUSE LINUX, s.r.o. e-mail: jsuchome@suse.cz Lihovarská 1060/12 tel: +420 284 028 960 190 00 Praha 9, Czech Republic http://www.suse.cz -- To unsubscribe, e-mail: yast-devel+unsubscribe@opensuse.org For additional commands, e-mail: yast-devel+help@opensuse.org
Dňa Friday 03 October 2008 12:23:49 Stanislav Visnovsky ste napísal:
Hi!
During bug fixing, Jozo came with interesting observation: the default behavior of 'remove' builtin for maps if a map does not contain key, is strange.
Documentation: "Remove the value with the key KEY from a map. Returns nil if the key is invalid."
The definition for list is similar. So, this means the following code will break quite a bit, if "this key" does not exist.
a = remove( a, "this key" )
The proposal is to change the behavior to return the original (unchanged) map/list for CODE11 (openSUSE >= 11.1). Seems code in SVN seems to be quite OK (either uses haskey() or is safe by other means, or broken just because of this behavior ;-))
Any comments or objections?
OK, so I'll change the behavior in trunk for both maps and lists. Stano -- To unsubscribe, e-mail: yast-devel+unsubscribe@opensuse.org For additional commands, e-mail: yast-devel+help@opensuse.org
participants (2)
-
Jiří Suchomel
-
Stanislav Visnovsky