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

deprecate syntax 1.+. fixes #19089 #22459

Merged
merged 1 commit into from
Jun 26, 2017
Merged

deprecate syntax 1.+. fixes #19089 #22459

merged 1 commit into from
Jun 26, 2017

Conversation

JeffBezanson
Copy link
Member

No description provided.

@JeffBezanson JeffBezanson added deprecation This change introduces or involves a deprecation parser Language parsing and surface syntax labels Jun 21, 2017
@JeffBezanson JeffBezanson force-pushed the jb/fix19089 branch 2 times, most recently from 4df4c25 to 0946a6f Compare June 21, 2017 22:41
Copy link
Member

@Sacha0 Sacha0 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm (modulo the parser changes which I did not pore over)! :)

@Sacha0
Copy link
Member

Sacha0 commented Jun 22, 2017

Might be worth mentioning the need for disambiguation in the documentation somewhere?

@JeffBezanson
Copy link
Member Author

Added a bit on this to the manual.

Copy link
Member

@Sacha0 Sacha0 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm for the manual addition! :)

@ararslan ararslan merged commit 5036a1f into master Jun 26, 2017
@ararslan ararslan deleted the jb/fix19089 branch June 26, 2017 22:33
@jebej
Copy link
Contributor

jebej commented Jun 27, 2017

Was there any argument for why keeping the 1. syntax is preferable? The only two I see in #19089 was that other languages accept it, and that it would be annoying to have people replace all the dots with .0. This does not seem super convincing, and people in that thread also seemed to prefer to disallow 1..

I find that putting spaces for operations like division, multiplication and exponentiation to be fairly jarring as it makes their higher precedence less obvious.

I also think more people use the syntax 1.*[1,2,3]./6 .+ 5 than use the 1. syntax, ie more people will be affected by this change than by disallowing 1.. This is evidenced by this blurb in the manual:

 julia> 1 + 2 + 3
6

julia> 1 - 2
-1

julia> 3*2/12
0.5

(By convention, we tend to space operators more tightly if they get applied before other nearby operators. For instance, we would generally write -x + 2 to reflect that first x gets negated, and then 2 is added to that result.)

@JeffBezanson
Copy link
Member Author

I see numeric literal syntax as much more established than dot operator syntax. Even if 1. were disallowed in julia, it would be easy to read 1.+x as (1.)+x due to the prevalence of 1. as numeric literal syntax. In any case, deprecating 1.+x is the safest thing, since that at least allows us to change its meaning in the future.

martinholters added a commit to HSU-ANT/ACME.jl that referenced this pull request Jul 11, 2017
Remove the `.` in `1./(...)` where it was meant to make `1.` a float but
was actually parsed as `1 ./ (...)` and now gives a deprecation warning
due to JuliaLang/julia#22459.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
deprecation This change introduces or involves a deprecation parser Language parsing and surface syntax
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants