-
Notifications
You must be signed in to change notification settings - Fork 6
Open
Description
Hi, I noticed that arrays ({}
) and matrices ([]
) are formatted quite differently.
Arrays are always put into single line (if inside length limit) and matrices are always split per each row.
Let's demonstrate this on a simple example:
Before formatting:
within Somewhere;
model ArraysFormatting
"An example to demonstrate formatting of arrays and matrices"
parameter Real arrayA[3,3] = {{1.0, 2.0, 3.0}, {4.0, 5.0, 6.0}, {7.0, 8.0, 9.0}};
parameter Real arrayB[3,3] = {
{1.0, 2.0, 3.0},
{4.0, 5.0, 6.0},
{7.0, 8.0, 9.0}};
parameter Real matrixA[3,3] = [1.0, 2.0, 3.0; 5.0, 6.0, 7.0; 7.0, 8.0, 9.0];
parameter Real matrixB[3,3] = [
1.0, 2.0, 3.0;
4.0, 5.0, 6.0;
7.0, 8.0, 9.0];
end ArraysFormatting;
After formatting:
within Somewhere;
model ArraysFormatting
"An example to demonstrate formatting of arrays and matrices"
parameter Real arrayA[3,3]={{1.0,2.0,3.0},{4.0,5.0,6.0},{7.0,8.0,9.0}};
parameter Real arrayB[3,3]={{1.0,2.0,3.0},{4.0,5.0,6.0},{7.0,8.0,9.0}};
parameter Real matrixA[3,3]=[
1.0,2.0,3.0;
5.0,6.0,7.0;
7.0,8.0,9.0];
parameter Real matrixB[3,3]=[
1.0,2.0,3.0;
4.0,5.0,6.0;
7.0,8.0,9.0];
end ArraysFormatting;
Is there any reason for that? I guess that it might be connected with annotations, as arrays are used there and one-line syntax works probably works better with that. But outside of annotations, I think that the clearer format is something similar to the current formatting of matrices.
Also, arrays can be multidimensional, so output like that probably makes the most sense:
parameter Real array3D[2,2,2] = {
{
{1.0, 2.0},
{1.0, 2.0}},
{
{1.0, 2.0},
{1.0, 2.0}}};
What do you think? Is it a big challenge to change? I think that the current code is able to detect if parser is inside annotation, isn't it?
Metadata
Metadata
Assignees
Labels
No labels