-
Notifications
You must be signed in to change notification settings - Fork 6
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
Different formatting of arrays and matrices #29
Comments
This is a good point, we should format multidimensional arrays as we do matrices. We do have a way of tracking if we are inside of an annotation, so you're right, maybe we could use that to determine if we should do this type of foratting. One concern I have is determining when to linebreak in the array. e.g. if we just did curly braces we might end up with something like this:
Another question, how do we handle arrays with more than 3 dimensions (e.g. a 4d array)? I don't think I'll have much time to look deeply into this right now, but I think this would definitely be an improvement. |
I thought a bit on it and I think that I have a consistent solution. Here is an example for 2D and 3D: parameter Integer array2D[2,2] = {
{1,2},
{3,4}
};
parameter Integer array3D[2,2,2] = {
{
{1,2},
{3,4}
},
{
{5,6},
{7,8}
}
}; And now, the explanation of the rules that should make the above possible. With Opening brace
|
I would much prefer a more compact layout, such as parameter Integer array4D[2,2,2,2] = {
{{{1,2}, {3,4}},
{{5,6}, {7,8}}}, When looking at source code it is in my view important to see a large part of code. |
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:
After formatting:
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:
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?
The text was updated successfully, but these errors were encountered: