Array: recommended style of code and how to return to the post window

The following rule recommends that you do not add a white space inside the parentheses:

However, the post window always adds whitespace inside parentheses.
So if I evaluate the following code:

[1, 2, 3]

the post window returns the following result:

[ 1, 2, 3 ]

What do you think about changing the recommended code style or the behaviour of the post window?

1 Like

yes I think this is a good idea! Then if we copy paste we have well formatted code.

There are many different places to look in the code though because each Class can be responsible for how it posts - the relevant method is printOn

for Array you would have to fix: Array.sc:printOn

printOn { arg stream;
    if (stream.atLimit, { ^this });
    stream << "[ " ;
    this.printItemsOn(stream);
    stream << " ]" ;
}

List does not have its own printOn method - you have to look at the method for Collection etc

there are other issues with the Post Window as well! see Cosmetic improvements to error printing · Issue #2922 · supercollider/supercollider · GitHub

2 Likes

I think this can be done easily as I can find and replace all such cases using VScode. However, I am not sure if I can also change the following file:

to_string_stub.hpp

I have attached a screenshot:

No, that one is not relevant to your issue!

also just a note that if you change any .cpp files you would need to be building supercollider from source to test.

1 Like

Thank you very much!