# General Usage

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

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

**Page:** 1007

---

## [Setproperty! , which julia has it?](https://discourse.julialang.org/t/setproperty-which-julia-has-it/7984)

<div class="topic-metadata">

**Author:** [@Qiyamah](https://discourse.julialang.org/u/Qiyamah)\
**Replies:** 2\
**Last updated:** [December 25, 2017, 3:35pm UTC](https://discourse.julialang.org/t/setproperty-which-julia-has-it/7984 "2017-12-25T15:35:22Z")

</div>

I am looking for the julia version which has the setproperty! and getproperty to override. Thanks

---

## [On the design of nullable property](https://discourse.julialang.org/t/on-the-design-of-nullable-property/7981)

<div class="topic-metadata">

**Author:** [@bicycle1885](https://discourse.julialang.org/u/bicycle1885)\
**Replies:** 2\
**Last updated:** [December 25, 2017, 2:27pm UTC](https://discourse.julialang.org/t/on-the-design-of-nullable-property/7981 "2017-12-25T14:27:55Z")

</div>

Hi all, I’m now playing around the new Base.getproperty method, which was introduced in the master branch of Julia very recently. It is cool, so I’m planning to use it in my packages. The question is what will be the b…

---

## [Faster join()?](https://discourse.julialang.org/t/faster-join/7957)

<div class="topic-metadata">

**Author:** [@tk3369](https://discourse.julialang.org/u/tk3369)\
**Replies:** 4\
**Last updated:** [December 25, 2017, 9:26am UTC](https://discourse.julialang.org/t/faster-join/7957 "2017-12-25T09:26:17Z")

</div>

I happened to have no access to Internet this morning and didn’t remember the function that joins strings together. I’m a newbie, clearly :slightly\_smiling\_face: So I wrote my own: concatenate(strArray::Vector{String}…

---

## [How to implement equality test for mutable types? Hash Function Example](https://discourse.julialang.org/t/how-to-implement-equality-test-for-mutable-types-hash-function-example/7982)

<div class="topic-metadata">

**Author:** [@Qiyamah](https://discourse.julialang.org/u/Qiyamah)\
**Replies:** 1\
**Last updated:** [December 25, 2017, 9:04am UTC](https://discourse.julialang.org/t/how-to-implement-equality-test-for-mutable-types-hash-function-example/7982 "2017-12-25T09:04:27Z")

</div>

Can you give an example?

---

## [Removing the elements of one array from another using setdiff](https://discourse.julialang.org/t/removing-the-elements-of-one-array-from-another-using-setdiff/7977)

<div class="topic-metadata">

**Author:** [@Qiyamah](https://discourse.julialang.org/u/Qiyamah)\
**Replies:** 4\
**Last updated:** [December 25, 2017, 2:05am UTC](https://discourse.julialang.org/t/removing-the-elements-of-one-array-from-another-using-setdiff/7977 "2017-12-25T02:05:56Z")

</div>

Hi fellows, The following code works: a = \[1,2,3,4,5\] b = \[4,5,6\] setdiff(a,b) 3-element Array{Int64,1}: 1 2 3 However this one doesn’t: type X a::Int end Base.broadcast(::typeof(==),x::X,y::X) = x.a =…

---

## [Yet another failed attempt to build julia with MKL](https://discourse.julialang.org/t/yet-another-failed-attempt-to-build-julia-with-mkl/7327)

<div class="topic-metadata">

**Author:** [@navidcy](https://discourse.julialang.org/u/navidcy)\
**Replies:** 6\
**Last updated:** [December 25, 2017, 1:26am UTC](https://discourse.julialang.org/t/yet-another-failed-attempt-to-build-julia-with-mkl/7327 "2017-12-25T01:26:21Z")

</div>

I’ve reached bottom and despair… I’ve tried MANY times to build julia with MKL. I’ve done all sorts of gimmicks and tricks people mention here at GitHub and all over the internet. Repetitive failure each time more or le…

---

## [Way to get module of undef variable?](https://discourse.julialang.org/t/way-to-get-module-of-undef-variable/7931)

<div class="topic-metadata">

**Author:** [@djsegal](https://discourse.julialang.org/u/djsegal)\
**Replies:** 1\
**Last updated:** [December 24, 2017, 9:53pm UTC](https://discourse.julialang.org/t/way-to-get-module-of-undef-variable/7931 "2017-12-24T21:53:52Z")

</div>

If you do: cur\_error = nothing try foo(bar::Main.baz) = "Rambo" catch tmp\_error cur\_error = tmp\_error end which gives \> cur\_error UndefVarError(:baz) \> cur\_error.var :baz The thing I’m kind of curious about …

---

## [DifferentialEquations.jl error when solving equations with complex variables](https://discourse.julialang.org/t/differentialequations-jl-error-when-solving-equations-with-complex-variables/7939)

<div class="topic-metadata">

**Author:** [@111](https://discourse.julialang.org/u/111)\
**Replies:** 5\
**Last updated:** [December 24, 2017, 12:03pm UTC](https://discourse.julialang.org/t/differentialequations-jl-error-when-solving-equations-with-complex-variables/7939 "2017-12-24T12:03:08Z")

</div>

I tried to solve the problem u’ = -im \* E \* u, of which the solution is like u = const \* e^(-im \* E \* t). My code is: using DifferentialEquations using Plots; pyplot() E = 200.0 function Eq(t::Float64, u::Array{Comple…

---

## [Is there any speed improvement from wrapping invokelatest in a try-catch?](https://discourse.julialang.org/t/is-there-any-speed-improvement-from-wrapping-invokelatest-in-a-try-catch/7958)

<div class="topic-metadata">

**Author:** [@djsegal](https://discourse.julialang.org/u/djsegal)\
**Replies:** 2\
**Last updated:** [December 24, 2017, 9:51am UTC](https://discourse.julialang.org/t/is-there-any-speed-improvement-from-wrapping-invokelatest-in-a-try-catch/7958 "2017-12-24T09:51:02Z")

</div>

For example, let’s say you dynamically make a module Foo: module Foo nothing\_here\_yet = true end Is it worthwhile to put an invokelatest try-catch to avoid world\_age bugs, while still keeping most of the speed? try …

---

## [Is there a way to make module in anon workspace & then ingest it into a package?](https://discourse.julialang.org/t/is-there-a-way-to-make-module-in-anon-workspace-then-ingest-it-into-a-package/7909)

<div class="topic-metadata">

**Author:** [@djsegal](https://discourse.julialang.org/u/djsegal)\
**Replies:** 1\
**Last updated:** [December 24, 2017, 9:38am UTC](https://discourse.julialang.org/t/is-there-a-way-to-make-module-in-anon-workspace-then-ingest-it-into-a-package/7909 "2017-12-24T09:38:46Z")

</div>

The idea is you create a module – Foo – in some anonymous workspace. // i.e. in order to not have to overwrite the module if it fails module \_anon\_uuid module Foo if rand() \< 0.5 bar() = "Hello, …

---

## [Way to be explicit with different objects sharing the same name?](https://discourse.julialang.org/t/way-to-be-explicit-with-different-objects-sharing-the-same-name/7961)

<div class="topic-metadata">

**Author:** [@djsegal](https://discourse.julialang.org/u/djsegal)\
**Replies:** 5\
**Last updated:** [December 24, 2017, 9:36am UTC](https://discourse.julialang.org/t/way-to-be-explicit-with-different-objects-sharing-the-same-name/7961 "2017-12-24T09:36:05Z")

</div>

Let’s say you have a module in a package called IO (obviously not preferable): module IO custom\_input\_output\_stuff = true end The problem now is that the module IO will clobber the Base IO type in calls. This leads…

---

## [Toward faster Rationals](https://discourse.julialang.org/t/toward-faster-rationals/7933)

<div class="topic-metadata">

**Author:** [@JeffreySarnoff](https://discourse.julialang.org/u/JeffreySarnoff)\
**Replies:** 9\
**Last updated:** [December 24, 2017, 1:38am UTC](https://discourse.julialang.org/t/toward-faster-rationals/7933 "2017-12-24T01:38:45Z")

</div>

Consider (abs, inv, +, -, \*, //) over values of type Rational{I} where I\<:Union{Int16…Int128, BigInt}. A substantive time sink is renormalizing the (numerator, denominator) pairs: div each by their gcd. Use two sor…

---

## [How to get count of current methods in a package's methodtable?](https://discourse.julialang.org/t/how-to-get-count-of-current-methods-in-a-packages-methodtable/7910)

<div class="topic-metadata">

**Author:** [@djsegal](https://discourse.julialang.org/u/djsegal)\
**Replies:** 5\
**Last updated:** [December 23, 2017, 9:29am UTC](https://discourse.julialang.org/t/how-to-get-count-of-current-methods-in-a-packages-methodtable/7910 "2017-12-23T09:29:03Z")

</div>

The only tools I know to get information about methods are: methods() methodswith() (kind of) fieldnames() How do you get information about the underlying method table though? Is there a way to see how many methods …

---

## [Best way to make has\_many/belongs\_to relation for structs?](https://discourse.julialang.org/t/best-way-to-make-has-many-belongs-to-relation-for-structs/7937)

<div class="topic-metadata">

**Author:** [@djsegal](https://discourse.julialang.org/u/djsegal)\
**Replies:** 3\
**Last updated:** [December 23, 2017, 6:48am UTC](https://discourse.julialang.org/t/best-way-to-make-has-many-belongs-to-relation-for-structs/7937 "2017-12-23T06:48:12Z")

</div>

Let’s say you have two types of structs: Users Posts Users can have many posts. But each post belongs to only one user. How would you do this in structs? Some pseudocode: struct User posts::AbstractArray{Post} e…

---

## [Broadcast and .\* not the same](https://discourse.julialang.org/t/broadcast-and-not-the-same/7935)

<div class="topic-metadata">

**Author:** [@srwhite59](https://discourse.julialang.org/u/srwhite59)\
**Replies:** 2\
**Last updated:** [December 23, 2017, 3:56am UTC](https://discourse.julialang.org/t/broadcast-and-not-the-same/7935 "2017-12-23T03:56:02Z")

</div>

I have an AutoVector type for which broadcast(,v,v) works but v . v doesn’t. The indexing is more flexible than the usual type, so I don’t want it to be a subtype of AbstractVector. Here is a drastically simplified set…

---

## [Emacs mode indentation trouble](https://discourse.julialang.org/t/emacs-mode-indentation-trouble/7932)

<div class="topic-metadata">

**Author:** [@purplishrock](https://discourse.julialang.org/u/purplishrock)\
**Replies:** 1\
**Last updated:** [December 23, 2017, 3:12am UTC](https://discourse.julialang.org/t/emacs-mode-indentation-trouble/7932 "2017-12-23T03:12:55Z")

</div>

I’m having a weird, very inconsitent problem with indentation in emacs mod. I’m currently editing a file and have a line part way down a function definition which indents the way it should and the very next line does no…

---

## [Static sparse matrices? Limit on number of type parameters?](https://discourse.julialang.org/t/static-sparse-matrices-limit-on-number-of-type-parameters/7830)

<div class="topic-metadata">

**Author:** [@mohamed82008](https://discourse.julialang.org/u/mohamed82008)\
**Replies:** 25\
**Last updated:** [December 22, 2017, 3:06pm UTC](https://discourse.julialang.org/t/static-sparse-matrices-limit-on-number-of-type-parameters/7830 "2017-12-22T15:06:19Z")

</div>

I have been thinking of what would be the equivalent of static arrays for sparse matrices and entertaining the possibility of specializing linear algebra for every sparsity pattern thus possibly achieving similar speed b…

---

## [Incrementally growing datafield with JLD](https://discourse.julialang.org/t/incrementally-growing-datafield-with-jld/7919)

<div class="topic-metadata">

**Author:** [@carstenbauer](https://discourse.julialang.org/u/carstenbauer)\
**Replies:** 0\
**Last updated:** [December 22, 2017, 1:52pm UTC](https://discourse.julialang.org/t/incrementally-growing-datafield-with-jld/7919 "2017-12-22T13:52:10Z")

</div>

Let’s say I have a matrix stored in a file and I want to add columns over time. I want to add them in chunks so that I do not open/close the file all the time and I also want compression. HDF5 allows me to do so for bas…

---

## [Is the if statement inside my for loop body being optimized out or not?](https://discourse.julialang.org/t/is-the-if-statement-inside-my-for-loop-body-being-optimized-out-or-not/7913)

<div class="topic-metadata">

**Author:** [@favba](https://discourse.julialang.org/u/favba)\
**Replies:** 2\
**Last updated:** [December 22, 2017, 12:39pm UTC](https://discourse.julialang.org/t/is-the-if-statement-inside-my-for-loop-body-being-optimized-out-or-not/7913 "2017-12-22T12:39:38Z")

</div>

Consider the following MWE: abstract type AbstractSimulation end struct Simulation \<: AbstractSimulation ux::Array{Float64,3} uy::Array{Float64,3} uz::Array{Float64,3} rhsx::Array{Float64,3} rhsy::Array{Float…

---

## [H5write analog for JLD](https://discourse.julialang.org/t/h5write-analog-for-jld/7917)

<div class="topic-metadata">

**Author:** [@carstenbauer](https://discourse.julialang.org/u/carstenbauer)\
**Replies:** 0\
**Last updated:** [December 22, 2017, 12:19pm UTC](https://discourse.julialang.org/t/h5write-analog-for-jld/7917 "2017-12-22T12:19:13Z")

</div>

using JLD # create dummy file save("test.jld", "x", rand(2,2)) # I now want to add another element to "test.jld" # I can't do save("test.jld", "y", rand(2,2)) because # this creates a new file that only contains y (x i…

---

## [How to find to which module a type belongs to?](https://discourse.julialang.org/t/how-to-find-to-which-module-a-type-belongs-to/7911)

<div class="topic-metadata">

**Author:** [@Qiyamah](https://discourse.julialang.org/u/Qiyamah)\
**Replies:** 2\
**Last updated:** [December 22, 2017, 9:44am UTC](https://discourse.julialang.org/t/how-to-find-to-which-module-a-type-belongs-to/7911 "2017-12-22T09:44:48Z")

</div>

Hi fellows, Let’s assume, I have a type XYZ which i currently use in my current module , however XYZ is defined in some other module. How can i get to which module XYZ belongs to? Thanks

---

## [Julia slow with Hilbert matrices](https://discourse.julialang.org/t/julia-slow-with-hilbert-matrices/7905)

<div class="topic-metadata">

**Author:** [@jmichel](https://discourse.julialang.org/u/jmichel)\
**Replies:** 9\
**Last updated:** [December 22, 2017, 7:17am UTC](https://discourse.julialang.org/t/julia-slow-with-hilbert-matrices/7905 "2017-12-22T07:17:05Z")

</div>

Hello, I am new to Julia, which I learn in the hope to port some mathematical software (group theory and arithmetic) to. I did a simple test with Hilbert matrices, and to my disappointment I found that on th…

---

## [Pkg.add/clone/update doesn't work behind corporate proxy unless run in Juno](https://discourse.julialang.org/t/pkg-add-clone-update-doesnt-work-behind-corporate-proxy-unless-run-in-juno/7889)

<div class="topic-metadata">

**Author:** [@xiaodai](https://discourse.julialang.org/u/xiaodai)\
**Replies:** 5\
**Last updated:** [December 21, 2017, 11:06pm UTC](https://discourse.julialang.org/t/pkg-add-clone-update-doesnt-work-behind-corporate-proxy-unless-run-in-juno/7889 "2017-12-21T23:06:18Z")

</div>

I tried to do Pkg.update() which works in Juno but not in Julia REPL nor VSCode. This is the message I get. ERROR: METADATA cannot be updated. Resolve problems manually in C:\\User\\usernameA\\.julia\\v0.6\\METADATA. GitEr…

---

## [Workflow for monitoring native code size](https://discourse.julialang.org/t/workflow-for-monitoring-native-code-size/7897)

<div class="topic-metadata">

**Author:** [@juliohm](https://discourse.julialang.org/u/juliohm)\
**Replies:** 11\
**Last updated:** [December 21, 2017, 9:17pm UTC](https://discourse.julialang.org/t/workflow-for-monitoring-native-code-size/7897 "2017-12-21T21:17:06Z")

</div>

A good measure of performance is length of generated machine code. As a package writer, I would like to monitor how well the functions I am writing are in terms of concise assembly. This would improve the performance of …

---

## [What is it for, GMP external library used by JULIA?](https://discourse.julialang.org/t/what-is-it-for-gmp-external-library-used-by-julia/7893)

<div class="topic-metadata">

**Author:** [@NKC](https://discourse.julialang.org/u/NKC)\
**Replies:** 6\
**Last updated:** [December 21, 2017, 6:37pm UTC](https://discourse.julialang.org/t/what-is-it-for-gmp-external-library-used-by-julia/7893 "2017-12-21T18:37:50Z")

</div>

JULIA has some dependencies. Regarding this, What is it for, GMP external library used by JULIA? If it is not a necessary part of JULIA, how can I make JULIA avoid using it? Because it has GPL2+ license and I assum…

---

## [Can I upgrade Julia that was installed with Apt?](https://discourse.julialang.org/t/can-i-upgrade-julia-that-was-installed-with-apt/7884)

<div class="topic-metadata">

**Author:** [@Frank\_Applin](https://discourse.julialang.org/u/Frank_Applin)\
**Replies:** 9\
**Last updated:** [December 21, 2017, 12:13pm UTC](https://discourse.julialang.org/t/can-i-upgrade-julia-that-was-installed-with-apt/7884 "2017-12-21T12:13:06Z")

</div>

Hi, I’m running Julia 0.6.0 arm-linux-gnueabihf on my Raspberry Pi Zero. I installed it using apt-get install julia on Raspbian GNU/Linux 9 (stretch). I tried to build the latest Julia from source, but I wasn’t successf…

---

## [Variable scope in functions](https://discourse.julialang.org/t/variable-scope-in-functions/7876)

<div class="topic-metadata">

**Author:** [@essenciary](https://discourse.julialang.org/u/essenciary)\
**Replies:** 8\
**Last updated:** [December 21, 2017, 3:54am UTC](https://discourse.julialang.org/t/variable-scope-in-functions/7876 "2017-12-21T03:54:12Z")

</div>

I don’t know what to make of this… In the follow snippet const user\_mappings, profile\_mappings = Dict{Int,Int}(), Dict{Int,Int}() const user\_counter, profile\_counter = 0, 0 function data\_accessor() :: DataAccessor t…

---

## [Numeric types and their relationships](https://discourse.julialang.org/t/numeric-types-and-their-relationships/7869)

<div class="topic-metadata">

**Author:** [@juliohm](https://discourse.julialang.org/u/juliohm)\
**Replies:** 14\
**Last updated:** [December 21, 2017, 1:20am UTC](https://discourse.julialang.org/t/numeric-types-and-their-relationships/7869 "2017-12-21T01:20:58Z")

</div>

Suppose I need to define a parametric type with numeric values that are real numbers, but not integers. Initially I thought of doing something like: struct Foo{Integer\<:T\<:Real} end but I am aware that it has two issu…

---

## [Reading material / tutorials / resources on threadsafe programming](https://discourse.julialang.org/t/reading-material-tutorials-resources-on-threadsafe-programming/7834)

<div class="topic-metadata">

**Author:** [@floswald](https://discourse.julialang.org/u/floswald)\
**Replies:** 4\
**Last updated:** [December 20, 2017, 5:52pm UTC](https://discourse.julialang.org/t/reading-material-tutorials-resources-on-threadsafe-programming/7834 "2017-12-20T17:52:30Z")

</div>

I started to use the Threads in my code when I realized there are too many things I don’t understand. I know that I need to be careful that one thread does not interfere with another ones operations, which is pretty intu…

---

## [How to pre-allocate matrices to avoid constructing new matrices during the for-loop?](https://discourse.julialang.org/t/how-to-pre-allocate-matrices-to-avoid-constructing-new-matrices-during-the-for-loop/7866)

<div class="topic-metadata">

**Author:** [@hongyan](https://discourse.julialang.org/u/hongyan)\
**Replies:** 6\
**Last updated:** [December 20, 2017, 11:17am UTC](https://discourse.julialang.org/t/how-to-pre-allocate-matrices-to-avoid-constructing-new-matrices-during-the-for-loop/7866 "2017-12-20T11:17:00Z")

</div>

Hi guys, I have some codes as follows: function sim(M,R,S,q,numIters,numGrids) for i = 1:numIters tmp = R + reshape(q' \* S, numGrids, numGrids); q = (M - tmp) \\ ((M + tmp) \* q); end return q;…

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

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