# General Usage

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

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

**Page:** 1023

---

## [Type instability for \`SArray\` wrapped in \`struct\`](https://discourse.julialang.org/t/type-instability-for-sarray-wrapped-in-struct/6358)

<div class="topic-metadata">

**Author:** [@DNF](https://discourse.julialang.org/u/DNF)\
**Replies:** 6\
**Last updated:** [October 9, 2017, 6:27pm UTC](https://discourse.julialang.org/t/type-instability-for-sarray-wrapped-in-struct/6358 "2017-10-09T18:27:52Z")

</div>

I’m struggling with an apparent type instability when wrapping a StaticArray in a struct. This also leads to a ~3x slowdown. Here’s an MWE running on version 0.6.0: struct Foo x::SMatrix{4, 4, Float64} end function…

---

## [Submodule initialization](https://discourse.julialang.org/t/submodule-initialization/6325)

<div class="topic-metadata">

**Author:** [@Alexander\_Belopolsky](https://discourse.julialang.org/u/Alexander_Belopolsky)\
**Replies:** 2\
**Last updated:** [October 9, 2017, 5:57pm UTC](https://discourse.julialang.org/t/submodule-initialization/6325 "2017-10-09T17:57:35Z")

</div>

According to the “Module-initialization-and-precompilation” section of the manual. “if you define a function \_\_init\_\_() in a module, then Julia will call \_\_init\_\_() immediately after the module is loaded”. Consider the …

---

## [LightXML question](https://discourse.julialang.org/t/lightxml-question/6352)

<div class="topic-metadata">

**Author:** [@Frank\_Applin](https://discourse.julialang.org/u/Frank_Applin)\
**Replies:** 2\
**Last updated:** [October 9, 2017, 5:07pm UTC](https://discourse.julialang.org/t/lightxml-question/6352 "2017-10-09T17:07:17Z")

</div>

I’m reading an XML file that looks like this: \<machine\_information\> \<machine name="Raspberry Pi" node="julia-user@NODE-RPI3" julia-bin="/home/julia-user/julia-0.6.0/bin/"\> \<pins category="GPIO"\> \<!--left pins (lef…

---

## [Stubbing in Julia?](https://discourse.julialang.org/t/stubbing-in-julia/6341)

<div class="topic-metadata">

**Author:** [@ratan](https://discourse.julialang.org/u/ratan)\
**Replies:** 2\
**Last updated:** [October 9, 2017, 2:30pm UTC](https://discourse.julialang.org/t/stubbing-in-julia/6341 "2017-10-09T14:30:03Z")

</div>

In Scala, for example, ??? is defined as throwing a NotImplementedException, is there something similar in julia for stubbing functions?

---

## [Cpu\_target of standard Windows 64-bit download](https://discourse.julialang.org/t/cpu-target-of-standard-windows-64-bit-download/2885)

<div class="topic-metadata">

**Author:** [@greg\_plowman](https://discourse.julialang.org/u/greg_plowman)\
**Replies:** 10\
**Last updated:** [October 9, 2017, 12:22pm UTC](https://discourse.julialang.org/t/cpu-target-of-standard-windows-64-bit-download/2885 "2017-10-09T12:22:48Z")

</div>

By default, build\_sysimg() uses cpu\_target="native" I can override this (for example to use cpu\_target="x86\_64") include(joinpath(JULIA\_HOME, Base.DATAROOTDIR, "julia", "build\_sysimg.jl")) build\_sysimg(nothing, "x86\_64…

---

## [Retrieve member types of a Union](https://discourse.julialang.org/t/retrieve-member-types-of-a-union/6335)

<div class="topic-metadata">

**Author:** [@greg\_plowman](https://discourse.julialang.org/u/greg_plowman)\
**Replies:** 4\
**Last updated:** [October 9, 2017, 2:49am UTC](https://discourse.julialang.org/t/retrieve-member-types-of-a-union/6335 "2017-10-09T02:49:48Z")

</div>

Is there a standard way to get the member types of a Union? In v0.5 I used, but was never happy with: typealias Primitive\_UInt Union{UInt8,UInt16,UInt32,UInt64,UInt128} Primitive\_UInt.types In v0.6 I’ve experimented, …

---

## [Concatenating vectors into a single vector without allocating memory (opposite of @view)](https://discourse.julialang.org/t/concatenating-vectors-into-a-single-vector-without-allocating-memory-opposite-of-view/6339)

<div class="topic-metadata">

**Author:** [@wsshin](https://discourse.julialang.org/u/wsshin)\
**Replies:** 1\
**Last updated:** [October 9, 2017, 2:12am UTC](https://discourse.julialang.org/t/concatenating-vectors-into-a-single-vector-without-allocating-memory-opposite-of-view/6339 "2017-10-09T02:12:01Z")

</div>

Suppose we want to construct one large vector x and three smaller vectors x1, x2, x3 such that a relationship x = \[x1; x2; x3\] is always maintained. Provided that each of the smaller vectors has 100 entries, this can be…

---

## [Why is this code nondeterministic?](https://discourse.julialang.org/t/why-is-this-code-nondeterministic/6331)

<div class="topic-metadata">

**Author:** [@Tamas\_Papp](https://discourse.julialang.org/u/Tamas_Papp)\
**Replies:** 2\
**Last updated:** [October 8, 2017, 9:12pm UTC](https://discourse.julialang.org/t/why-is-this-code-nondeterministic/6331 "2017-10-08T21:12:17Z")

</div>

I don’t understand what is going on with the code below (MWE): the first invocation of isequal is false, from then on it is true. Running v0.6. struct MaybeParsed{T} pos::Int value::T MaybeParsed{T}(pos) whe…

---

## [Pkg.update() Pkg.clone() does not work behind corporate firewall](https://discourse.julialang.org/t/pkg-update-pkg-clone-does-not-work-behind-corporate-firewall/6329)

<div class="topic-metadata">

**Author:** [@xiaodai](https://discourse.julialang.org/u/xiaodai)\
**Replies:** 1\
**Last updated:** [October 8, 2017, 8:29pm UTC](https://discourse.julialang.org/t/pkg-update-pkg-clone-does-not-work-behind-corporate-firewall/6329 "2017-10-08T20:29:41Z")

</div>

In older versions of R install.packages used to not work behind corporate firewalls unless you run setinternet2(). What the function setinternet2() does is that it tells install.packages to use the Internet Explorer prox…

---

## [Pretty printing JSON in JuliaIO/JSON.jl](https://discourse.julialang.org/t/pretty-printing-json-in-juliaio-json-jl/6315)

<div class="topic-metadata">

**Author:** [@NickNack](https://discourse.julialang.org/u/NickNack)\
**Replies:** 1\
**Last updated:** [October 7, 2017, 11:11pm UTC](https://discourse.julialang.org/t/pretty-printing-json-in-juliaio-json-jl/6315 "2017-10-07T23:11:52Z")

</div>

Doesn’t pretty printing of JSON strings with JSON.jl work? The README doesn’t explicitly mention pretty printing, but indentation is mentioned all over the code and there are print methods with an indentation parameter. …

---

## [Construct an Expr(:tuple, ...) without Expr](https://discourse.julialang.org/t/construct-an-expr-tuple-without-expr/6311)

<div class="topic-metadata">

**Author:** [@Tamas\_Papp](https://discourse.julialang.org/u/Tamas_Papp)\
**Replies:** 2\
**Last updated:** [October 7, 2017, 6:34pm UTC](https://discourse.julialang.org/t/construct-an-expr-tuple-without-expr/6311 "2017-10-07T18:34:37Z")

</div>

When writing a generated function, I can do it like this: julia\> pp = Any\[:(1+2),:(3+4)\] 2-element Array{Any,1}: :(1 + 2) :(3 + 4) julia\> Expr(:tuple, pp...) :((1 + 2, 3 + 4)) but is there a way without Expr?

---

## [Base.\_return\_type in generated function](https://discourse.julialang.org/t/base--return-type-in-generated-function/6309)

<div class="topic-metadata">

**Author:** [@Tamas\_Papp](https://discourse.julialang.org/u/Tamas_Papp)\
**Replies:** 1\
**Last updated:** [October 7, 2017, 3:37pm UTC](https://discourse.julialang.org/t/base--return-type-in-generated-function/6309 "2017-10-07T15:37:25Z")

</div>

The manual warns against Interacting with the contents or methods of Core.Inference in any way. in generated functions. Does this mean that I cannot call Base.\_return\_type? What can go wrong? Can I call a function t…

---

## [Why \`Dict("A"=\>1, "B"=\>2)\` instead \`Dict("A":1, "B":2)\`?](https://discourse.julialang.org/t/why-dict-a-1-b-2-instead-dict-a-1-b-2/6306)

<div class="topic-metadata">

**Author:** [@shravankumar147](https://discourse.julialang.org/u/shravankumar147)\
**Replies:** 5\
**Last updated:** [October 7, 2017, 1:47pm UTC](https://discourse.julialang.org/t/why-dict-a-1-b-2-instead-dict-a-1-b-2/6306 "2017-10-07T13:47:55Z")

</div>

Dear DevTeam, I saw Julia incorporated features from both Python and Matlab and I really appreciate its performance in-terms of speed. As a python user we love writing dictionaries as {key:value}. I appreciate if you …

---

## [Conditional code and precompilation](https://discourse.julialang.org/t/conditional-code-and-precompilation/6301)

<div class="topic-metadata">

**Author:** [@Alexander\_Belopolsky](https://discourse.julialang.org/u/Alexander_Belopolsky)\
**Replies:** 12\
**Last updated:** [October 7, 2017, 1:33am UTC](https://discourse.julialang.org/t/conditional-code-and-precompilation/6301 "2017-10-07T01:33:57Z")

</div>

I am developing a package that is designed to be used either by standard Julia or by Julia library embedded in a third party application. Most of the code is the same in either mode, but a few functions are currently de…

---

## [Any ... but not that much](https://discourse.julialang.org/t/any-but-not-that-much/6300)

<div class="topic-metadata">

**Author:** [@joa-quim](https://discourse.julialang.org/u/joa-quim)\
**Replies:** 3\
**Last updated:** [October 6, 2017, 10:52pm UTC](https://discourse.julialang.org/t/any-but-not-that-much/6300 "2017-10-06T22:52:15Z")

</div>

a=\[\]; b=\[\]; julia\> c=\[a b\] 0×2 Array{Any,2} julia\> c=\[1 b\] ERROR: DimensionMismatch("mismatch in dimension 1 (expected 1 got 0)") This highly reduces the usefulness of the Any’s. In Matlab we can do \>\> c={1 \[\]}; \>\> i…

---

## [Nulling of object references / unset!](https://discourse.julialang.org/t/nulling-of-object-references-unset/6031)

<div class="topic-metadata">

**Author:** [@foobar\_lv](https://discourse.julialang.org/u/foobar_lv)\
**Replies:** 7\
**Last updated:** [October 6, 2017, 8:27pm UTC](https://discourse.julialang.org/t/nulling-of-object-references-unset/6031 "2017-10-06T20:27:32Z")

</div>

When interfacing to C code, it is often necessary to unset variables, i.e. reset object references to C\_NULL before passing then as structs to C. This can be done by @inline function unset\_field!(x::T) unsafestore!(co…

---

## [Infer type from tuple argument](https://discourse.julialang.org/t/infer-type-from-tuple-argument/6294)

<div class="topic-metadata">

**Author:** [@ric.cioffi](https://discourse.julialang.org/u/ric.cioffi)\
**Replies:** 5\
**Last updated:** [October 6, 2017, 7:03pm UTC](https://discourse.julialang.org/t/infer-type-from-tuple-argument/6294 "2017-10-06T19:03:16Z")

</div>

Hi all, I have been having problems making my functions type stable as I don’t entirely understand how it works. I managed to make most of my functions type stable (I think) but I am having problems with the most perfo…

---

## [Dereference a pointer](https://discourse.julialang.org/t/dereference-a-pointer/6251)

<div class="topic-metadata">

**Author:** [@Frank\_Applin](https://discourse.julialang.org/u/Frank_Applin)\
**Replies:** 25\
**Last updated:** [October 6, 2017, 6:29pm UTC](https://discourse.julialang.org/t/dereference-a-pointer/6251 "2017-10-06T18:29:25Z")

</div>

How do I dereference a pointer? The hex 01a I get back is correct, but I need it as a value. Or, am I even doing this right? device\_id = ccall((:i2c\_smbus\_read\_byte\_data, "/home/julia-user/julia-0.6.0/bin/libi2c-dev.so"…

---

## [CoreNLP - Base Name Conflict](https://discourse.julialang.org/t/corenlp-base-name-conflict/4714)

<div class="topic-metadata">

**Author:** [@aether](https://discourse.julialang.org/u/aether)\
**Replies:** 68\
**Last updated:** [October 6, 2017, 12:56pm UTC](https://discourse.julialang.org/t/corenlp-base-name-conflict/4714 "2017-10-06T12:56:09Z")

</div>

Hi, Trying to use the CoreNLP.jl package at the Julia 0.6.0 command line on Ubuntu 16.04. I’m following the instructions shown here. The session looks like this– julia\> using CoreNLP WARNING: deprecated syntax “\_ as…

---

## [Problems with strings which contain unicode characters on julia 0.7-DEV](https://discourse.julialang.org/t/problems-with-strings-which-contain-unicode-characters-on-julia-0-7-dev/6279)

<div class="topic-metadata">

**Author:** [@PerezHz](https://discourse.julialang.org/u/PerezHz)\
**Replies:** 2\
**Last updated:** [October 6, 2017, 3:31am UTC](https://discourse.julialang.org/t/problems-with-strings-which-contain-unicode-characters-on-julia-0-7-dev/6279 "2017-10-06T03:31:44Z")

</div>

Hi everyone! Is this a known issue on julia 0.7-DEV? julia\> str1 = "a " "a " julia\> str2 = "a" "a" julia\> str2 == str1\[1:end-1\] true julia\> str1 = "₁ " "₁ " julia\> str2 = "₁" "₁" julia\> str2 == str1\[1:end-1\] ERROR:…

---

## [Even more Pkg troubles](https://discourse.julialang.org/t/even-more-pkg-troubles/6282)

<div class="topic-metadata">

**Author:** [@jebej](https://discourse.julialang.org/u/jebej)\
**Replies:** 2\
**Last updated:** [October 6, 2017, 3:09am UTC](https://discourse.julialang.org/t/even-more-pkg-troubles/6282 "2017-10-06T03:09:26Z")

</div>

A recent Pkg.update() caused a couple of packages to get downgraded: julia\> Pkg.update() INFO: Updating METADATA... INFO: Updating cache of Lazy... INFO: Updating cache of IJulia... INFO: Updating cache of RecipesBase..…

---

## [Atom 1.21.0 update broke Juno console autocomplete?](https://discourse.julialang.org/t/atom-1-21-0-update-broke-juno-console-autocomplete/6250)

<div class="topic-metadata">

**Author:** [@jessebett](https://discourse.julialang.org/u/jessebett)\
**Replies:** 2\
**Last updated:** [October 5, 2017, 5:49pm UTC](https://discourse.julialang.org/t/atom-1-21-0-update-broke-juno-console-autocomplete/6250 "2017-10-05T17:49:18Z")

</div>

I just updated my Atom to 1.21.0 and no longer have the autocomplete popup in Juno’s console. I do however have the autocomplete working in the main editor. Does anyone else have this problem with the 1.21.0 atom updat…

---

## [Help: can anyone tell me why julia is not correctly inferring the return type?](https://discourse.julialang.org/t/help-can-anyone-tell-me-why-julia-is-not-correctly-inferring-the-return-type/6262)

<div class="topic-metadata">

**Author:** [@Ronis\_BR](https://discourse.julialang.org/u/Ronis_BR)\
**Replies:** 11\
**Last updated:** [October 5, 2017, 3:03pm UTC](https://discourse.julialang.org/t/help-can-anyone-tell-me-why-julia-is-not-correctly-inferring-the-return-type/6262 "2017-10-05T15:03:32Z")

</div>

Hi guys! I have this code here: import Base: getindex mutable struct A{T\<:Real} a::T b::T c::T d::T end function getindex(a::A{T}, ::Colon) where T\<:Real \[a.a;a.b;a.c;a.d\] end function test(a::A{…

---

## [Grid Representation in Interpolations.jl](https://discourse.julialang.org/t/grid-representation-in-interpolations-jl/6261)

<div class="topic-metadata">

**Author:** [@Andrew\_Gibb](https://discourse.julialang.org/u/Andrew_Gibb)\
**Replies:** 0\
**Last updated:** [October 5, 2017, 10:29am UTC](https://discourse.julialang.org/t/grid-representation-in-interpolations-jl/6261 "2017-10-05T10:29:59Z")

</div>

Am I missing something here, or is this a bug? using Interpolations xs = 1:10 data = xs.^2 itp1 = interpolate(data, BSpline(Linear()), OnGrid()) itp2 = interpolate(data, BSpline(Linear()), OnCell()) itp1\[5\]-itp2\[5\], itp…

---

## [Atomic println function](https://discourse.julialang.org/t/atomic-println-function/6259)

<div class="topic-metadata">

**Author:** [@usefulhyun](https://discourse.julialang.org/u/usefulhyun)\
**Replies:** 0\
**Last updated:** [October 5, 2017, 7:38am UTC](https://discourse.julialang.org/t/atomic-println-function/6259 "2017-10-05T07:38:23Z")

</div>

Hi, there I suffer from overlapping the print result from remote print and local print. Especially, when print statement includes the print variables For example: addprocs(1) # =\> suppose worker number is 2 a = 1111 …

---

## [Performance: tuple unpacking](https://discourse.julialang.org/t/performance-tuple-unpacking/6244)

<div class="topic-metadata">

**Author:** [@Marek\_Kukan](https://discourse.julialang.org/u/Marek_Kukan)\
**Replies:** 8\
**Last updated:** [October 5, 2017, 6:11am UTC](https://discourse.julialang.org/t/performance-tuple-unpacking/6244 "2017-10-05T06:11:14Z")

</div>

Why is the first expression ~2.5x slower? julia\> x = rand(10^6); julia\> y = rand(10^6); julia\> @btime sum(a \* b for (a, b) in zip(x, y)); 4.280 ms (5 allocations: 112 bytes) julia\> @btime sum(t\[1\] \* t\[2\] for t in z…

---

## [Invalid redefinition of constant in comprehensions](https://discourse.julialang.org/t/invalid-redefinition-of-constant-in-comprehensions/6252)

<div class="topic-metadata">

**Author:** [@bkamins](https://discourse.julialang.org/u/bkamins)\
**Replies:** 1\
**Last updated:** [October 4, 2017, 11:03pm UTC](https://discourse.julialang.org/t/invalid-redefinition-of-constant-in-comprehensions/6252 "2017-10-04T23:03:24Z")

</div>

I am running the following code from the following section in Julia manual: https://docs.julialang.org/en/latest/manual/arrays/#Comprehensions-1: x = rand(8) \[ 0.25\*x\[i-1\] + 0.5\*x\[i\] + 0.25\*x\[i+1\] for i=2:length(x)-1 \] …

---

## [How define a function on remote process](https://discourse.julialang.org/t/how-define-a-function-on-remote-process/6243)

<div class="topic-metadata">

**Author:** [@usefulhyun](https://discourse.julialang.org/u/usefulhyun)\
**Replies:** 0\
**Last updated:** [October 4, 2017, 3:37pm UTC](https://discourse.julialang.org/t/how-define-a-function-on-remote-process/6243 "2017-10-04T15:37:59Z")

</div>

Hi, there As far as I know, I can define a function on all processes by @everywhere keyword. But, I do want to know how do I define a function on specific process. And beside, I want to define a function on remote pro…

---

## [Performance: mutable vs immutable structs](https://discourse.julialang.org/t/performance-mutable-vs-immutable-structs/6221)

<div class="topic-metadata">

**Author:** [@tryingtosolve](https://discourse.julialang.org/u/tryingtosolve)\
**Replies:** 4\
**Last updated:** [October 4, 2017, 9:10am UTC](https://discourse.julialang.org/t/performance-mutable-vs-immutable-structs/6221 "2017-10-04T09:10:36Z")

</div>

In my code, I need to create a struct to hold two vectors. In terms of speed and memory allocations, would it make a difference if I make it mutable instead of immutable, assuming that there’s no need to make to mutable? …

---

## [Incomplete tuples](https://discourse.julialang.org/t/incomplete-tuples/6214)

<div class="topic-metadata">

**Author:** [@Colin\_Beckingham](https://discourse.julialang.org/u/Colin_Beckingham)\
**Replies:** 5\
**Last updated:** [October 4, 2017, 7:46am UTC](https://discourse.julialang.org/t/incomplete-tuples/6214 "2017-10-04T07:46:54Z")

</div>

If I define a vector as a=\[2,3\] then its size() is returned as an incomplete tuple (2,). The transpose of a has a size of (1,2). Do not problems arise from the fact that (2,) == (2,1) returns false?

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

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