-
Notifications
You must be signed in to change notification settings - Fork 18
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
added builtin list::reverse for YCP list #3
Conversation
* @param list<flex1> v list | ||
* @param integer i1 index of first element | ||
* @param integer i2 index of second element | ||
* @return New list. Changed if offset is correct, otherwise return unchanged list |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is the documentation right? I don't see such parameters
{ | ||
ycp2error ("Cannot reverse 'nil' list"); | ||
return YCPNull (); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is it really problem? If so, then why continue with execution?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
After reading documentation for you method I strongly don't see reason for such error log - Creates new list with reversed order of elements. Return nil if list is nil.
so it is documented as common and expected behavior
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
On Wed, Jun 20, Josef Reidinger wrote:
\* @id list.reverse
\* @short Creates new list with reversed order of elements.
\* @param list<flex1> v list
\* @return New list. Changed if offset is correct, otherwise return unchanged list
*
\* @description
\* Creates new list with reversed order of elements. Return nil if list is nil.
*
\* @usage list::reverse ([0,1,2,3]) -> [3,2,1,0]
\* @usage list::reverse ([]) -> []
*/
- if (v.isNull ())
- {
- ycp2error ("Cannot reverse 'nil' list");
- return YCPNull ();
- }
After reading documentation for you method I strongly don't see reason for such error log -
Creates new list with reversed order of elements. Return nil if list is nil.
so it is documented as common and expected behavior
This is first time I add an ycp builtin.
I just copied code of another builtin and changed functionality
so I have no idea if this error log has some reason or not.
Tschuess,
Thomas Fehr
Thomas Fehr, SuSE Linux Products GmbH, Maxfeldstr. 5, 90409 Nuernberg, Germany
GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer, HRB 16746 (AG Nürnberg)
Tel: +49-911-74053-0, Fax: +49-911-74053-482, Email: fehr@suse.de
GPG public key available.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It depend case by case like for add new element to nil list it is reasonable to have it here.
From my POV reduce is similar case like e.g. sort ( just return list with different order ), so it make sense for me to not have here error message.
@mvidner Can you bring some light here?
Except two minor issues I think it is fine. |
On Wed, Jun 20, Josef Reidinger wrote:
It is present in YCPBuiltinList.xml in libycp/doc so I would assume it Tschuess, Thomas FehrThomas Fehr, SuSE Linux Products GmbH, Maxfeldstr. 5, 90409 Nuernberg, Germany |
@aschnell I see that you write a most lines here. I think that your review would be also nice. We should keep core in good shape. |
@@ -1289,6 +1315,7 @@ | |||
{ "reduce", "flex1 (variable <flex1>, variable <flex1>, const list <flex1>, const block <flex1>)", (void *)l_reduce1, DECL_LOOP|DECL_SYMBOL|DECL_FLEX, ETCf }, | |||
{ "reduce", "flex1 (variable <flex1>, variable <flex2>, const flex1, const list <flex2>, const block <flex1>)", (void *)l_reduce2, DECL_LOOP|DECL_SYMBOL|DECL_FLEX, ETCf }, | |||
{ "swap", "list <flex> (const list <flex>, const integer, const integer)", (void *)l_swaplist, DECL_FLEX, ETCf }, | |||
{ "reverse", "list <flex> (const list <flex>)", (void *)l_reverselist, DECL_FLEX, ETCf }, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well, this line is a little magic for me, but from list of DECL_FLEX it looks like it should also accept nil so DECL_NIL
@mvidner can you point me to some documentation to verify it? ( at least it is strange for me why only select have it here, but almost all function handle nil list )
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
DeclFlags are declared at
enum DeclFlags |
I cannot quite parse your question, but anyway, the problem is that we haven't really agreed on whether nil is an "exception" or a processable value.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see that definition of DeclFlags, but I don't understand it completelly especially part with DECL_NIL. It looks bogus for me. Some methods doesn't have it and still it looks like ti accept nil paramter.
Conflicts: package/yast2-core.changes
Obsoleted by pull rq #7. |
No description provided.