-
-
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
RFC: Deprecate several space insensitivities #11891
Conversation
f (...)
, x [...]
and f {T}
syntaxf (...)
, x [...]
and f {T}
syntax
I'm glad that you make it. Should mention that 1-3 are parsed differently when using inside |
Sadly, yes, but is there really anything that we can do about |
@yuyichao Can you explain the differences, and the rationale behind the differences in parsing? Thanks! |
Not really anything now but this is the most appealing and objective reason for me to deprecate (and possibly disallow) |
@ScottPJones: The issue stems from the following syntax for columns and rows.
|
Is that going to be changed during Arraymageddon? Essentially having a different language |
@ScottPJones: I don't think there are any plans to change it, but feel free to open an issue to discuss it. As it stands, while related, it is really beyond the scope of this PR. |
I should add, if I get someone to agree to merge this, I will go ahead and add a commit to the PR that fixes occurrences of the deprecated syntax in base. |
ref #7128 for that one |
+100.
Of all the cases you found and deprecated, this one surprised me the most. I don't understand what you mean by chaining here — could you give an example where this is useful? |
Something like:
However, I think this is really carrying over idioms from "properly" object oriented languages. I would opt for:
|
You're not deprecating that here though, right? Just saying that maybe putting spaces into that would look nicer to some people? I say down with spaces there too. |
@tkelman: Nope, not touching dots yet, I am tempted though. |
(on master): julia> log(3+5im) . re
1.7631802623080808
julia> [log(3+5im) . re]
1-element Array{Float64,1}:
1.76318
julia> Nullable(log) . value (3)
1.0986122886681096
julia> [Nullable(log) . value (3)]
1x2 Array{Any,2}:
log 3 Wild. |
@mbauman: Holy smokes, that is Pandora's box right there... |
f (...)
, x [...]
and f {T}
syntaxf (...)
, x [...]
, f {T}
, and x .y
syntax
I took the plunge and deprecated the |
Digging through the Femtolisp implementation I was unable to find a way to peek more than one character ahead. If it is possible to shift this deprecation until after tokenisation is done. As a bonus, |
f (...)
, x [...]
, f {T}
, and x .y
syntaxf (...)
, x [...]
, f {T}
, and x .y
syntax
Correction, |
f (...)
, x [...]
, f {T}
, and x .y
syntaxf (...)
, x [...]
, f {T}
, and x .y
syntax
👍 |
I'm not sure we should drop the |
We can always re-allow it if and when we get there. |
I have been able to deprecate everything on the form |
f (...)
, x [...]
, f {T}
, and x .y
syntax
Works for me. |
Deprecates: * `f (...)` #7232 * `x [...]` * `f {T}` * `x .y` * `import x .y` * `use x .y`
Pushed the removals of the deprecated syntax from base. I would like to emphasise that I was trying to remain consistent with the surrounding code rather than trying to establish some sort of new consistent standard when it comes to aligning lines of code. |
Also, for future reference. Running |
The CI failure appears to be the same good old unrelated time out. |
RFC: Deprecate several space insensitivities
Victory!!!!! |
@jakebolewski: Thank you for the news entry and sorry about forgetting to include it myself. |
I like this very much, but worth pointing out that it seems a likely culprit in breaking Tk (and any package that depends on Tk). JuliaGraphics/Tk.jl#104 |
ref JuliaGraphics/Tk.jl@f283145 where @carnaval had a temp fix but not sure if it's suitable for broader consumption |
Was this intended to become an error and not a deprecation?
|
That usually indicates a nasty internal error, basically an uncaught exception in the parser. |
Oh I thought that was intential, it happened in a few packages (only can detect in ones that were passing/loading already) (http://pkg.julialang.org/pulse.html) - a third of those are from JSON, another third from this, and the rest misc I guess. They all seem to be of the general pattern of @phobon's example though. |
should be fixed now |
Regarding the spaces: deprecating function add (x, y)
x + y
end The space after |
Why would you want to use a different convention for defining vs. calling a function? Sounds like a source of inconsistencies without a clear gain to me. |
Not to mention that the code that parses them is the same – this would necessitate making them different. |
Well, defining a function and calling a function are clearly different things, so I don't think it's an inconsistency. It's just that I was forced to change that spacing I've always done up until now to get it working and I don't quite see why. So in my eyes you are breaking code for people without a good reason (apart from implementation convenience). |
Sorry for the hassle. This shell command should fix it: find . -name '*.jl' | xargs perl -i -ple 's/^(\s*function\s+[\w!]+)\s+\(/$1(/' There's no choice that makes allowing space in function definition but not invocation consistent: f (x) # not allowed
f (x) = 2x + 1 # ???
function f (x) # allowed
2x + 1
end No matter what you choose for the middle, it's inconsistent. The only really consistent way to go is to allow all three or none. The fact that it would cause annoying code forking in the parser is simply a symptom of the fact that it's introducing two different – and thus by definition inconsistent – ways of parsing similar syntaxes. If you don't believe me, I invite you to have a go at changing the parser to allow the space in function definitions and but not in function invocations. |
Thank you for the explanation, I now see your point with |
The overall agreement in #7232 seems to be that we should deprecate
f (17)
and now is as good of a time as any to go ahead and do this. This PR takes this even further and deprecatesf (17)
x [17]
rand(17) [17]
function f () 17 end
I also considered deprecating
f .env
andf. env
, but I can see the use for them when it comes to chaining calls. However, an argument for deprecating them would be that we are trying to push the idea that Julia is not a dot-oriented language. Deprecating the dots as well could then allow us to push this direction further. Any thoughts on the matter?I had never written a single line of Lisp until I started on this PR, feedback is most welcome.