String Manipulation fails in 4.3.4 if comments precede the code

Maybe I am missing something, but when I have comments before my
String Manipulation code, the dialog box does not work.

Removing the comments fixes the issue.

I am Using KNIME 4.3.4 on Windows 10 Pro.

Fails:
// this is a comment
string (“KNIME”)

Error message:
Invalid settings:
Ambiguous return type! Use ‘string()’ or another function from the “Convert Type” category to specify the return type.

Works:
string (“KNIME”)

Works as in there is no error and KNIME is added at the end of each row.

Hello @BruceJohnson,

to my knowledge comments in String Manipulation were never possible. But maybe I’m wrong :man_shrugging:

Br,
Ivan

2 Likes

Hi @ipazin , I don’t recall either that it was ever possible. But this is where Knime is a bit inconsistent. Why can you use comments in nodes like the Rule Engine nodes (rule-based splitter/filter, rule engine), but String Manipulation and the Math Formula nodes cannot have comments.

The Expressions nodes of course support comments, because they’re scripting nodes, just like the python, Java and R scripting nodes.

1 Like

Hello @bruno29a,

there’s a lot of talk about inconsistency around KNIME lately. However think we are all missing aspect that certain nodes were developed long time ago (along with KNIME itself, oldest version found, 1.3.5. is from 2008 and guess it already included nodes whose consistency is/was discussed) by a handful of enthusiasts with tools and resources available at that time (:warning:) who might or might not be aware (had a vision) of KNIME today as it is. Having that on mind (including all the consistency we don’t talk about, high attention to backward compatibility, open source story, community driven development) I think a bit more acknowledgment and appreciation for KNIME and its developers is needed (me included :slightly_smiling_face:). That of course doesn’t mean we can’t talk about these inconsistencies, flaws, bugs… and report them as we regularly do.

Br,
Ivan

2 Likes

Hey @ipazin , thanks for raising these valid points.

The appreciation is there, but perhaps not shown enough indeed, and I hope this did not come out as a strong critic. I was just wondering why the comments could be supported in some nodes but not in others, and I think the explanation you gave kinda answered that a bit.

For the String Manipulation in particular, it’s not so much that I want to add comments, but rather that I may be trying to figure out a Manipulation and have different ideas being generated at once as I’m writing down a possible solution, but I can’t write them down temporarily in the manipulation. So I’ve got to copy what I have to notepad and then go back to Knime and add different String Manipulation nodes to test the different manipulations. If I were able to add comments, then I would be able to comment out some of the expressions I want to “disable” and play around, in just 1 same node.

Just a thought :slight_smile:

2 Likes

I started my journey with coding data prep rules in KNIME using the Rule-Based Row Filter. In that dialog, comments are there when you open the dialog! And so it appeared to me that commenting was being encouraged.

There are lots of times that I would like to comment the logic as I go along. I thought that was a best practice!

In this case, I wanted to paste a copy of the string I was trying to parse so that I could compare my results with my goals, much like @bruno29a has described.

On backward compatibility – I appreciate that is an issue, but adding comments doesn’t necessarily reduce functionality in older dialogs that don’t have them…

I did what searching I could to discover what was allowed or not allowed. I suppose it’s documented somewhere, but I couldn’t find it. I appreciate the discussion here.

Consistency can be great, especially for new learners, but it needs to have a purpose. I think there is a lot of good history behind including comments in any code, so this would be a nice feature to see in the future. Short of that, it would have been very helpful if the help button mentioned that comments weren’t allowed… On the other hand, the Help usually describes what is allowed, since what is not allowed is nearly infinite.

1 Like

Hello @BruceJohnson and @bruno29a,

you raised a very well point in my opinion and that is easier and faster expressions testing and comparison so have created a ticket for it. (Internal reference: AP-17715). And while digging a bit found out that there is actually a possibility to have comments inside String Manipulation node (hidden feature). So you can use /*comment*/ syntax but as long as it’s not at the beginning of the expression meaning this:

string($$ROWINDEX$$) /*comment*/

and this:

string(/*comment*/$$ROWINDEX$$)

works just fine! Albeit limited find it very helpful until (hopefully) better commenting support within String Manipulation node :slight_smile:

Br,
Ivan

1 Like

Nice @ipazin , that’s great find! I had tried the /**/ but only as a test, meaning it was at the beginning, so that’s why it did not work. Good to know that we can use it as you suggested.

1 Like

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.