JuliaLang / julia

The Julia Programming Language
https://julialang.org/
MIT License
45.92k stars 5.49k forks source link

use of [] in base #8101

Closed my-little-repository closed 10 years ago

my-little-repository commented 10 years ago

There are a few uses of the [] array (aka None[]) in base. It was suggested in another issue https://github.com/JuliaLang/julia/issues/8092 to provide an element type for the array whenever possible. Here are the occurrences of [] for julia Version 0.3.1-pre+4 (2014-08-22 11:13 UTC) obtained from emacs with the command M-x rgrep RET " \[\]" RET *.jl RET ~/path/to/source/directory RET:

  ./base/pkg.jl:62:generate(pkg::String, license::String; force::Bool=false, authors::Union(String,Array) = [], config::Dict=Dict()) =
  ./base/show.jl:562:            show_block(io, "catch", is(args[2], false) ? [] : args[2], args[3], indent)
  ./base/show.jl:565:            show_block(io, "finally", [], args[4], indent)
  ./base/linalg/lapack.jl:3360:                    &jobvs, &'N', [], &n, 
  ./base/linalg/lapack.jl:3363:                        &lwork, [], info)
  ./base/linalg/lapack.jl:3404:                    &jobvsl, &jobvsr, &'N', [], 
  ./base/linalg/lapack.jl:3408:                    &ldvsr, work, &lwork, [], 
  ./base/linalg/lapack.jl:3450:                    &jobvs, &sort, [], &n, 
  ./base/linalg/lapack.jl:3453:                        rwork, [], info)
  ./base/linalg/lapack.jl:3495:                    &jobvsl, &jobvsr, &'N', [], 
  ./base/linalg/lapack.jl:3499:                    work, &lwork, rwork, [], 
  ./base/abstractarray.jl:794:hvcat(rows::(Int...)) = []
  ./base/dSFMT.jl:589:for (lhs, rhs) in (([], []), 
  ./base/LineEdit.jl:85:complete_line(c::EmptyCompletionProvider, s) = []
  ./base/LineEdit.jl:639:default_completion_cb(::IOBuffer) = []
  ./base/replutil.jl:65:            print(io, "Use square brackets [] for indexing.")
  ./base/array.jl:592:const _default_splice = []
StefanKarpinski commented 10 years ago

I don't think any of these uses are problematic. Empty None arrays aren't bad, they're just kind of limited.