-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
Style guide for creating arrays #32618
Comments
Personally, I think of both [0 1 a-b]
# and
[0 1 a - b] are bad style, and prefer [0 1 (a - b)] Cf discussion in #7128. |
Agreed, main text edited. |
Just to clarify: the above is my personal preference on this, not something directly implied by either the linked discussion or the existing style guide. I linked #7128 because it discusses the unfortunate consequences of whitespace being significant in the surface syntax for I am not sure that the style guide is the best place to fix this. Generally, I think that one should avoid cases where the programmer would have to think about what the parser would do, or clarify with Disallowing one of these forms, eg the one with whitespace between terms (eg |
Longer term we might want to disallow asymmetric spacing around infix operators ( |
Just out of curiosity, why did Julia choose to put both |
|
One concern was that |
Is there anything we are going to do here? Can we close this issue? |
Below is an example on the potentially problematic way of creating arrays. It can be confusing and accidentally lead to bugs:
It may not be obvious in the above code block.
For elaboration, instead of
a - b
, imagine you want to insert some computations into the creation of an array, so that your code stays concise.Now accidentally missing the second space causes unexpected behavior:
It can be uneasy for debugging, suppose the length of
c
is unknown at runtime. So, no clear expectation of how long the composed array should be.(Matlab also has this confusion problem. Python does not as it rejects space as element splitter in the first place.)
The text was updated successfully, but these errors were encountered: