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

Free up curly brace syntax. #8578

Merged
merged 7 commits into from
Oct 9, 2014
Merged

Free up curly brace syntax. #8578

merged 7 commits into from
Oct 9, 2014

Conversation

jakebolewski
Copy link
Member

The fate of the {} syntax has been debated in #7941, #7128, #2488, #6739 and many other threads that I cannot dig up at the moment. The current syntax is slated to change in 0.4. My suggestion was outlined by Jeff in #8470. Whatever we decide to do, this change makes it easier to transition to allowing [a, b] to be non-concatenating (#3737) and regularization of Dict syntax #8521.

The parser should probably be changed to reject the {} array / dict syntax during the transition period. Would throwing an error be sufficient? This will be a hugely breaking change so I thought I would solicit some feedback on that.

@jakebolewski jakebolewski added needs decision A decision on this change is needed breaking This change will break code labels Oct 4, 2014
@jakebolewski jakebolewski added this to the 0.4 milestone Oct 4, 2014
@jakebolewski jakebolewski changed the title WIP: Free up curly brace syntax. Free up curly brace syntax. Oct 5, 2014
@tonyhffong
Copy link

I'm thinking, in Lint, I could add a trigger like "Using {} for Any[] may be deprecated in Julia 0.4" for julia VERSION < v"0.4-". It may help 0.3 users future-proof their code a bit. What do you think?

@johnmyleswhite
Copy link
Member

+1 to that

tonyhffong referenced this pull request in tonyhffong/Lint.jl Oct 5, 2014
@tonyhffong
Copy link

So it is done.

@staticfloat
Copy link
Member

This is gonna be another one of those "real" 0.4 changes. :) Now we just need a catchy name like the itruncalpyse.

@elextr
Copy link

elextr commented Oct 6, 2014

bracalypse?

@StefanKarpinski
Copy link
Member

curlpocalypse?

@quinnj
Copy link
Member

quinnj commented Oct 6, 2014

  • The Curly Wars
  • The Curly Curtain
  • Curly Crusades

@tonyhffong
Copy link

Curler iron.

I'll show myself out.

@jakebolewski
Copy link
Member Author

Brought up to date with latest dictionary syntax changes.

@JeffBezanson what are your thoughts on this? I could add a deprecation warning for the time begin for {} arrays similar to dictionaries. I would like to implement #8470 but that means there really is no "deprecation" behavior for {}.

@JeffBezanson
Copy link
Member

For a little while, let's print a deprecation warning but keep it working the same and use Tuple{...} for tuple types.

@StefanKarpinski
Copy link
Member

I wonder if it makes sense to backport some deprecations to the 0.3 branch without breaking any functionality. That way people can have more chance to prepare for some of these bigger changes.

@staticfloat
Copy link
Member

We would have to make sure that the new functionality actually works
though, right?
On Oct 6, 2014 2:55 PM, "Stefan Karpinski" [email protected] wrote:

I wonder if it makes sense to backport some deprecations to the 0.3 branch
without breaking any functionality. That way people can have more chance to
prepare for some of these bigger changes.


Reply to this email directly or view it on GitHub
#8578 (comment).

@StefanKarpinski
Copy link
Member

Yes, of course. Might not be practical.

@jakebolewski
Copy link
Member Author

I feel that this would be better handled by external tools rather than cluttering up the parser in Julia.

@staticfloat
Copy link
Member

Agreed. Some kind of lint tool, or .12 tool or something would be nice. ;)

@jakebolewski
Copy link
Member Author

Updated with deprecation warnings.

tonyhffong referenced this pull request in tonyhffong/Lint.jl Oct 7, 2014
@jakebolewski
Copy link
Member Author

Is this good to merge?

@@ -108,7 +108,7 @@ eval(Sys, :(@deprecate shlib_list dllist))
@deprecate put put!
@deprecate take take!

@deprecate Set(a, b...) Set({a, b...})
@deprecate Set(a, b...) Set([a, b...])
Copy link
Member

Choose a reason for hiding this comment

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

Needs Any to avoid concatenation.

@@ -1812,7 +1818,9 @@
(length= (cdr x) nc)))
(cddr vex)))
(error "inconsistent shape in cell expression"))
`(cell2d ,nr ,nc
(begin
(syntax-deprecation-warning s "{[a,b] [c,d]}" "Any[[a,b] [c,d]]"))
Copy link
Member

Choose a reason for hiding this comment

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

Shouldn't this be {a b; c d} to Any[a b;c d]?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, should be fixed.

@JeffBezanson
Copy link
Member

Merge away.

jakebolewski added a commit that referenced this pull request Oct 9, 2014
@jakebolewski jakebolewski merged commit 264fba7 into master Oct 9, 2014
@jakebolewski jakebolewski deleted the jcb/rmanyarray branch October 9, 2014 14:56
@PythonNut
Copy link
Contributor

I can't help but ask (as I've been looking for the answer for a while now), what do you intend to do with curly braces now that they're "free"?

@JeffBezanson
Copy link
Member

#8470 is one likely possibility, but suggestions welcome!

simonster added a commit to JuliaLang/JuliaDoc that referenced this pull request Oct 15, 2014
simonster added a commit to simonster/Reexport.jl that referenced this pull request Oct 15, 2014
simonster added a commit to JuliaCollections/Iterators.jl that referenced this pull request Oct 15, 2014
simonster added a commit to JuliaIO/HDF5.jl that referenced this pull request Oct 16, 2014
@vtjnash vtjnash modified the milestones: 0.4-projects, 0.4 Oct 17, 2014
@vtjnash
Copy link
Member

vtjnash commented Oct 17, 2014

can we get a NEWS.md item for this? I almost missed it, and it's a pretty significant change.

also some places in the manual might still need to be updated (http://docs.julialang.org/en/latest/manual/noteworthy-differences/?highlight=matlab and http://docs.julialang.org/en/latest/stdlib/punctuation/?highlight=cell)

@catawbasam
Copy link
Contributor

Regarding new uses for brackets, using them for Dict/Hash would align the syntax nicely with Ruby, and move it a step closer to JavaScript/Python/JSON. If they were used for Sets as well, that would match Python.

(I'd love to see Julia's Dict literals match the familiar and finger-friendly syntax of Python/JavaScript/JSON, but would guess further use of ':' might be tough to make work well.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
breaking This change will break code needs decision A decision on this change is needed
Projects
None yet
Development

Successfully merging this pull request may close these issues.