# General Usage

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

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

**Page:** 922

---

## [Share a module between two Worker processes](https://discourse.julialang.org/t/share-a-module-between-two-worker-processes/13998)

<div class="topic-metadata">

**Author:** [@vitreo12](https://discourse.julialang.org/u/vitreo12)\
**Replies:** 1\
**Last updated:** [November 7, 2018, 5:37pm UTC](https://discourse.julialang.org/t/share-a-module-between-two-worker-processes/13998 "2018-11-07T17:37:30Z")

</div>

Hello everyone, I am currently writing some hard real-time Julia code that relies on importing some modules from source files. The include function, though, with long and complex files, is too slow. I was thinking of …

---

## [Traits in Julia?](https://discourse.julialang.org/t/traits-in-julia/17267)

<div class="topic-metadata">

**Author:** [@peter.wolf](https://discourse.julialang.org/u/peter.wolf)\
**Replies:** 4\
**Last updated:** [November 7, 2018, 5:22pm UTC](https://discourse.julialang.org/t/traits-in-julia/17267 "2018-11-07T17:22:00Z")

</div>

Is there an idiomatic way to do user defined traits ala Scala or Rust, or interfaces ala Java? I want to define ‘contracts’ so I know which functions are available for my arguments. Julia has predefined interfaces suc…

---

## [Why is Bool an Integer?](https://discourse.julialang.org/t/why-is-bool-an-integer/17237)

<div class="topic-metadata">

**Author:** [@tk3369](https://discourse.julialang.org/u/tk3369)\
**Replies:** 1\
**Last updated:** [November 7, 2018, 2:28am UTC](https://discourse.julialang.org/t/why-is-bool-an-integer/17237 "2018-11-07T02:28:51Z")

</div>

I just realized that Bool is a subtype of Integer… why? When I have a function that takes an Integer value I don’t expect to get dispatched with true or false value… That’s very C-like but makes no logical sense to me …

---

## [Usability tweak for Pkg](https://discourse.julialang.org/t/usability-tweak-for-pkg/17203)

<div class="topic-metadata">

**Author:** [@gdkrmr](https://discourse.julialang.org/u/gdkrmr)\
**Replies:** 6\
**Last updated:** [November 6, 2018, 2:14pm UTC](https://discourse.julialang.org/t/usability-tweak-for-pkg/17203 "2018-11-06T14:14:26Z")

</div>

I find myself very often doing something like this: (v1.0) pkg\> up Updating ........................ (v1.0) pkg\> using MyPkg ERROR: expected command. instead got \[using\] I propose that using (and possibly some other…

---

## [Any way to load a module faster even in a fresh session (given the module has been loaded in a previous sessoin)?](https://discourse.julialang.org/t/any-way-to-load-a-module-faster-even-in-a-fresh-session-given-the-module-has-been-loaded-in-a-previous-sessoin/17230)

<div class="topic-metadata">

**Author:** [@Zhong\_Pan](https://discourse.julialang.org/u/Zhong_Pan)\
**Replies:** 2\
**Last updated:** [November 7, 2018, 1:52am UTC](https://discourse.julialang.org/t/any-way-to-load-a-module-faster-even-in-a-fresh-session-given-the-module-has-been-loaded-in-a-previous-sessoin/17230 "2018-11-07T01:52:08Z")

</div>

I know that first time a module is loaded in a new session, Julia needs to go through a lot of compiling so it’s slow, and successive loads are much faster. But I read that recent versions of Julia will pre-compile modul…

---

## [Set Julia environment variables from command line call](https://discourse.julialang.org/t/set-julia-environment-variables-from-command-line-call/17234)

<div class="topic-metadata">

**Author:** [@kilgoretrout](https://discourse.julialang.org/u/kilgoretrout)\
**Replies:** 8\
**Last updated:** [November 7, 2018, 1:35am UTC](https://discourse.julialang.org/t/set-julia-environment-variables-from-command-line-call/17234 "2018-11-07T01:35:51Z")

</div>

Hi, I am using Julia v0.6. I need to execute the following julia commands for a test: ENV\["PYTHON"\] = "\<path to a specific conda virtual env python\>" using MyPackage # needs to call the above python But, I am trying t…

---

## [Warning for array view usage?](https://discourse.julialang.org/t/warning-for-array-view-usage/17189)

<div class="topic-metadata">

**Author:** [@LaurentPlagne](https://discourse.julialang.org/u/LaurentPlagne)\
**Replies:** 13\
**Last updated:** [November 6, 2018, 10:25pm UTC](https://discourse.julialang.org/t/warning-for-array-view-usage/17189 "2018-11-06T22:25:13Z")

</div>

Dear Julia experts, I have been struggling a few hours to understand a massive slow down (x1000) of some computations. I finally spotted the problem to be caused by the use of array views in a context where one (at leas…

---

## [To get the help mode, is "?" the only way?](https://discourse.julialang.org/t/to-get-the-help-mode-is-the-only-way/17199)

<div class="topic-metadata">

**Author:** [@PetrKryslUCSD](https://discourse.julialang.org/u/PetrKryslUCSD)\
**Replies:** 8\
**Last updated:** [November 6, 2018, 7:36pm UTC](https://discourse.julialang.org/t/to-get-the-help-mode-is-the-only-way/17199 "2018-11-06T19:36:25Z")

</div>

Can I get the help mode in some other way than by pressing the questionmark key?

---

## [Using a Base.CFunction in ccall](https://discourse.julialang.org/t/using-a-base-cfunction-in-ccall/13621)

<div class="topic-metadata">

**Author:** [@giordano](https://discourse.julialang.org/u/giordano)\
**Replies:** 8\
**Last updated:** [November 6, 2018, 6:04pm UTC](https://discourse.julialang.org/t/using-a-base-cfunction-in-ccall/13621 "2018-11-06T18:04:06Z")

</div>

I want to do something like this, inside a begin block: begin f(x) = x \* x ptr = @cfunction(f, Cdouble, (Cdouble,)) g(x) = ccall(ptr, Cdouble, (Cdouble,), x) g(1.2) end However this gives the following …

---

## [How to initialize \`UDPSocket\` for broadcast?](https://discourse.julialang.org/t/how-to-initialize-udpsocket-for-broadcast/17149)

<div class="topic-metadata">

**Author:** [@standarddeviant](https://discourse.julialang.org/u/standarddeviant)\
**Replies:** 3\
**Last updated:** [November 6, 2018, 1:04am UTC](https://discourse.julialang.org/t/how-to-initialize-udpsocket-for-broadcast/17149 "2018-11-06T01:04:09Z")

</div>

What is the correct way to initialize a UDPSocket for only sending broadcast packets? I wondered if this would work: julia\> usock=UDPSocket() UDPSocket(init) julia\> send(usock, ip"255.255.255.255", 42000, "test") ERRO…

---

## [Unexpected Type conversion](https://discourse.julialang.org/t/unexpected-type-conversion/17096)

<div class="topic-metadata">

**Author:** [@PauloXavier](https://discourse.julialang.org/u/PauloXavier)\
**Replies:** 4\
**Last updated:** [November 6, 2018, 12:16am UTC](https://discourse.julialang.org/t/unexpected-type-conversion/17096 "2018-11-06T00:16:00Z")

</div>

Im trying to extend some functionality on the framework Persa and got stuck in conversion wich i dont know if its supposed to happen on creating my SparseMatrix. Example code: abstract type AbstractRating{T \<: Number} e…

---

## [Persistent Pkg error](https://discourse.julialang.org/t/persistent-pkg-error/17183)

<div class="topic-metadata">

**Author:** [@joa-quim](https://discourse.julialang.org/u/joa-quim)\
**Replies:** 5\
**Last updated:** [November 5, 2018, 9:05pm UTC](https://discourse.julialang.org/t/persistent-pkg-error/17183 "2018-11-05T21:05:10Z")

</div>

Hi, I’m having a persistent Pkg error while trying to create a new package. Like in other cases I: Created a new repo Webview.jl dev https://github.com/joa-quim/Webview.jl Try to use it But it annoyingly it insists t…

---

## [Loading lots of images](https://discourse.julialang.org/t/loading-lots-of-images/17125)

<div class="topic-metadata">

**Author:** [@robertdj](https://discourse.julialang.org/u/robertdj)\
**Replies:** 5\
**Last updated:** [November 5, 2018, 7:59pm UTC](https://discourse.julialang.org/t/loading-lots-of-images/17125 "2018-11-05T19:59:57Z")

</div>

I have a lot of folders, each with a lot of images. All images have the same size. I want to compute the “average image” of each folder, that is, the pixel-wise average of the images in the folder. With the Images pack…

---

## [What is the appropriate way to clone packages in dockerfile?](https://discourse.julialang.org/t/what-is-the-appropriate-way-to-clone-packages-in-dockerfile/17066)

<div class="topic-metadata">

**Author:** [@jwu](https://discourse.julialang.org/u/jwu)\
**Replies:** 7\
**Last updated:** [November 5, 2018, 6:57pm UTC](https://discourse.julialang.org/t/what-is-the-appropriate-way-to-clone-packages-in-dockerfile/17066 "2018-11-05T18:57:53Z")

</div>

I am trying to clone or add a package from my repo in dockerfile, I am using: RUN julia -e 'import Pkg; Pkg.clone("https://github.com/jingpengw/GoogleCloud.jl.git")' but I was told that I should use add rather than clo…

---

## [How is factorial(BigInt) so fast?](https://discourse.julialang.org/t/how-is-factorial-bigint-so-fast/17166)

<div class="topic-metadata">

**Author:** [@frank](https://discourse.julialang.org/u/frank)\
**Replies:** 10\
**Last updated:** [November 5, 2018, 4:32pm UTC](https://discourse.julialang.org/t/how-is-factorial-bigint-so-fast/17166 "2018-11-05T16:32:47Z")

</div>

As an experiment, I copy/pasted Julia’s factorial() function and renamed it. But when I use it to evaluate a bigint, it is way slower than Julia’s factorial(BigInt). If the base function uses the same code, then why is …

---

## [How to use @test\_warn?](https://discourse.julialang.org/t/how-to-use-test-warn/15557)

<div class="topic-metadata">

**Author:** [@cstook](https://discourse.julialang.org/u/cstook)\
**Replies:** 5\
**Last updated:** [November 5, 2018, 3:49pm UTC](https://discourse.julialang.org/t/how-to-use-test-warn/15557 "2018-11-05T15:49:16Z")

</div>

I don’t understand how to use @test\_warn. MWE of my problem is below. \_ \_ \_ \_(\_)\_ | Documentation: https://docs.julialang.org (\_) | (\_) (\_) | \_ \_ \_| |\_ \_\_ \_ | Type "?" for…

---

## [how to get color on command line with less](https://discourse.julialang.org/t/how-to-get-color-on-command-line-with-less/17173)

<div class="topic-metadata">

**Author:** [@Joris\_Pinkse](https://discourse.julialang.org/u/Joris_Pinkse)\
**Replies:** 0\
**Last updated:** [November 5, 2018, 3:29pm UTC](https://discourse.julialang.org/t/how-to-get-color-on-command-line-with-less/17173 "2018-11-05T15:29:37Z")

</div>

I’d like to get color terminal output even when piping through more/less. I had expected julia --color=yes myprogram.jl | less -R to produce color output, but it doesn’t. What are the alternatives? Thanks! (Julia …

---

## [Enumerate loop: problem with indexing (method error)](https://discourse.julialang.org/t/enumerate-loop-problem-with-indexing-method-error/17168)

<div class="topic-metadata">

**Author:** [@axelle](https://discourse.julialang.org/u/axelle)\
**Replies:** 3\
**Last updated:** [November 5, 2018, 2:53pm UTC](https://discourse.julialang.org/t/enumerate-loop-problem-with-indexing-method-error/17168 "2018-11-05T14:53:56Z")

</div>

Good afternoon, Using an enumerate loop, I get an error method when trying to fill in a vector with value calculated at each iteration of the loop. Would anyone know how to solve it? Many thanks for your help. grid = c…

---

## [Return type of blockdiag?](https://discourse.julialang.org/t/return-type-of-blockdiag/17172)

<div class="topic-metadata">

**Author:** [@teored90](https://discourse.julialang.org/u/teored90)\
**Replies:** 1\
**Last updated:** [November 5, 2018, 2:43pm UTC](https://discourse.julialang.org/t/return-type-of-blockdiag/17172 "2018-11-05T14:43:46Z")

</div>

I was studying the type stability of my code (I’m still very bad at it) and I bumped into this weird behavior with SparseArrays.blockdiag(): julia\> using SparseArrays julia\> A = \[sprand(100, 100, .1) for i = 1: 15\]; @co…

---

## [Dot (inner product)](https://discourse.julialang.org/t/dot-inner-product/17170)

<div class="topic-metadata">

**Author:** [@davidzentlermunro](https://discourse.julialang.org/u/davidzentlermunro)\
**Replies:** 2\
**Last updated:** [November 5, 2018, 2:22pm UTC](https://discourse.julialang.org/t/dot-inner-product/17170 "2018-11-05T14:22:32Z")

</div>

I’ve just upgraded to v1.0.1 and I’m getting a undefined variable error when I try and use dot(a,b) - error says that dot is not defined. Documentation implies that dot function should still work: Linear Algebra · The Ju…

---

## [Question regarding metapackages under v1.0](https://discourse.julialang.org/t/question-regarding-metapackages-under-v1-0/17164)

<div class="topic-metadata">

**Author:** [@braamvandyk](https://discourse.julialang.org/u/braamvandyk)\
**Replies:** 14\
**Last updated:** [November 5, 2018, 1:08pm UTC](https://discourse.julialang.org/t/question-regarding-metapackages-under-v1-0/17164 "2018-11-05T13:08:45Z")

</div>

I have noticed that metapackages behave differently under v1.0 than under v0.6. Specifically, I added ValidatedNumerics to my v1.0.1 installation. While this installs the various Interval\* packages, they are not availabl…

---

## [A question regarding BigFloat](https://discourse.julialang.org/t/a-question-regarding-bigfloat/17106)

<div class="topic-metadata">

**Author:** [@a-berg](https://discourse.julialang.org/u/a-berg)\
**Replies:** 11\
**Last updated:** [November 5, 2018, 11:01am UTC](https://discourse.julialang.org/t/a-question-regarding-bigfloat/17106 "2018-11-05T11:01:05Z")

</div>

I was using BigFloats to compute the Harmonic series (naïve implementation) with arbitrary precision, and it was brought to my attention a bug in my code: in particular, the difference between BigFloat(1/i) and 1/BigFloa…

---

## [Help with package update](https://discourse.julialang.org/t/help-with-package-update/17156)

<div class="topic-metadata">

**Author:** [@rveltz](https://discourse.julialang.org/u/rveltz)\
**Replies:** 1\
**Last updated:** [November 5, 2018, 8:14am UTC](https://discourse.julialang.org/t/help-with-package-update/17156 "2018-11-05T08:14:04Z")

</div>

Hi, I am trying to help to port JacobiDavidson.jl to Julia 1.0. I have done most of conversions but there is an issue I can’t resolve. Is it enough for a PR or it should be a working update? Best Romain

---

## [Returning Inf of specific type](https://discourse.julialang.org/t/returning-inf-of-specific-type/17138)

<div class="topic-metadata">

**Author:** [@lostella](https://discourse.julialang.org/u/lostella)\
**Replies:** 5\
**Last updated:** [November 4, 2018, 8:37pm UTC](https://discourse.julialang.org/t/returning-inf-of-specific-type/17138 "2018-11-04T20:37:46Z")

</div>

I would like for a function to return Inf in some cases. However, the type of Inf should depend on the floating type of the function arguments. That is, I would like the following function f(x::R) where {R \<: Real} if…

---

## [If control flow 40X slow down](https://discourse.julialang.org/t/if-control-flow-40x-slow-down/17144)

<div class="topic-metadata">

**Author:** [@Donut\_Meepo](https://discourse.julialang.org/u/Donut_Meepo)\
**Replies:** 11\
**Last updated:** [November 4, 2018, 8:23pm UTC](https://discourse.julialang.org/t/if-control-flow-40x-slow-down/17144 "2018-11-04T20:23:16Z")

</div>

Hi, By adding some work in the if statement (test2 function), even though the evaluation always false and so nothing has been done in the if block, I got 40X slow down compare to real nothing (test) in the if blocks. f…

---

## [Get values of symbols inside a function](https://discourse.julialang.org/t/get-values-of-symbols-inside-a-function/848)

<div class="topic-metadata">

**Author:** [@Ronis\_BR](https://discourse.julialang.org/u/Ronis_BR)\
**Replies:** 48\
**Last updated:** [November 4, 2018, 7:59pm UTC](https://discourse.julialang.org/t/get-values-of-symbols-inside-a-function/848 "2018-11-04T19:59:43Z")

</div>

Hi guys! I have one problem: if I have an array of symbols, how can I get their values inside a function scope? Something like this: function f(a::Array{Symbols,1}) a = 1 b = 2 c = 3 # Get the values o…

---

## [Travis: Cannot add package with the same name or uuid as the project](https://discourse.julialang.org/t/travis-cannot-add-package-with-the-same-name-or-uuid-as-the-project/17132)

<div class="topic-metadata">

**Author:** [@peterkovesi](https://discourse.julialang.org/u/peterkovesi)\
**Replies:** 3\
**Last updated:** [November 4, 2018, 6:32pm UTC](https://discourse.julialang.org/t/travis-cannot-add-package-with-the-same-name-or-uuid-as-the-project/17132 "2018-11-04T18:32:57Z")

</div>

I am trying to set up a new package. I am using what I believe to be a standard Travis script as per https://github.com/JuliaLang/Example.jl/blob/master/.travis.yml - julia -e 'using Pkg; Pkg.add(pwd()); Pkg.build("Im…

---

## [Extreme memory usage seemingly caused by using the functions \`map\` and \`Iterators.flatten\`](https://discourse.julialang.org/t/extreme-memory-usage-seemingly-caused-by-using-the-functions-map-and-iterators-flatten/17141)

<div class="topic-metadata">

**Author:** [@SZJX](https://discourse.julialang.org/u/SZJX)\
**Replies:** 2\
**Last updated:** [November 4, 2018, 5:40pm UTC](https://discourse.julialang.org/t/extreme-memory-usage-seemingly-caused-by-using-the-functions-map-and-iterators-flatten/17141 "2018-11-04T17:40:24Z")

</div>

I had a program that was running extremely slowly so I ran memory benchmark on it. Apparently one particular line of code accumulated a whopping 27GB of memory allocation… (lgamma(theta(pyp)) - lgamma(theta(pyp)…

---

## [Add cross-references \`\[\`foo\`\](@ref)\` to functions with same name but different arguments](https://discourse.julialang.org/t/add-cross-references-foo-ref-to-functions-with-same-name-but-different-arguments/17113)

<div class="topic-metadata">

**Author:** [@zygmuntszpak](https://discourse.julialang.org/u/zygmuntszpak)\
**Replies:** 1\
**Last updated:** [November 4, 2018, 2:01am UTC](https://discourse.julialang.org/t/add-cross-references-foo-ref-to-functions-with-same-name-but-different-arguments/17113 "2018-11-04T02:01:16Z")

</div>

Hi all, When writing documentation for a function, is it possible to create cross-references (i.e. @ref) to functions that have the same name but different dispatch signature? Below is a simplified example of what I hav…

---

## [How do you address side effects for callable types?](https://discourse.julialang.org/t/how-do-you-address-side-effects-for-callable-types/17072)

<div class="topic-metadata">

**Author:** [@Roger-luo](https://discourse.julialang.org/u/Roger-luo)\
**Replies:** 6\
**Last updated:** [November 3, 2018, 7:30pm UTC](https://discourse.julialang.org/t/how-do-you-address-side-effects-for-callable-types/17072 "2018-11-03T19:30:13Z")

</div>

Say there is a callable type implemented with some side effect, but the variable name can be something without !, which looks like count\_foo = 0 struct Foo a::Int end (::Foo)(x::Int) = (global count\_foo; count\_foo…

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

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