[Bug 239005] New: Proper access of <any> value from maps and lists undocumented, including no docs for YCP function "is()"
https://bugzilla.novell.com/show_bug.cgi?id=239005 Summary: Proper access of <any> value from maps and lists undocumented, including no docs for YCP function "is()" Product: openSUSE 10.2 Version: Final Platform: Other OS/Version: Other Status: NEW Severity: Normal Priority: P5 - None Component: YaST2 AssignedTo: yast2-maintainers@suse.de ReportedBy: odabrunz@novell.com QAContact: jsrain@novell.com There are many places where the is() function (e.g.: "is(WFM::Args(0), string)") is used, but I was unable to find the documentation. This function is needed whenever a value of type "any" is retrieved from a map or list, to use a proper default value. E.g., if the <any> values in my_map can contain <string>s or <integer>s: map<string,any> my_map = ...; sformat("%1", is(my_map[this]:nil, string) ? my_map[this]:"" : ( my_map[this]:nil == nil ? "" : my_map[this]:nil ) ); Most other approaches give error messages or unwanted behaviour as follows: my_map[this] = 123; sformat("%1", my_map[this]:"") -> Can't convert value '123' to type 'string' my_map[this] = "testing"; sformat("%1", my_map[this]:0) -> Can't convert value '"testing"' to type 'const integer' my_map[this] = nil; sformat("%1", my_map[this]:nil) -> no error, but output is 'nil' (and I want the empty string '') The only working alternative that does not need the "is()" function is this: sformat("%1", my_map[this]:nil == nil ? "" : my_map[this]:nil) I believe this is a standard situation and as such both alternatives should be documented. I could not find anything here: http://forgeftp.novell.com/yast/doc/SL10.2/tdg/Book-YaSTReference.html -- Configure bugmail: https://bugzilla.novell.com/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- You are on the CC list for the bug, or are watching someone who is.
https://bugzilla.novell.com/show_bug.cgi?id=239005 ------- Comment #1 from odabrunz@novell.com 2007-01-26 05:02 MST ------- Another reason to document this is that even seasoned YaST2-programmers seem to get this wrong sometimes. I am currently fixing a bug that was caused by such code. It would be helpful to have a reference for "some common programming situations and how to express yourself in YCP". -- Configure bugmail: https://bugzilla.novell.com/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- You are on the CC list for the bug, or are watching someone who is.
https://bugzilla.novell.com/show_bug.cgi?id=239005 lslezak@novell.com changed: What |Removed |Added ---------------------------------------------------------------------------- AssignedTo|yast2-maintainers@suse.de |mvidner@novell.com ------- Comment #2 from lslezak@novell.com 2007-01-29 07:17 MST ------- is() is an YCP built-in, it should be well documented. Martin? -- Configure bugmail: https://bugzilla.novell.com/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- You are on the CC list for the bug, or are watching someone who is.
https://bugzilla.novell.com/show_bug.cgi?id=239005 mvidner@novell.com changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |ASSIGNED ------- Comment #3 from mvidner@novell.com 2007-02-01 08:00 MST ------- Technically "is" is a keyword, so that's why it is missing from the list of built-ins. But of course that is a lame excuse. Its docs is here in the type system chapter: http://forgeftp.novell.com/yast/doc/SL10.2/tdg/id_ycp_types.html -- Configure bugmail: https://bugzilla.novell.com/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- You are on the CC list for the bug, or are watching someone who is.
https://bugzilla.novell.com/show_bug.cgi?id=239005 Stanislav Visnovsky <visnov@novell.com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |visnov@novell.com Component|YaST2 |YaST2 OS/Version|Other |openSUSE 10.2 Product|openSUSE 10.2 |openSUSE 11.0 Version|Final |Factory -- Configure bugmail: https://bugzilla.novell.com/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- You are on the CC list for the bug.
https://bugzilla.novell.com/show_bug.cgi?id=239005 User visnov@novell.com added comment https://bugzilla.novell.com/show_bug.cgi?id=239005#c4 Stanislav Visnovsky <visnov@novell.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|ASSIGNED |RESOLVED Resolution| |FIXED --- Comment #4 from Stanislav Visnovsky <visnov@novell.com> 2008-09-25 04:18:48 MDT --- is() is documented now. Added your excellent code example to a new Wiki page http://en.opensuse.org/YaST/Development/Tricks -- Configure bugmail: https://bugzilla.novell.com/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- You are on the CC list for the bug.
participants (1)
-
bugzilla_noreply@novell.com