# General Usage

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

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

**Page:** 976

---

## [Question about the selection mechanism of multiple dispatch](https://discourse.julialang.org/t/question-about-the-selection-mechanism-of-multiple-dispatch/11175)

<div class="topic-metadata">

**Author:** [@Ronis\_BR](https://discourse.julialang.org/u/Ronis_BR)\
**Replies:** 3\
**Last updated:** [May 27, 2018, 9:11pm UTC](https://discourse.julialang.org/t/question-about-the-selection-mechanism-of-multiple-dispatch/11175 "2018-05-27T21:11:24Z")

</div>

Hi guys! I am having problems to understand the mechanism of multiple dispatch. The documentation has the following text: When a function is applied to a particular tuple of arguments, the most specific method applica…

---

## [ForwardDiff problem: Cannot \`convert\` an object of type ForwardDiff.Dual{](https://discourse.julialang.org/t/forwarddiff-problem-cannot-convert-an-object-of-type-forwarddiff-dual/11167)

<div class="topic-metadata">

**Author:** [@fastwave](https://discourse.julialang.org/u/fastwave)\
**Replies:** 2\
**Last updated:** [May 27, 2018, 3:12pm UTC](https://discourse.julialang.org/t/forwarddiff-problem-cannot-convert-an-object-of-type-forwarddiff-dual/11167 "2018-05-27T15:12:29Z")

</div>

Hi, I am really stuck for a while now, I cannot seem to use ForwardDiff to calculate second derivatives of a function. It works for the first derivative, but the same approach applied to the first derivative crashes wit…

---

## [Build 0.6.2 from source: problem with pcre2 link](https://discourse.julialang.org/t/build-0-6-2-from-source-problem-with-pcre2-link/11180)

<div class="topic-metadata">

**Author:** [@mcreel](https://discourse.julialang.org/u/mcreel)\
**Replies:** 2\
**Last updated:** [May 27, 2018, 9:46am UTC](https://discourse.julialang.org/t/build-0-6-2-from-source-problem-with-pcre2-link/11180 "2018-05-27T09:46:23Z")

</div>

Line 8 of dep/pcre.mk attempts to download using https, which the site referred to does not allow. Replacing “https” with “ftp” so that the line reads $(JLDOWNLOAD) $@ ftp://ftp.csx.cam.ac.uk/pub/software/programming/p…

---

## [The 4 kinds of Metapackages / API / Higher level packages](https://discourse.julialang.org/t/the-4-kinds-of-metapackages-api-higher-level-packages/10947)

<div class="topic-metadata">

**Author:** [@oxinabox](https://discourse.julialang.org/u/oxinabox)\
**Replies:** 2\
**Last updated:** [May 27, 2018, 2:00am UTC](https://discourse.julialang.org/t/the-4-kinds-of-metapackages-api-higher-level-packages/10947 "2018-05-27T02:00:09Z")

</div>

I was thinking about this, we have as I count it, 3 different kinds of Metapackage/Higher level package. Though the term Metapackage is used only for the last 2. I think especially for Class C maybe? Class A: \*Base …

---

## [Deprecation Warnings Not Showing](https://discourse.julialang.org/t/deprecation-warnings-not-showing/11171)

<div class="topic-metadata">

**Author:** [@JaredCrean2](https://discourse.julialang.org/u/JaredCrean2)\
**Replies:** 2\
**Last updated:** [May 27, 2018, 12:13am UTC](https://discourse.julialang.org/t/deprecation-warnings-not-showing/11171 "2018-05-27T00:13:20Z")

</div>

I am upgrading a package to Julia 0.6.2, and I noticed deprecation warnings in the Travis logs that are not present when I run the tests locally. The output from the local run (both stdout and errout) is here, and the o…

---

## [How to know if the terminal supports color (escape sequences)](https://discourse.julialang.org/t/how-to-know-if-the-terminal-supports-color-escape-sequences/11173)

<div class="topic-metadata">

**Author:** [@Ronis\_BR](https://discourse.julialang.org/u/Ronis_BR)\
**Replies:** 0\
**Last updated:** [May 26, 2018, 11:01pm UTC](https://discourse.julialang.org/t/how-to-know-if-the-terminal-supports-color-escape-sequences/11173 "2018-05-26T23:01:07Z")

</div>

Hi guys! I am overloading the show function and I want to print some text with color. Is there a way to know if the terminal support colors or if the user wants colors? For example, if the user execute julia --colors=no …

---

## [How to convert a string into an expression?](https://discourse.julialang.org/t/how-to-convert-a-string-into-an-expression/11160)

<div class="topic-metadata">

**Author:** [@ufechner7](https://discourse.julialang.org/u/ufechner7)\
**Replies:** 11\
**Last updated:** [May 26, 2018, 9:54pm UTC](https://discourse.julialang.org/t/how-to-convert-a-string-into-an-expression/11160 "2018-05-26T21:54:23Z")

</div>

Hello, I want to generate lines of code automatically, using a list of field names as input. The following code doesn’t throw an error, but it also doesn’t produce the desired result, because the eval function needs an…

---

## ["@." can induce poor performance sometimes](https://discourse.julialang.org/t/can-induce-poor-performance-sometimes/11170)

<div class="topic-metadata">

**Author:** [@1115](https://discourse.julialang.org/u/1115)\
**Replies:** 7\
**Last updated:** [May 26, 2018, 9:47pm UTC](https://discourse.julialang.org/t/can-induce-poor-performance-sometimes/11170 "2018-05-26T21:47:24Z")

</div>

@. macro, it will put a . behind some user defined function even though it is applited on a scalar and there is no available bmask.. Interestingly, it causes a lot of memory allocation, inducing a poor performance. jul…

---

## [Composite Types of Arrays](https://discourse.julialang.org/t/composite-types-of-arrays/11110)

<div class="topic-metadata">

**Author:** [@Juser](https://discourse.julialang.org/u/Juser)\
**Replies:** 2\
**Last updated:** [May 26, 2018, 8:09pm UTC](https://discourse.julialang.org/t/composite-types-of-arrays/11110 "2018-05-26T20:09:08Z")

</div>

I would like to do something like: type Vecs{V,T} A::V{T} B::V{T} end where V could be Vector or SharedVector or some other specified AbstractVector and T is some sort of bits-type. I understand that I cou…

---

## [Generating plots in Documenter.jl](https://discourse.julialang.org/t/generating-plots-in-documenter-jl/11166)

<div class="topic-metadata">

**Author:** [@kevbonham](https://discourse.julialang.org/u/kevbonham)\
**Replies:** 2\
**Last updated:** [May 26, 2018, 3:36pm UTC](https://discourse.julialang.org/t/generating-plots-in-documenter-jl/11166 "2018-05-26T15:36:00Z")

</div>

In my Microbiome package, I’ve got some places where plots are generated in the documentation, and then I’d like to show it below the code block, eg here (note: I wasn’t sure how to get tripple backticks to format here …

---

## [How to check if you're running Julia on win32?](https://discourse.julialang.org/t/how-to-check-if-youre-running-julia-on-win32/11165)

<div class="topic-metadata">

**Author:** [@anriseth](https://discourse.julialang.org/u/anriseth)\
**Replies:** 1\
**Last updated:** [May 26, 2018, 2:08pm UTC](https://discourse.julialang.org/t/how-to-check-if-youre-running-julia-on-win32/11165 "2018-05-26T14:08:35Z")

</div>

AppVeyor win32 fails because I’m running tests that use HigherPrecision.jl Is there a way to check whether we are on win32, in the same fashion I can call is\_windows()?

---

## [Lazy subranges or \`1:end\` as entity](https://discourse.julialang.org/t/lazy-subranges-or-1-end-as-entity/11159)

<div class="topic-metadata">

**Author:** [@mschauer](https://discourse.julialang.org/u/mschauer)\
**Replies:** 5\
**Last updated:** [May 26, 2018, 10:40am UTC](https://discourse.julialang.org/t/lazy-subranges-or-1-end-as-entity/11159 "2018-05-26T10:40:06Z")

</div>

Sometimes I’d like to be able to write r = 1:End()-1 x\[r\] .= y\[r\] Is this a good idea and how to achieve this?

---

## [Memoize a vararg function](https://discourse.julialang.org/t/memoize-a-vararg-function/11151)

<div class="topic-metadata">

**Author:** [@gmouts](https://discourse.julialang.org/u/gmouts)\
**Replies:** 3\
**Last updated:** [May 26, 2018, 5:26am UTC](https://discourse.julialang.org/t/memoize-a-vararg-function/11151 "2018-05-26T05:26:58Z")

</div>

I tried to use Memoize.jl fro a vararg function. The following code @memoize function test(lst::Vararg{Int}) return length(lst) end test(1,2) gives TypeError: test: in typeassert, expected Vararg{Int64,N} where N…

---

## [Can I force a vector to release its memory?](https://discourse.julialang.org/t/can-i-force-a-vector-to-release-its-memory/11158)

<div class="topic-metadata">

**Author:** [@jinliangwei](https://discourse.julialang.org/u/jinliangwei)\
**Replies:** 5\
**Last updated:** [May 26, 2018, 5:14am UTC](https://discourse.julialang.org/t/can-i-force-a-vector-to-release-its-memory/11158 "2018-05-26T05:14:15Z")

</div>

a = zeros(4000000000) resize!(a, 0) sizehint!(a, 0) b = zeros(4000000000) resize!(b, 0) sizehint!(b, 0) c = zeros(4000000000) while true end I ran into OutOfMemoryError with the above program. My computer has 64GiB of R…

---

## [Non-mutating deleteat/splice function](https://discourse.julialang.org/t/non-mutating-deleteat-splice-function/11139)

<div class="topic-metadata">

**Author:** [@digital\_carver](https://discourse.julialang.org/u/digital_carver)\
**Replies:** 4\
**Last updated:** [May 25, 2018, 7:58pm UTC](https://discourse.julialang.org/t/non-mutating-deleteat-splice-function/11139 "2018-05-25T19:58:23Z")

</div>

Is there a function to return a copy of an array with one or more elements removed? Or to splice in different elements into a copy of the array and return that? I’ve been doing things like deleteat!(copy(arr), idxs), b…

---

## [Nullptr in CxxWrap](https://discourse.julialang.org/t/nullptr-in-cxxwrap/11150)

<div class="topic-metadata">

**Author:** [@jstrube](https://discourse.julialang.org/u/jstrube)\
**Replies:** 2\
**Last updated:** [May 25, 2018, 7:08pm UTC](https://discourse.julialang.org/t/nullptr-in-cxxwrap/11150 "2018-05-25T19:08:12Z")

</div>

I’m wrapping an API for a file format (LCIO.jl). This is a serial format and each readNext () call either returns a pointer to the next record or NULL. When wrapping that function, I can’t seem to propagate the compariso…

---

## [Pkg.init() Segmentation Fault](https://discourse.julialang.org/t/pkg-init-segmentation-fault/11112)

<div class="topic-metadata">

**Author:** [@mkschleg](https://discourse.julialang.org/u/mkschleg)\
**Replies:** 6\
**Last updated:** [May 25, 2018, 2:23pm UTC](https://discourse.julialang.org/t/pkg-init-segmentation-fault/11112 "2018-05-25T14:23:06Z")

</div>

I’ve been looking around the issues on Github and the discussion here and haven’t found a solution to my problem. A few things. I’m behind a corporate proxy and on ubuntu-16.04. I’ve downloaded the precompiled version of…

---

## [How to make 1×n Array{String, 2} from n-element Array{String, 1}?](https://discourse.julialang.org/t/how-to-make-1xn-array-string-2-from-n-element-array-string-1/11138)

<div class="topic-metadata">

**Author:** [@paalon](https://discourse.julialang.org/u/paalon)\
**Replies:** 7\
**Last updated:** [May 25, 2018, 11:04am UTC](https://discourse.julialang.org/t/how-to-make-1xn-array-string-2-from-n-element-array-string-1/11138 "2018-05-25T11:04:53Z")

</div>

I am using Plots and it requires to be set labels as 1×n Array{String, 2} but I want to make the labels automatically. I can get n-element Array{String, 1} but I cannot find how to convert this to 1×n Array{String, 2}. C…

---

## [push! showing better performance than pre-allocation for Vector?](https://discourse.julialang.org/t/push-showing-better-performance-than-pre-allocation-for-vector/11136)

<div class="topic-metadata">

**Author:** [@shushman](https://discourse.julialang.org/u/shushman)\
**Replies:** 4\
**Last updated:** [May 25, 2018, 10:35am UTC](https://discourse.julialang.org/t/push-showing-better-performance-than-pre-allocation-for-vector/11136 "2018-05-25T10:35:13Z")

</div>

I’ll just post the code snippets - they are quite self-explanatory. That said, I am still learning the nitty-gritties of Julia so please bear with me. vect = Vector{Int}(1000000) @time for i = 1:1000000 vect\[i\] =…

---

## [Use protobuf to generate jl code](https://discourse.julialang.org/t/use-protobuf-to-generate-jl-code/10300)

<div class="topic-metadata">

**Author:** [@IreneWang333](https://discourse.julialang.org/u/IreneWang333)\
**Replies:** 12\
**Last updated:** [May 18, 2018, 10:42am UTC](https://discourse.julialang.org/t/use-protobuf-to-generate-jl-code/10300 "2018-05-18T10:42:30Z")

</div>

Hi all I am using the ProtoBuf Julia package to generate jl from .proto file. The package is https://github.com/JuliaIO/ProtoBuf.jl/blob/master/PROTOC.md I follow the guiding that use the command: protoc -I=/proto-fol…

---

## [Using StaticArrays on 0.7 fails \[SOLVED\]](https://discourse.julialang.org/t/using-staticarrays-on-0-7-fails-solved/11133)

<div class="topic-metadata">

**Author:** [@ufechner7](https://discourse.julialang.org/u/ufechner7)\
**Replies:** 10\
**Last updated:** [May 25, 2018, 3:57am UTC](https://discourse.julialang.org/t/using-staticarrays-on-0-7-fails-solved/11133 "2018-05-25T03:57:26Z")

</div>

I installed StaticArrays on Version 0.7.0-DEV.5216 (2018-05-24 18:04 UTC), using the new package manager. While the installation seams to work, using it fails: julia\> using StaticArrays \[ Info: Precompiling module Sta…

---

## [List comprehension Dictionary Julia](https://discourse.julialang.org/t/list-comprehension-dictionary-julia/11129)

<div class="topic-metadata">

**Author:** [@jayce\_ram](https://discourse.julialang.org/u/jayce_ram)\
**Replies:** 2\
**Last updated:** [May 24, 2018, 3:43pm UTC](https://discourse.julialang.org/t/list-comprehension-dictionary-julia/11129 "2018-05-24T15:43:44Z")

</div>

I have a set of years like that: years = \[2020,2021,2022\] and I also have a dictionary that links the sites available in each year(sit\_available\_year), that looks like following : 2020 -\> \[ "site1","site2,"site3\] 2021…

---

## [Decision boundary and scatter (almost solved)](https://discourse.julialang.org/t/decision-boundary-and-scatter-almost-solved/11104)

<div class="topic-metadata">

**Author:** [@hpoit](https://discourse.julialang.org/u/hpoit)\
**Replies:** 0\
**Last updated:** [May 23, 2018, 4:40pm UTC](https://discourse.julialang.org/t/decision-boundary-and-scatter-almost-solved/11104 "2018-05-23T16:40:41Z")

</div>

Almost solved, I’m sorry. I wanted to delete this entire thread but ended up bumping it.

---

## [DeepGetfield.jl](https://discourse.julialang.org/t/deepgetfield-jl/11121)

<div class="topic-metadata">

**Author:** [@baggepinnen](https://discourse.julialang.org/u/baggepinnen)\
**Replies:** 6\
**Last updated:** [May 24, 2018, 8:54am UTC](https://discourse.julialang.org/t/deepgetfield-jl/11121 "2018-05-24T08:54:39Z")

</div>

I developed a small utility package DeepGetfield.jl that provides the macro @deep composite.field which makes getfield look through a composite type recursively to find the specified field somewhere deep inside. I use …

---

## [Fast way to access bits of Float64?](https://discourse.julialang.org/t/fast-way-to-access-bits-of-float64/11098)

<div class="topic-metadata">

**Author:** [@robertfeldt](https://discourse.julialang.org/u/robertfeldt)\
**Replies:** 7\
**Last updated:** [May 24, 2018, 7:56am UTC](https://discourse.julialang.org/t/fast-way-to-access-bits-of-float64/11098 "2018-05-24T07:56:05Z")

</div>

I need a fast way to repeatedly access bits in the representation of a floating point value in Julia julia\> rawbit(x::Float64, bit::I) where {I \<: Integer} = reinterpret(UInt64, x) & (1 \<\< (bit-1)) but the native code …

---

## [Defining a variable within a function at the module scope?](https://discourse.julialang.org/t/defining-a-variable-within-a-function-at-the-module-scope/11114)

<div class="topic-metadata">

**Author:** [@Qiyamah](https://discourse.julialang.org/u/Qiyamah)\
**Replies:** 4\
**Last updated:** [May 24, 2018, 5:32am UTC](https://discourse.julialang.org/t/defining-a-variable-within-a-function-at-the-module-scope/11114 "2018-05-24T05:32:38Z")

</div>

Hi, I was wondering how can i define a variable at the module scope within a function or code block. Is my only option “global” keyword? or is there function define(MODULE,sym) Thanks

---

## [@cfunctions with keyword arguments](https://discourse.julialang.org/t/cfunctions-with-keyword-arguments/11088)

<div class="topic-metadata">

**Author:** [@jkozdon](https://discourse.julialang.org/u/jkozdon)\
**Replies:** 2\
**Last updated:** [May 24, 2018, 12:34am UTC](https://discourse.julialang.org/t/cfunctions-with-keyword-arguments/11088 "2018-05-24T00:34:21Z")

</div>

I believe that this is a bug in the nightly build but wanted to check before submitting an issue. When using the @cfunction macro within a closure with keyword arguments, I get an error message from Julia if the keyword…

---

## [JuMP constraints with conditions in Sum](https://discourse.julialang.org/t/jump-constraints-with-conditions-in-sum/11059)

<div class="topic-metadata">

**Author:** [@majbah](https://discourse.julialang.org/u/majbah)\
**Replies:** 2\
**Last updated:** [May 22, 2018, 6:25pm UTC](https://discourse.julialang.org/t/jump-constraints-with-conditions-in-sum/11059 "2018-05-22T18:25:04Z")

</div>

I am trying to solve an optimization problem with JuMP. Is there any way to include “condition” in the “sum” part of @constraint macro? The constraint is: \\sum\_{c \\in C} \\sum\_{s \\in S} \\sum\_{r \\in S, s \\ne r} (x\_s^c + …

---

## [Fast lookup into (almost) constant array](https://discourse.julialang.org/t/fast-lookup-into-almost-constant-array/11085)

<div class="topic-metadata">

**Author:** [@Adriel](https://discourse.julialang.org/u/Adriel)\
**Replies:** 6\
**Last updated:** [May 23, 2018, 9:19pm UTC](https://discourse.julialang.org/t/fast-lookup-into-almost-constant-array/11085 "2018-05-23T21:19:25Z")

</div>

I have this (simplified) code in a module. const A = @SMatrix \[1.0 2.0; 3.0 4.0\] f(r, x::Number) = x \* Vector{Float64}(A\[r,:\]) f is a bottleneck function. This is already really quick and I’m happy…

---

## [How to expose a C++ library to julia](https://discourse.julialang.org/t/how-to-expose-a-c-library-to-julia/11068)

<div class="topic-metadata">

**Author:** [@floswald](https://discourse.julialang.org/u/floswald)\
**Replies:** 9\
**Last updated:** [May 23, 2018, 3:50pm UTC](https://discourse.julialang.org/t/how-to-expose-a-c-library-to-julia/11068 "2018-05-23T15:50:49Z")

</div>

I would like to use this C++ library from julia: https://github.com/ORNL/Tasmanian there is a Python interface which I tried to use with PyCall but without success. I’m now wondering how hard it would be to wrap this as…

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

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