# General Usage

**URL:** https://discourse.julialang.org/c/usage/6.md?page=1053

[Latest](https://discourse.julialang.org/latest.md) · [Categories](https://discourse.julialang.org/categories.md) · [Tags](https://discourse.julialang.org/tags.md)

**Page:** 1054

---

## [No documentation for Base packages at REPL help prompt](https://discourse.julialang.org/t/no-documentation-for-base-packages-at-repl-help-prompt/3068)

<div class="topic-metadata">

**Author:** [@Fab](https://discourse.julialang.org/u/Fab)\
**Replies:** 2\
**Last updated:** [April 18, 2017, 8:28am UTC](https://discourse.julialang.org/t/no-documentation-for-base-packages-at-repl-help-prompt/3068 "2017-04-18T08:28:57Z")

</div>

Hi, when one presses the ? in the REPL to get the help prompt, and then e.g. tries Pkg or Dates, one only gets help?\> Pkg search: Pkg No documentation found. No README.md found for module Base.Pkg. It would be ni…

---

## [Dynamic type declarations](https://discourse.julialang.org/t/dynamic-type-declarations/3239)

<div class="topic-metadata">

**Author:** [@poke1024](https://discourse.julialang.org/u/poke1024)\
**Replies:** 4\
**Last updated:** [April 18, 2017, 3:32am UTC](https://discourse.julialang.org/t/dynamic-type-declarations/3239 "2017-04-18T03:32:27Z")

</div>

Hello, I just stumbled across local f = function(T::Type) return function(x::T) x + 1 end end which gives “UndefVarError: T not defined” due to the inner x::T. This is a bit surprising to me, as using dynamic ty…

---

## [Trying to improve code that provides simple Excel file writing functionality](https://discourse.julialang.org/t/trying-to-improve-code-that-provides-simple-excel-file-writing-functionality/3259)

<div class="topic-metadata">

**Author:** [@askvorts](https://discourse.julialang.org/u/askvorts)\
**Replies:** 2\
**Last updated:** [April 18, 2017, 3:02am UTC](https://discourse.julialang.org/t/trying-to-improve-code-that-provides-simple-excel-file-writing-functionality/3259 "2017-04-18T03:02:33Z")

</div>

The following code surprisingly allows writing to an Excel file (sometimes): using PyCall, Compat f = "myfile.xlsx" vol = 0.15 @pyimport xlsxwriter.workbook as wb wb01 = wb.Workbook(f) worksheet = wb01\[:add\_workshe…

---

## [Error message using JuMP and NLopt](https://discourse.julialang.org/t/error-message-using-jump-and-nlopt/3255)

<div class="topic-metadata">

**Author:** [@jic](https://discourse.julialang.org/u/jic)\
**Replies:** 2\
**Last updated:** [April 18, 2017, 2:57am UTC](https://discourse.julialang.org/t/error-message-using-jump-and-nlopt/3255 "2017-04-18T02:57:36Z")

</div>

Dear Julia experts, I have been using JuMP and NLopt for an optimization problem about a year ago and in trying to rerun the code which worked, I am getting an error message. I have three non-linear constraints (I am on…

---

## [Efficient Broadcast of Heterogeneous AbstractArrays?](https://discourse.julialang.org/t/efficient-broadcast-of-heterogeneous-abstractarrays/3244)

<div class="topic-metadata">

**Author:** [@ChrisRackauckas](https://discourse.julialang.org/u/ChrisRackauckas)\
**Replies:** 10\
**Last updated:** [April 17, 2017, 5:40pm UTC](https://discourse.julialang.org/t/efficient-broadcast-of-heterogeneous-abstractarrays/3244 "2017-04-17T17:40:51Z")

</div>

I have a question about broadcasting on an AbstractArray. Easiest to explain by example. Lets say I have a type type MyArray{T,T2} x::Tuple{Vector{T},Vector{T2}} end A = MyArray((rand(5),rand(5)+im\*rand(5))) where I …

---

## [Accumulating memory in nested loops](https://discourse.julialang.org/t/accumulating-memory-in-nested-loops/3220)

<div class="topic-metadata">

**Author:** [@WenlongGong](https://discourse.julialang.org/u/WenlongGong)\
**Replies:** 10\
**Last updated:** [April 17, 2017, 11:53am UTC](https://discourse.julialang.org/t/accumulating-memory-in-nested-loops/3220 "2017-04-17T11:53:44Z")

</div>

Is it normal that memory usage accumulate when running loops (many iterations including nested loops) inside a function in julia? I’m using Julia-0.4.5. and I think there is garbage collection in julia that helps clean …

---

## [Parallel fetch into pre-allocated memory?](https://discourse.julialang.org/t/parallel-fetch-into-pre-allocated-memory/3238)

<div class="topic-metadata">

**Author:** [@samtkaplan](https://discourse.julialang.org/u/samtkaplan)\
**Replies:** 2\
**Last updated:** [April 17, 2017, 11:40am UTC](https://discourse.julialang.org/t/parallel-fetch-into-pre-allocated-memory/3238 "2017-04-17T11:40:30Z")

</div>

Hello, I’m using fetch to communicate large arrays between nodes on a compute cluster. This results in more memory allocation than I would like. Is there an in-place version of fetch that uses pre-allocated memory? H…

---

## [Summing matrix elements is \>1000X slower than summing vector elements](https://discourse.julialang.org/t/summing-matrix-elements-is-1000x-slower-than-summing-vector-elements/3228)

<div class="topic-metadata">

**Author:** [@wsshin](https://discourse.julialang.org/u/wsshin)\
**Replies:** 8\
**Last updated:** [April 17, 2017, 6:44am UTC](https://discourse.julialang.org/t/summing-matrix-elements-is-1000x-slower-than-summing-vector-elements/3228 "2017-04-17T06:44:39Z")

</div>

I find that summing elements using a for loop is more than 1000 times slower for a matrix than for a vector. Consider the following two functions that sum the elements of a 100×100 matrix and the elements of a vector wi…

---

## [A function got exactly the type it expected, so why is it throwing a TypeError?](https://discourse.julialang.org/t/a-function-got-exactly-the-type-it-expected-so-why-is-it-throwing-a-typeerror/3236)

<div class="topic-metadata">

**Author:** [@pegger0709](https://discourse.julialang.org/u/pegger0709)\
**Replies:** 3\
**Last updated:** [April 17, 2017, 1:16am UTC](https://discourse.julialang.org/t/a-function-got-exactly-the-type-it-expected-so-why-is-it-throwing-a-typeerror/3236 "2017-04-17T01:16:23Z")

</div>

Hello everyone! I’m having a vexing problem with TypeError that is getting in the way of me producing a large amount of needed data. Imagine a function foo whose return type is Array{T,2}, and a more complicated functi…

---

## [Closure vs call overloading](https://discourse.julialang.org/t/closure-vs-call-overloading/3240)

<div class="topic-metadata">

**Author:** [@matthieu](https://discourse.julialang.org/u/matthieu)\
**Replies:** 1\
**Last updated:** [April 16, 2017, 5:26pm UTC](https://discourse.julialang.org/t/closure-vs-call-overloading/3240 "2017-04-16T17:26:08Z")

</div>

I have defined a function F that takes a function fas an argument (say F solves for x such that f(x) = 0). The function F calls the function f within large for loops etc. I have noticed that there was a large difference…

---

## [Nullable with an unknown type](https://discourse.julialang.org/t/nullable-with-an-unknown-type/3078)

<div class="topic-metadata">

**Author:** [@cstjean](https://discourse.julialang.org/u/cstjean)\
**Replies:** 4\
**Last updated:** [April 15, 2017, 11:40pm UTC](https://discourse.julialang.org/t/nullable-with-an-unknown-type/3078 "2017-04-15T23:40:41Z")

</div>

Suppose I have this function, function foo(x) if g(x) h(x) else nothing end end where x can be of many different types, and h(x) is type-stable, in the sense that given x’s type, h(x)'s type…

---

## [Tasks and type stability](https://discourse.julialang.org/t/tasks-and-type-stability/3212)

<div class="topic-metadata">

**Author:** [@mbeltagy](https://discourse.julialang.org/u/mbeltagy)\
**Replies:** 6\
**Last updated:** [April 15, 2017, 10:05pm UTC](https://discourse.julialang.org/t/tasks-and-type-stability/3212 "2017-04-15T22:05:03Z")

</div>

I was experimenting with Julia’s coroutines to do some simple discrete event simulations. I noticed that consume returns a type Any, as shown below. Performance could be much better if the returned type was known. Is th…

---

## [Inner constructor with type parameter not in signature](https://discourse.julialang.org/t/inner-constructor-with-type-parameter-not-in-signature/1413)

<div class="topic-metadata">

**Author:** [@Tamas\_Papp](https://discourse.julialang.org/u/Tamas_Papp)\
**Replies:** 2\
**Last updated:** [April 15, 2017, 5:36am UTC](https://discourse.julialang.org/t/inner-constructor-with-type-parameter-not-in-signature/1413 "2017-04-15T05:36:53Z")

</div>

I would like to “store” some information (basically, a tuple of symbols) in a type parameter, eg immutable Foo{X} end which works: julia\> Foo{(:A)}() Foo{:A}() But at the same time I also want to use an inner constr…

---

## [Scope of variable - is this expected?](https://discourse.julialang.org/t/scope-of-variable-is-this-expected/3227)

<div class="topic-metadata">

**Author:** [@Thiagogps93](https://discourse.julialang.org/u/Thiagogps93)\
**Replies:** 2\
**Last updated:** [April 15, 2017, 2:39am UTC](https://discourse.julialang.org/t/scope-of-variable-is-this-expected/3227 "2017-04-15T02:39:07Z")

</div>

I found this very weird. When I call f(y), the global value of y changes. Apparently, the line: y\[y.\<0\] = 0.01 is running globally. This doesn’t make sense to me. Is it suppose to be like this? function f(y) y\[y.\<0\]…

---

## [Can you expand your functionality based on other package availability?](https://discourse.julialang.org/t/can-you-expand-your-functionality-based-on-other-package-availability/3175)

<div class="topic-metadata">

**Author:** [@richardreeve](https://discourse.julialang.org/u/richardreeve)\
**Replies:** 9\
**Last updated:** [April 14, 2017, 10:46pm UTC](https://discourse.julialang.org/t/can-you-expand-your-functionality-based-on-other-package-availability/3175 "2017-04-14T22:46:24Z")

</div>

I want to expand a package I’ve written to provide extra functionality if another package is installed, but not to make that package compulsory. I don’t know whether it’s possible to do that, but it seems like it would b…

---

## [Elementwise multiplication of arrays across many cores](https://discourse.julialang.org/t/elementwise-multiplication-of-arrays-across-many-cores/3222)

<div class="topic-metadata">

**Author:** [@garrison](https://discourse.julialang.org/u/garrison)\
**Replies:** 5\
**Last updated:** [April 14, 2017, 6:51pm UTC](https://discourse.julialang.org/t/elementwise-multiplication-of-arrays-across-many-cores/3222 "2017-04-14T18:51:48Z")

</div>

I have two parallel arrays a and b of type Vector{Complex128}, and each of them is very large (say, each contains 2^30 elements, thus each requires around 16 GB of RAM). I would like to multiply these arrays elementwise…

---

## [Dangers of abusing multiple dispatch: missing optimization?](https://discourse.julialang.org/t/dangers-of-abusing-multiple-dispatch-missing-optimization/3221)

<div class="topic-metadata">

**Author:** [@aaowens](https://discourse.julialang.org/u/aaowens)\
**Replies:** 1\
**Last updated:** [April 14, 2017, 5:39pm UTC](https://discourse.julialang.org/t/dangers-of-abusing-multiple-dispatch-missing-optimization/3221 "2017-04-14T17:39:48Z")

</div>

I was reading this section in the manual https://docs.julialang.org/en/stable/manual/performance-tips/#the-dangers-of-abusing-multiple-dispatch-aka-more-on-types-with-values-as-parameters , and I realized I’ve done this …

---

## [Plot horizontal error bars in Gadfly or Plots.jl](https://discourse.julialang.org/t/plot-horizontal-error-bars-in-gadfly-or-plots-jl/3216)

<div class="topic-metadata">

**Author:** [@Christopher\_Fisher](https://discourse.julialang.org/u/Christopher_Fisher)\
**Replies:** 2\
**Last updated:** [April 14, 2017, 4:17pm UTC](https://discourse.julialang.org/t/plot-horizontal-error-bars-in-gadfly-or-plots-jl/3216 "2017-04-14T16:17:40Z")

</div>

I was wondering if it is possible to plot horizontal error bars with category labels on the y axis. I attached an example of what I would like to accomplish. Thanks, Chris

---

## [Pointer being freed was not allocated](https://discourse.julialang.org/t/pointer-being-freed-was-not-allocated/3131)

<div class="topic-metadata">

**Author:** [@rveltz](https://discourse.julialang.org/u/rveltz)\
**Replies:** 11\
**Last updated:** [April 14, 2017, 6:05am UTC](https://discourse.julialang.org/t/pointer-being-freed-was-not-allocated/3131 "2017-04-14T06:05:17Z")

</div>

Hi, I am trying to develop LSODA.jl and to overcome some malloc issues. In order to achieve this, I took inspiration from Sundials.jl but I cannot solve the test issue in test1.jl. Basically, calls to lsoda\_free give j…

---

## [ZMQ.Message super slow?](https://discourse.julialang.org/t/zmq-message-super-slow/3193)

<div class="topic-metadata">

**Author:** [@ggggggggg](https://discourse.julialang.org/u/ggggggggg)\
**Replies:** 6\
**Last updated:** [April 13, 2017, 11:35pm UTC](https://discourse.julialang.org/t/zmq-message-super-slow/3193 "2017-04-13T23:35:59Z")

</div>

Hello, I’m trying to use ZMQ.jl to use a PUB socket to send out some data. I’m finding that it is very slow, and that it seems at least partially due to Message. If I @benchmark Message("1") I find that it takes a minim…

---

## [Julia workers: why so many processes? what is --bind-to doing?](https://discourse.julialang.org/t/julia-workers-why-so-many-processes-what-is-bind-to-doing/3200)

<div class="topic-metadata">

**Author:** [@floswald](https://discourse.julialang.org/u/floswald)\
**Replies:** 1\
**Last updated:** [April 13, 2017, 9:43pm UTC](https://discourse.julialang.org/t/julia-workers-why-so-many-processes-what-is-bind-to-doing/3200 "2017-04-13T21:43:10Z")

</div>

I just looked at my htop output after doing addprocs(3). I was surprised by couple of things: why are there so many julia processes? What are all the options at the worker processes? I did julia --help but the --bind-t…

---

## [Creation of large strings much slower on v0.6 than v0.5.0](https://discourse.julialang.org/t/creation-of-large-strings-much-slower-on-v0-6-than-v0-5-0/1808)

<div class="topic-metadata">

**Author:** [@ScottPJones](https://discourse.julialang.org/u/ScottPJones)\
**Replies:** 8\
**Last updated:** [April 13, 2017, 7:10pm UTC](https://discourse.julialang.org/t/creation-of-large-strings-much-slower-on-v0-6-than-v0-5-0/1808 "2017-04-13T19:10:26Z")

</div>

I found v0.6 about 50x slower than v0.5.0 creating a 2GB string: v"0.5.0": julia\> @timev v = String(Vector{UInt8}(2^31)) ; 0.049646 seconds (8 allocations: 2.000 GB, 99.89% gc time) elapsed time (ns): 49645505 gc tim…

---

## [Odd behavior from @threads with bitwise AND](https://discourse.julialang.org/t/odd-behavior-from-threads-with-bitwise-and/3191)

<div class="topic-metadata">

**Author:** [@paulstey](https://discourse.julialang.org/u/paulstey)\
**Replies:** 6\
**Last updated:** [April 13, 2017, 6:36pm UTC](https://discourse.julialang.org/t/odd-behavior-from-threads-with-bitwise-and/3191 "2017-04-13T18:36:14Z")

</div>

I might have misunderstood something about the expected behavior of the bitwise AND or the @threads macro, but I have observed something I think is odd. Suppose we have a function that uses a for loop with @threads to p…

---

## [Coverage of code run at precompile time](https://discourse.julialang.org/t/coverage-of-code-run-at-precompile-time/3198)

<div class="topic-metadata">

**Author:** [@fengyang.wang](https://discourse.julialang.org/u/fengyang.wang)\
**Replies:** 1\
**Last updated:** [April 13, 2017, 6:23pm UTC](https://discourse.julialang.org/t/coverage-of-code-run-at-precompile-time/3198 "2017-04-13T18:23:03Z")

</div>

Coverage doesn’t seem to capture lines which are executed only during package precompile time and not while actually running the tests. Is there a way to also track coverage for these lines? In this example, the process …

---

## [Serializing Julia Composite Type with Inline JavaScript to JSON](https://discourse.julialang.org/t/serializing-julia-composite-type-with-inline-javascript-to-json/3178)

<div class="topic-metadata">

**Author:** [@randyzwitch](https://discourse.julialang.org/u/randyzwitch)\
**Replies:** 7\
**Last updated:** [April 13, 2017, 1:26pm UTC](https://discourse.julialang.org/t/serializing-julia-composite-type-with-inline-javascript-to-json/3178 "2017-04-13T13:26:32Z")

</div>

This is a follow-up to this issue, because I still can’t quite see how to do this. I’d love to be able to create a Julia composite type, and when I serialize to JSON, be able to emit valid JavaScript. The JavaScript lib…

---

## [A test where readcsv and writecsv fail](https://discourse.julialang.org/t/a-test-where-readcsv-and-writecsv-fail/3185)

<div class="topic-metadata">

**Author:** [@yakir12](https://discourse.julialang.org/u/yakir12)\
**Replies:** 4\
**Last updated:** [April 13, 2017, 8:38am UTC](https://discourse.julialang.org/t/a-test-where-readcsv-and-writecsv-fail/3185 "2017-04-13T08:38:32Z")

</div>

Consider the following test. It randomly samples from a bunch of symbols, builds a matrix, writecsvs it, readcsvs it, and then compares the two. It fails with even really small ns. function genmat(collection, n) #ra…

---

## [Inconsistency with multidimensional comprehensions and iterators](https://discourse.julialang.org/t/inconsistency-with-multidimensional-comprehensions-and-iterators/3188)

<div class="topic-metadata">

**Author:** [@rdeits](https://discourse.julialang.org/u/rdeits)\
**Replies:** 5\
**Last updated:** [April 13, 2017, 3:35am UTC](https://discourse.julialang.org/t/inconsistency-with-multidimensional-comprehensions-and-iterators/3188 "2017-04-13T03:35:32Z")

</div>

I found this behavior surprising: julia\> using Iterators: product julia\> p = product(1:2, 1:2) Iterators.Product{Tuple{UnitRange{Int64},UnitRange{Int64}}}(\[(1:2, 1:2)) julia\> \[1 for x in p, y in 1:2\] 8-element Array{I…

---

## [Linux travis tries and fails to open Gtk display](https://discourse.julialang.org/t/linux-travis-tries-and-fails-to-open-gtk-display/3179)

<div class="topic-metadata">

**Author:** [@yakir12](https://discourse.julialang.org/u/yakir12)\
**Replies:** 6\
**Last updated:** [April 12, 2017, 4:06pm UTC](https://discourse.julialang.org/t/linux-travis-tries-and-fails-to-open-gtk-display/3179 "2017-04-12T16:06:43Z")

</div>

I’m writing this package, and wanted to test it on Travis. It includes Gtk.jl. While the osx build works fine, the linux one doesn’t: INFO: Testing Associations WARNING: Method definition depth\_buffer(Gtk.GtkGLArea, B…

---

## [Overloading parametric methods - avoiding ambiguity](https://discourse.julialang.org/t/overloading-parametric-methods-avoiding-ambiguity/3181)

<div class="topic-metadata">

**Author:** [@Ward9250](https://discourse.julialang.org/u/Ward9250)\
**Replies:** 1\
**Last updated:** [April 12, 2017, 3:50pm UTC](https://discourse.julialang.org/t/overloading-parametric-methods-avoiding-ambiguity/3181 "2017-04-12T15:50:25Z")

</div>

Hi. I have an example over overloading a parametric method that results in an ambiguity error I’d like to avoid. Say I have the following default method: abstract Site immutable NaiveCount @inline function count\_alg…

---

## [Adding a \`userimg.jl\` to base for custom build](https://discourse.julialang.org/t/adding-a-userimg-jl-to-base-for-custom-build/3180)

<div class="topic-metadata">

**Author:** [@m-j-w](https://discourse.julialang.org/u/m-j-w)\
**Replies:** 0\
**Last updated:** [April 12, 2017, 1:39pm UTC](https://discourse.julialang.org/t/adding-a-userimg-jl-to-base-for-custom-build/3180 "2017-04-12T13:39:09Z")

</div>

I’ve started trying to use a user image to add default packages, make the REPL a bit more responsive after start and implement a few custom changes to base. I’m now also primarily using Julia 0.6 master, rebuilding more …

[Previous page](https://discourse.julialang.org/c/usage/6.md?page=1052)

[Next page](https://discourse.julialang.org/c/usage/6.md?page=1054)
