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

Warning: [a] concatenation is deprecated; use [a;] instead #10290

Closed
juliohm opened this issue Feb 23, 2015 · 10 comments
Closed

Warning: [a] concatenation is deprecated; use [a;] instead #10290

juliohm opened this issue Feb 23, 2015 · 10 comments

Comments

@juliohm
Copy link
Contributor

juliohm commented Feb 23, 2015

Julia Version 0.4.0-dev+3533
Commit f875a54* (2015-02-22 20:56 UTC)
Platform Info:
System: Linux (x86_64-unknown-linux-gnu)
CPU: Intel(R) Core(TM) i7-3632QM CPU @ 2.20GHz
WORD_SIZE: 64
BLAS: libopenblas (USE64BITINT DYNAMIC_ARCH NO_AFFINITY Sandybridge)
LAPACK: libopenblas
LIBM: libopenlibm
LLVM: libLLVM-3.3

julia> [1:3]
WARNING: [a] concatenation is deprecated; use [a;] instead
 in depwarn at ./deprecated.jl:40
 in oldstyle_vcat_warning at ./abstractarray.jl:26
 in vect at abstractarray.jl:29
3-element Array{Int64,1}:
 1
 2
 3

Is this undesired syntax?

@jiahao
Copy link
Member

jiahao commented Feb 23, 2015

The warning is correct for 0.4. See #3737 #8599 and the related issues regarding array concatenation syntax.

Please reopen if the warning is unclear.

@jiahao jiahao closed this as completed Feb 23, 2015
@juliohm
Copy link
Contributor Author

juliohm commented Feb 23, 2015

@jiahao, I did read the threads, but the change is still not clear to me. Could you please elaborate on the current syntax for what I'm trying to achieve?

@jiahao
Copy link
Member

jiahao commented Feb 23, 2015

julia> [1:3;]
3-element Array{Int64,1}:
 1
 2
 3

Please note that 0.4-dev is considered not suitable for general use.

@juliohm
Copy link
Contributor Author

juliohm commented Feb 23, 2015

How is the semicolon solving the issue here?

@jakebolewski
Copy link
Member

[1:2] is an Array{Range,1} of one element, [1:2;] calls vcat which produces a Int[1,2]. The new default behavior is not to concatenate by default.

@juliohm
Copy link
Contributor Author

juliohm commented Feb 23, 2015

Thank you @jakebolewski, I don't like the extra semicolon myself, but will assume Julia devs have a good reason for it.

@garborg
Copy link
Contributor

garborg commented Feb 23, 2015

@juliohm You may prefer collect(1:2). (I do at least, and there was some discussion in the PR comments about that being more correct, even though the deprecation message disagrees.)

@juliohm
Copy link
Contributor Author

juliohm commented Feb 23, 2015

Thank you @garborg, will keep this option in mind.

@JeffBezanson
Copy link
Member

I don't like the extra semicolon myself, but will assume Julia devs have a good reason for it.

The reason is so [x] always means to make a 1-element array with element x. Otherwise [x] would mean something strange like

if isa(x, AbstractArray)
  collect(x)
else
  a = Array(typeof(x),1); a[1] = x; a
end

In the long run we're better off with simpler more predictable abstractions.

@juliohm
Copy link
Contributor Author

juliohm commented Feb 23, 2015

@JeffBezanson nice, KISS philosophy.

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

5 participants