Skip to content
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

re-allow line-terminating colons #35088

Closed
bjarthur opened this issue Mar 12, 2020 · 7 comments
Closed

re-allow line-terminating colons #35088

bjarthur opened this issue Mar 12, 2020 · 7 comments

Comments

@bjarthur
Copy link
Contributor

i find it really cramps my code formatting style to not permit colon-defined ranges across multiple lines. and to get around the prohibition requires adding extra parens or defining otherwise needless temporary variables.

disallowed in #4701 because it caused a pythonista problems. can we please consider reverting?

a range has two or three arguments that naturally avail themselves to a line of their own. much more readable that way in many cases. i often want to write:

variable1 = some_really_long_start_expression : 
            another_long_expression_for_the_step : 
            and_lastly_yet_another_expression_for_stop

perfectly readable, right? much more ugly though if i have to:

foo1 = some_really_long_start_expression
foo2 = another_long_expression_for_the_step
foo3 = and_lastly_yet_another_expression_for_stop
variable1 = foo1 : foo2 : foo3 
 
## or, use the lispy variant:

variable1 = some_really_long_start_expression :  (
            another_long_expression_for_the_step ) :  (
            and_lastly_yet_another_expression_for_stop )
@KristofferC
Copy link
Member

(:)(some_really_long_start_expression,
    another_long_expression_for_the_step,
    and_lastly_yet_another_expression_for_stop)

heh.

@bjarthur
Copy link
Contributor Author

ah yes, another quirky alternative. had thought of that too and forgot to put it here. i remember the day colon was deprecated, but can't remember why. can someone point me to the discussion?

my general thoughts with this issue and with #35073 are that we shouldn't be beholden to the past.

as it stands now, for kids growing up learning julia as their very first language, we have to teach them that no, you can't do it this way because there used to be / is this other language that did/does it this way, or for which doing it this way caused problems, and so yea we decided to perpetuate this standard despite how ugly it is.

@KristofferC
Copy link
Member

KristofferC commented Mar 12, 2020

for kids growing up learning julia as their very first language, we have to teach them that no, you can't do it this way because there used to be / is this other language that did/does it this way, or for which doing it this way caused problems, and so yea we decided to perpetuate this standard despite how ugly it is.

Yes? That's the case for a large number of things so it isn't like it will be something unique. Also "kids growing up learning julia as their first language" are not the only users of Julia so (like in this case) considerations to other groups of users also need to be taken.

@JeffBezanson
Copy link
Member

Putting the arguments to infix : on separate lines is also extremely rare and not exactly beautiful.

@Keno
Copy link
Member

Keno commented Mar 12, 2020

Yeah, I'd argue if you need to do this, put parens around the entire expression:

julia> (1:
        2:
        3)
1:2:3

@mbauman
Copy link
Member

mbauman commented Mar 12, 2020

I'm also quite partial to:

start = some_really_long_start_expression
step = another_long_expression_for_the_step
stop = and_lastly_yet_another_expression_for_stop
variable1 = start : step : stop 

Although I'd think if you're putting that much effort into computing steps, you should probably just use range(..., length=) instead since it's often just as easy (but more exact) to compute the length.

@brenhinkeller
Copy link
Contributor

It sounds like this is not planned, given the number of good workarounds available, but feel free to undo if anyone disagrees!

@brenhinkeller brenhinkeller closed this as not planned Won't fix, can't repro, duplicate, stale Nov 20, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants