# General Usage

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

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

**Page:** 997

---

## [A Question of Style: Should inner constructor completion functions end with ! ](https://discourse.julialang.org/t/a-question-of-style-should-inner-constructor-completion-functions-end-with/8948)

<div class="topic-metadata">

**Author:** [@anon32405968](https://discourse.julialang.org/u/anon32405968)\
**Replies:** 3\
**Last updated:** [February 15, 2018, 1:15pm UTC](https://discourse.julialang.org/t/a-question-of-style-should-inner-constructor-completion-functions-end-with/8948 "2018-02-15T13:15:54Z")

</div>

In the Julia style guide, direct link below, it recommends appending an exclamation mark to the end function names which modify their arguments: https://docs.julialang.org/en/stable/manual/style-guide/#Append-!-to-names…

---

## [Cxx.jl and -D flags](https://discourse.julialang.org/t/cxx-jl-and-d-flags/9063)

<div class="topic-metadata">

**Author:** [@vvjn](https://discourse.julialang.org/u/vvjn)\
**Replies:** 1\
**Last updated:** [February 14, 2018, 6:26pm UTC](https://discourse.julialang.org/t/cxx-jl-and-d-flags/9063 "2018-02-14T18:26:55Z")

</div>

So I am trying to use Cxx.jl to wrap a C++ library but I’m coming across some issues. As a start, I am converting some C++ code to Cxx.jl. And when I compile the C++, I need to pass a -D flag in order to turn on some opt…

---

## [Match LLVM with Julia source?](https://discourse.julialang.org/t/match-llvm-with-julia-source/9017)

<div class="topic-metadata">

**Author:** [@Stephen\_Vavasis](https://discourse.julialang.org/u/Stephen_Vavasis)\
**Replies:** 6\
**Last updated:** [February 14, 2018, 3:37pm UTC](https://discourse.julialang.org/t/match-llvm-with-julia-source/9017 "2018-02-14T15:37:27Z")

</div>

I have reason to suspect that incorrect LLVM is being generated for my code in some circumstances. Poring over 3000+ lines of LLVM is out of the question, but I might be able to figure out 10-15 lines if I knew where to…

---

## ["infinitivus" shortly is Inf , how to work with this?](https://discourse.julialang.org/t/infinitivus-shortly-is-inf-how-to-work-with-this/9008)

<div class="topic-metadata">

**Author:** [@programista](https://discourse.julialang.org/u/programista)\
**Replies:** 2\
**Last updated:** [February 14, 2018, 12:58pm UTC](https://discourse.julialang.org/t/infinitivus-shortly-is-inf-how-to-work-with-this/9008 "2018-02-14T12:58:21Z")

</div>

Inf in Any Array (text) is recognzed like Float64. how to work with this ? for i=1:k Slow\[i,2\]=string(uppercase(slow\[i,2\]\[1\]),string(slow\[i,2\]\[2:end\])) println(i) end … 920370 920371 ERROR: MethodError: no method…

---

## [Eliminite overhead of "invoke" in benchmark](https://discourse.julialang.org/t/eliminite-overhead-of-invoke-in-benchmark/9028)

<div class="topic-metadata">

**Author:** [@goerz](https://discourse.julialang.org/u/goerz)\
**Replies:** 7\
**Last updated:** [February 14, 2018, 3:49am UTC](https://discourse.julialang.org/t/eliminite-overhead-of-invoke-in-benchmark/9028 "2018-02-14T03:49:50Z")

</div>

In my benchmark, I would like to compare the performance of a more specialized method to a less specialized method. Following Ralph Smith’s suggestion, I’ve tried using the invoke function for this. The problem is that …

---

## [Struct with array and dict of symbols: index array by symbol](https://discourse.julialang.org/t/struct-with-array-and-dict-of-symbols-index-array-by-symbol/9040)

<div class="topic-metadata">

**Author:** [@EP-Guy](https://discourse.julialang.org/u/EP-Guy)\
**Replies:** 2\
**Last updated:** [February 13, 2018, 9:42pm UTC](https://discourse.julialang.org/t/struct-with-array-and-dict-of-symbols-index-array-by-symbol/9040 "2018-02-13T21:42:57Z")

</div>

I have defined a struct: struct State{T} \<: AbstractArray{T,1} fields::Dict{Symbol, UnitRange{Int64}} arr::Array{T} end that might be initialized by something like state0 = State(Dict(\[(:r, 1:3), (:v, 4:6)\]), …

---

## [Freeze when reading from output of external command](https://discourse.julialang.org/t/freeze-when-reading-from-output-of-external-command/9034)

<div class="topic-metadata">

**Author:** [@Jeffersyno](https://discourse.julialang.org/u/Jeffersyno)\
**Replies:** 4\
**Last updated:** [February 13, 2018, 8:24pm UTC](https://discourse.julialang.org/t/freeze-when-reading-from-output-of-external-command/9034 "2018-02-13T20:24:08Z")

</div>

Hi, I’m having an issue with running an external command from Julia. I’m trying to read XML from a process’s output stream and parse it with LibExpat. The problem I’m having is that Julia freezes indefinitely at the firs…

---

## [Model configuration/parameterization file](https://discourse.julialang.org/t/model-configuration-parameterization-file/8982)

<div class="topic-metadata">

**Author:** [@grahamas](https://discourse.julialang.org/u/grahamas)\
**Replies:** 9\
**Last updated:** [February 13, 2018, 4:48pm UTC](https://discourse.julialang.org/t/model-configuration-parameterization-file/8982 "2018-02-13T16:48:41Z")

</div>

Is there a best practice for storing and reading model parameters? (In plain text.) In Python, I would just use JSON because there’s a fairly straightforward mapping of the JSON syntax to the objects I wanted in Python,…

---

## [Passing multi-line expression to macro on Raspberry Pi causes seg fault](https://discourse.julialang.org/t/passing-multi-line-expression-to-macro-on-raspberry-pi-causes-seg-fault/8980)

<div class="topic-metadata">

**Author:** [@jacobcvt12](https://discourse.julialang.org/u/jacobcvt12)\
**Replies:** 11\
**Last updated:** [February 13, 2018, 3:26pm UTC](https://discourse.julialang.org/t/passing-multi-line-expression-to-macro-on-raspberry-pi-causes-seg-fault/8980 "2018-02-13T15:26:02Z")

</div>

I am running Julia 0.6.0 as installed from apt on a Raspberry Pi 3 Model B using Raspbian. Whenever I run a multi-line expression passed to a macro e.g. @p begin 2 + 2 - 3 end I get a segmentation fault signal (11…

---

## [Issues with plotting more than once in REPL](https://discourse.julialang.org/t/issues-with-plotting-more-than-once-in-repl/9022)

<div class="topic-metadata">

**Author:** [@gideonsimpson](https://discourse.julialang.org/u/gideonsimpson)\
**Replies:** 3\
**Last updated:** [February 13, 2018, 12:50pm UTC](https://discourse.julialang.org/t/issues-with-plotting-more-than-once-in-repl/9022 "2018-02-13T12:50:39Z")

</div>

I’m finding that if I launch Julia 0.6.2 at the terminal and then calling using Plots if I then plot something simple, on my Mac OS machine, a GKSTerm launches, and I see my figure. Now, If then close that figure and …

---

## [Shouldn't xcorr(a, b) be same as conv(reverse(a), b)?](https://discourse.julialang.org/t/shouldnt-xcorr-a-b-be-same-as-conv-reverse-a-b/8975)

<div class="topic-metadata">

**Author:** [@suiato](https://discourse.julialang.org/u/suiato)\
**Replies:** 7\
**Last updated:** [February 13, 2018, 12:49pm UTC](https://discourse.julialang.org/t/shouldnt-xcorr-a-b-be-same-as-conv-reverse-a-b/8975 "2018-02-13T12:49:17Z")

</div>

When a=\[1, 2, 3\] and b=\[1, 2, 3, 3, 2, 1\], yc = conv(reverse(a), b) returns \[3, 8 14, 17, 15, 10, 4, 1\], and yx = xcorr(a, b) returns \[1, 4, 10, 15, 17, 14, 8, 3, 0, 0, 0\]. Shouldn’t yx be same as yc? yx1 = xcorr(b,…

---

## [Setdiff doesn't work](https://discourse.julialang.org/t/setdiff-doesnt-work/9029)

<div class="topic-metadata">

**Author:** [@Qiyamah](https://discourse.julialang.org/u/Qiyamah)\
**Replies:** 1\
**Last updated:** [February 13, 2018, 7:40am UTC](https://discourse.julialang.org/t/setdiff-doesnt-work/9029 "2018-02-13T07:40:04Z")

</div>

julia\> struct XX x::Int y::Float64 end julia\> a = \[XX(1,2.1),XX(2,3.1),XX(3,4.2)\] 3-element Array{XX,1}: XX(1, 2.1) XX(2, 3.1) XX(3, 4.2) julia\> b = \[XX(1,2.2),XX(2,3.2),XX(3,4.3)\] 3-ele…

---

## [odd byte length primitive types and reinterpret()](https://discourse.julialang.org/t/odd-byte-length-primitive-types-and-reinterpret/9025)

<div class="topic-metadata">

**Author:** [@wherrera](https://discourse.julialang.org/u/wherrera)\
**Replies:** 3\
**Last updated:** [February 13, 2018, 1:43am UTC](https://discourse.julialang.org/t/odd-byte-length-primitive-types-and-reinterpret/9025 "2018-02-13T01:43:14Z")

</div>

julia\> primitive type Int24 24 end julia\> Int24(x::Int) = Core.Intrinsics.trunc\_int(Int24, x) Int24 julia\> Int(x::Int24) = Core.Intrinsics.zext\_int(Int, x) Int64 julia\> x = b"\\x10\\x45\\x12\\x20\\x30\\x40" 6-element Arr…

---

## [Use tab to page through suggestions](https://discourse.julialang.org/t/use-tab-to-page-through-suggestions/9021)

<div class="topic-metadata">

**Author:** [@jacobcvt12](https://discourse.julialang.org/u/jacobcvt12)\
**Replies:** 2\
**Last updated:** [February 12, 2018, 8:34pm UTC](https://discourse.julialang.org/t/use-tab-to-page-through-suggestions/9021 "2018-02-12T20:34:21Z")

</div>

Is it possible to use tab to page through suggestions without creating a new prompt? I appreciate this aspect of the fish and zsh shells - here’s a gif I found online demonstrating the desired effect.

---

## [Better Documentation of \[,Dims\] for Julia FFT function](https://discourse.julialang.org/t/better-documentation-of-dims-for-julia-fft-function/9016)

<div class="topic-metadata">

**Author:** [@Jordan\_Cluts](https://discourse.julialang.org/u/Jordan_Cluts)\
**Replies:** 3\
**Last updated:** [February 12, 2018, 5:20pm UTC](https://discourse.julialang.org/t/better-documentation-of-dims-for-julia-fft-function/9016 "2018-02-12T17:20:24Z")

</div>

I am attempting to find the FFT of a set of vectors. In particular I have an array that is 2234 rows long with each row being a signal to perform an FFT on. The documentation on FFT states that The optional dims argume…

---

## [Sparse matrix-matrix calculation only within specified sparsity?](https://discourse.julialang.org/t/sparse-matrix-matrix-calculation-only-within-specified-sparsity/9007)

<div class="topic-metadata">

**Author:** [@mcovalt](https://discourse.julialang.org/u/mcovalt)\
**Replies:** 2\
**Last updated:** [February 12, 2018, 1:06pm UTC](https://discourse.julialang.org/t/sparse-matrix-matrix-calculation-only-within-specified-sparsity/9007 "2018-02-12T13:06:09Z")

</div>

I need to preform some sparse matrix-matrix calculations, but I only need a few of the non-zeros. Specifically, for A\*B=C I only need the resulting C nonzeros where A has nonzeros. Forming all of C and then dropping the …

---

## [Problem with "\\" , how to use in Dict {Any}?](https://discourse.julialang.org/t/problem-with-how-to-use-in-dict-any/8989)

<div class="topic-metadata">

**Author:** [@programista](https://discourse.julialang.org/u/programista)\
**Replies:** 8\
**Last updated:** [February 12, 2018, 7:53am UTC](https://discourse.julialang.org/t/problem-with-how-to-use-in-dict-any/8989 "2018-02-12T07:53:16Z")

</div>

julia\> usuwam Dict{Any,Any} with 6 entries: “=” =\> “” “!” =\> “” “-” =\> “” “/” =\> “” “‘’” =\> “” “+” =\> “” Is ok, but : julia\> get!(usuwam,“backslash”,“”) not work ! how to use “backslash” in Dict {Any} ? P…

---

## [Curiosity: unglobal first-only replace()?](https://discourse.julialang.org/t/curiosity-unglobal-first-only-replace/9006)

<div class="topic-metadata">

**Author:** [@ivo\_welch](https://discourse.julialang.org/u/ivo_welch)\
**Replies:** 1\
**Last updated:** [February 12, 2018, 6:50am UTC](https://discourse.julialang.org/t/curiosity-unglobal-first-only-replace/9006 "2018-02-12T06:50:45Z")

</div>

More a curiosity than a problem. julia’s replace is global. Perl requires the ‘g’ modifier to do a global replace. my $s= "aabbccddaabbccddaabbccdd"; $s =~ s/(b+)/\[$1\]/; print "$s\\n"; replaces only the first match: a…

---

## [Worker process memory leak?](https://discourse.julialang.org/t/worker-process-memory-leak/9005)

<div class="topic-metadata">

**Author:** [@bbethke](https://discourse.julialang.org/u/bbethke)\
**Replies:** 0\
**Last updated:** [February 12, 2018, 2:50am UTC](https://discourse.julialang.org/t/worker-process-memory-leak/9005 "2018-02-12T02:50:51Z")

</div>

Hello, I have a question about garbage collection on worker processes (this is on 0.6.2). I have a long-running function that uses a RemoteChannel to communicate with the master node. This function allocates and frees…

---

## [Juno error after updating the package tool-bar v1.1.5](https://discourse.julialang.org/t/juno-error-after-updating-the-package-tool-bar-v1-1-5/8984)

<div class="topic-metadata">

**Author:** [@zhangliye](https://discourse.julialang.org/u/zhangliye)\
**Replies:** 3\
**Last updated:** [February 12, 2018, 2:10am UTC](https://discourse.julialang.org/t/juno-error-after-updating-the-package-tool-bar-v1-1-5/8984 "2018-02-12T02:10:47Z")

</div>

After I updated the too-bar package to the new version 1.1.5. Got the following error. windows 7, Julia0.6.2, latest version of Juno.

---

## [Chained comparison evaluation order](https://discourse.julialang.org/t/chained-comparison-evaluation-order/8999)

<div class="topic-metadata">

**Author:** [@tk3369](https://discourse.julialang.org/u/tk3369)\
**Replies:** 2\
**Last updated:** [February 11, 2018, 9:26pm UTC](https://discourse.julialang.org/t/chained-comparison-evaluation-order/8999 "2018-02-11T21:26:42Z")

</div>

This came straight from the official documentation. I don’t understand why v(2) should be evaluated before v(1) in the first example although technically it shouldn’t matter (unlike short circuit operators)… It just see…

---

## [Type inference slowdown in binary file i/o](https://discourse.julialang.org/t/type-inference-slowdown-in-binary-file-i-o/8995)

<div class="topic-metadata">

**Author:** [@dataPulverizer](https://discourse.julialang.org/u/dataPulverizer)\
**Replies:** 2\
**Last updated:** [February 11, 2018, 8:17pm UTC](https://discourse.julialang.org/t/type-inference-slowdown-in-binary-file-i-o/8995 "2018-02-11T20:17:13Z")

</div>

I’m writing code to read and write 1D arrays to binary files. I want the read function to infer the element type and read back the data, I had initially a large slowdown that I partially resolved by splitting the read fu…

---

## [Combining an SVector and an SMatrix, in a cat(2, vec, mat) style](https://discourse.julialang.org/t/combining-an-svector-and-an-smatrix-in-a-cat-2-vec-mat-style/8994)

<div class="topic-metadata">

**Author:** [@Datseris](https://discourse.julialang.org/u/Datseris)\
**Replies:** 1\
**Last updated:** [February 11, 2018, 3:03pm UTC](https://discourse.julialang.org/t/combining-an-svector-and-an-smatrix-in-a-cat-2-vec-mat-style/8994 "2018-02-11T15:03:14Z")

</div>

What is the best way to combine an SVector and an SMatrix, in a cat(2, vec, mat) style? D = 3 k = 2 # arguments Q = rand(SMatrix{D,k}) u = rand(SVector{D}) # 1 @btime cat(2, u, Q) #doesn't return SMatrix # 2 @btime S…

---

## [What is the preferred way to manage multiple files?](https://discourse.julialang.org/t/what-is-the-preferred-way-to-manage-multiple-files/8969)

<div class="topic-metadata">

**Author:** [@Roger-luo](https://discourse.julialang.org/u/Roger-luo)\
**Replies:** 9\
**Last updated:** [February 11, 2018, 10:46am UTC](https://discourse.julialang.org/t/what-is-the-preferred-way-to-manage-multiple-files/8969 "2018-02-11T10:46:22Z")

</div>

While developing a package, it is common to include a lot scripts into the main module (not Main), let’s say package FooPackage.jl in the main module module Foo include("xxxx.jl") export xxxxx using xxxxx # some code…

---

## [A tiny DSL for network filtering using generated functions](https://discourse.julialang.org/t/a-tiny-dsl-for-network-filtering-using-generated-functions/8979)

<div class="topic-metadata">

**Author:** [@NiclasMattsson](https://discourse.julialang.org/u/NiclasMattsson)\
**Replies:** 1\
**Last updated:** [February 11, 2018, 7:56am UTC](https://discourse.julialang.org/t/a-tiny-dsl-for-network-filtering-using-generated-functions/8979 "2018-02-11T07:56:58Z")

</div>

I know I’m not the only one here who struggles to understand generated functions. I spent an entire day implementing this simple DSL for filtering network connections and finally got it working. I’m sharing it here partl…

---

## [Writing Explicitly-Typed Functions for all Vector{Float} or Vector{Number} / and missing?!](https://discourse.julialang.org/t/writing-explicitly-typed-functions-for-all-vector-float-or-vector-number-and-missing/8986)

<div class="topic-metadata">

**Author:** [@ivo\_welch](https://discourse.julialang.org/u/ivo_welch)\
**Replies:** 3\
**Last updated:** [February 11, 2018, 7:17am UTC](https://discourse.julialang.org/t/writing-explicitly-typed-functions-for-all-vector-float-or-vector-number-and-missing/8986 "2018-02-11T07:17:07Z")

</div>

dear julia experts—I would like to define a function with explicit typing, which works for all types of float vectors. Its output should be the same type as its input. I know how to do this for one specific type, such…

---

## [Only 4 bytes of a pointer retrieved in C](https://discourse.julialang.org/t/only-4-bytes-of-a-pointer-retrieved-in-c/8899)

<div class="topic-metadata">

**Author:** [@nextr](https://discourse.julialang.org/u/nextr)\
**Replies:** 8\
**Last updated:** [February 11, 2018, 12:48am UTC](https://discourse.julialang.org/t/only-4-bytes-of-a-pointer-retrieved-in-c/8899 "2018-02-11T00:48:28Z")

</div>

Hello everybody, I’m having a problem with a Julia function which returns a pointer to an object. The pointer is coded in 8 bytes. This function has a C interface to be used form a C program. When I use this function i…

---

## [money!(player, money(player) + 100)](https://discourse.julialang.org/t/money-player-money-player-100/8967)

<div class="topic-metadata">

**Author:** [@kungfooman](https://discourse.julialang.org/u/kungfooman)\
**Replies:** 11\
**Last updated:** [February 10, 2018, 7:57pm UTC](https://discourse.julialang.org/t/money-player-money-player-100/8967 "2018-02-10T19:57:49Z")

</div>

Hi all, does somebody know a good “design pattern” to simplify this kind of code? money!(player, money(player) + 100) In other languages it would be something like this, via getters/setters: player.money += 100 But …

---

## [Show() and sisters](https://discourse.julialang.org/t/show-and-sisters/8927)

<div class="topic-metadata">

**Author:** [@j2b2](https://discourse.julialang.org/u/j2b2)\
**Replies:** 5\
**Last updated:** [February 10, 2018, 5:04pm UTC](https://discourse.julialang.org/t/show-and-sisters/8927 "2018-02-10T17:04:51Z")

</div>

Hi, here is my code : julia\> using Primes julia\> f=factor(binomial(30,12)) 3 ⋅ 5^2 ⋅ 7 ⋅ 13 ⋅ 19 ⋅ 23 ⋅ 29 julia\> repr(f) "Primes.Factorization(3=\>1,5=\>2,7=\>1,13=\>1,19=\>1,23=\>1,29=\>1)" julia\> string(f) "Primes.Factor…

---

## [Benchmark specialized method against general method](https://discourse.julialang.org/t/benchmark-specialized-method-against-general-method/8978)

<div class="topic-metadata">

**Author:** [@goerz](https://discourse.julialang.org/u/goerz)\
**Replies:** 1\
**Last updated:** [February 10, 2018, 4:45pm UTC](https://discourse.julialang.org/t/benchmark-specialized-method-against-general-method/8978 "2018-02-10T16:45:36Z")

</div>

Julia always uses the most specialized method. For a specific occasion, is there a way to force it to instead use the method that is one level more general? Or, more generally, any specific more general method? For exam…

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

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