# General Usage

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

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

**Page:** 1018

---

## [Extracting Array element type for subsequent use](https://discourse.julialang.org/t/extracting-array-element-type-for-subsequent-use/6840)

<div class="topic-metadata">

**Author:** [@purplishrock](https://discourse.julialang.org/u/purplishrock)\
**Replies:** 8\
**Last updated:** [November 3, 2017, 2:27am UTC](https://discourse.julialang.org/t/extracting-array-element-type-for-subsequent-use/6840 "2017-11-03T02:27:27Z")

</div>

I want to do something like: function foo(x::Array{T,1}, y::Array{T,1}) n1 = length(x) n2 = length(y) z = zeros(T, n1+n2) ... end First problem is that I actually need to write function foo(x::Array{T,1} where…

---

## [Cannot add methods to abstract type?](https://discourse.julialang.org/t/cannot-add-methods-to-abstract-type/6848)

<div class="topic-metadata">

**Author:** [@lostella](https://discourse.julialang.org/u/lostella)\
**Replies:** 4\
**Last updated:** [November 2, 2017, 9:18pm UTC](https://discourse.julialang.org/t/cannot-add-methods-to-abstract-type/6848 "2017-11-02T21:18:43Z")

</div>

I’m getting this strange error message in Julia 0.6.1 when I try doing abstract type MyAbstractType end function (a::MyAbstractType)() println(42) end which results in ERROR: cannot add methods to an abstract typ…

---

## [Basic examples of Tasks/Channels? (or more verbose documentation?)](https://discourse.julialang.org/t/basic-examples-of-tasks-channels-or-more-verbose-documentation/6797)

<div class="topic-metadata">

**Author:** [@angelv](https://discourse.julialang.org/u/angelv)\
**Replies:** 10\
**Last updated:** [November 2, 2017, 7:04pm UTC](https://discourse.julialang.org/t/basic-examples-of-tasks-channels-or-more-verbose-documentation/6797 "2017-11-02T19:04:18Z")

</div>

Hi, I’m going through the section in the manual about Tasks, but I find that it is not very thorough so I’m not getting the full picture of how they work (at least for the moment). The first paragraphs about using a Ch…

---

## [Multiple dispach method overwritten](https://discourse.julialang.org/t/multiple-dispach-method-overwritten/6838)

<div class="topic-metadata">

**Author:** [@joa-quim](https://discourse.julialang.org/u/joa-quim)\
**Replies:** 11\
**Last updated:** [November 2, 2017, 3:43pm UTC](https://discourse.julialang.org/t/multiple-dispach-method-overwritten/6838 "2017-11-02T15:43:01Z")

</div>

Hi, I don’t understand why I’m getting this warning. WARNING: Method definition grdtrack() in module GMT at c:\\j\\.julia\\v0.6\\GMT\\src\\grdtrack.jl:51 overwritten at c:\\j\\.julia\\v0.6\\GMT\\src\\grdtrack.jl:150. WARNING: Metho…

---

## [ERROR: ReadOnlyMemoryError() when doing a basic plot?](https://discourse.julialang.org/t/error-readonlymemoryerror-when-doing-a-basic-plot/6145)

<div class="topic-metadata">

**Author:** [@angelv](https://discourse.julialang.org/u/angelv)\
**Replies:** 9\
**Last updated:** [November 2, 2017, 9:23am UTC](https://discourse.julialang.org/t/error-readonlymemoryerror-when-doing-a-basic-plot/6145 "2017-11-02T09:23:05Z")

</div>

Hi, I’m installing fresh computers, and one of the things I’m installing is Julia. I have tried so far three computers, all using the same distribution (ArchLinux), and all have the same versions of everything as far as…

---

## [Properly source ENV variables](https://discourse.julialang.org/t/properly-source-env-variables/6726)

<div class="topic-metadata">

**Author:** [@tawheeler](https://discourse.julialang.org/u/tawheeler)\
**Replies:** 8\
**Last updated:** [November 1, 2017, 9:48pm UTC](https://discourse.julialang.org/t/properly-source-env-variables/6726 "2017-11-01T21:48:44Z")

</div>

I am trying to use Julia to automate an interface with a server running ROS. To do this I need to source some environment variables: export ROS\_MASTER\_URI=http://xxx.xxx.xxx.xxx:xxxxx export ROS\_IP=xxx.xxx.xxx.xxx expor…

---

## [Access to struct fields in generated function](https://discourse.julialang.org/t/access-to-struct-fields-in-generated-function/6800)

<div class="topic-metadata">

**Author:** [@Philippe\_Maincon](https://discourse.julialang.org/u/Philippe_Maincon)\
**Replies:** 4\
**Last updated:** [November 1, 2017, 9:38am UTC](https://discourse.julialang.org/t/access-to-struct-fields-in-generated-function/6800 "2017-11-01T09:38:26Z")

</div>

Hi, I am trying to wrap my skull around metaprogramming. Feels like a stiff skull. In my little example, I want a function that can take any composite type, and do some manipulation (here printing) of each field. Her…

---

## [Struct in julia to C structs](https://discourse.julialang.org/t/struct-in-julia-to-c-structs/6817)

<div class="topic-metadata">

**Author:** [@sysint64](https://discourse.julialang.org/u/sysint64)\
**Replies:** 3\
**Last updated:** [November 1, 2017, 3:45am UTC](https://discourse.julialang.org/t/struct-in-julia-to-c-structs/6817 "2017-11-01T03:45:17Z")

</div>

Hello, julia structs is the same as C structs or not? i.e.: struct Test x::Int y::Int end will this be the same as this? struct { int x; inx y; }

---

## [What is the type of an empty return from match()?](https://discourse.julialang.org/t/what-is-the-type-of-an-empty-return-from-match/6818)

<div class="topic-metadata">

**Author:** [@wherrera](https://discourse.julialang.org/u/wherrera)\
**Replies:** 2\
**Last updated:** [November 1, 2017, 3:08am UTC](https://discourse.julialang.org/t/what-is-the-type-of-an-empty-return-from-match/6818 "2017-11-01T03:08:16Z")

</div>

In the following: julia\> e = if false; end julia\> e julia\> f = match(r"x", “y”) julia\> f julia\> a = 0-element Array{Any,1} julia\> e == a false julia\> e == f true …What is the type of e and f which they are eq…

---

## [Error cloning private Github repo](https://discourse.julialang.org/t/error-cloning-private-github-repo/2878)

<div class="topic-metadata">

**Author:** [@sbohor3](https://discourse.julialang.org/u/sbohor3)\
**Replies:** 16\
**Last updated:** [September 28, 2017, 5:45pm UTC](https://discourse.julialang.org/t/error-cloning-private-github-repo/2878 "2017-09-28T17:45:55Z")

</div>

I got this error when I was cloning a private Github repo. Any idea how to solve this issue? Thanks. @Tero\_Frondelius

---

## [Safely use unsafe \`pointer\` usages](https://discourse.julialang.org/t/safely-use-unsafe-pointer-usages/6813)

<div class="topic-metadata">

**Author:** [@goretkin](https://discourse.julialang.org/u/goretkin)\
**Replies:** 1\
**Last updated:** [October 31, 2017, 8:33pm UTC](https://discourse.julialang.org/t/safely-use-unsafe-pointer-usages/6813 "2017-10-31T20:33:48Z")

</div>

Is there any way to be safe with respect to GC unallocating objects from under you in 0.6 when constructing a pointer that lives longer than just a ccall? For example, is there any way to make the equivalent in 0.6 http…

---

## [@threads vs @parallel, a simple fail case for @threads](https://discourse.julialang.org/t/threads-vs-parallel-a-simple-fail-case-for-threads/6801)

<div class="topic-metadata">

**Author:** [@fkjogu](https://discourse.julialang.org/u/fkjogu)\
**Replies:** 3\
**Last updated:** [October 31, 2017, 6:20pm UTC](https://discourse.julialang.org/t/threads-vs-parallel-a-simple-fail-case-for-threads/6801 "2017-10-31T18:20:27Z")

</div>

I’m new to Julia. I was experimenting with simple parallel code using threads and processes. Why is a = SharedArray{Int64,1}(4) @time @sync @parallel for i = 1:60000000 a\[myid() - 1\] = i end # 1.663024 seconds (7…

---

## [Array of bytes to string](https://discourse.julialang.org/t/array-of-bytes-to-string/6793)

<div class="topic-metadata">

**Author:** [@phlavenk](https://discourse.julialang.org/u/phlavenk)\
**Replies:** 4\
**Last updated:** [October 31, 2017, 6:10pm UTC](https://discourse.julialang.org/t/array-of-bytes-to-string/6793 "2017-10-31T18:10:35Z")

</div>

Hello, I get from an external interface an a::Array{UInt32,1} of a fixed length (assume length(a) == 600). This is in principle a buffer. A CString is written into this buffer, last character is \\0 and the rest of the …

---

## [Hypothesis testing with custom densities](https://discourse.julialang.org/t/hypothesis-testing-with-custom-densities/6808)

<div class="topic-metadata">

**Author:** [@gideonsimpson](https://discourse.julialang.org/u/gideonsimpson)\
**Replies:** 0\
**Last updated:** [October 31, 2017, 5:30pm UTC](https://discourse.julialang.org/t/hypothesis-testing-with-custom-densities/6808 "2017-10-31T17:30:20Z")

</div>

The HypothesisTests module includes a number of statistical tests for comparing against known distributions. Supposing that I have the density for a univariate variable defined as some function, f(x), is there a way to …

---

## [SharedArray of custom types](https://discourse.julialang.org/t/sharedarray-of-custom-types/6802)

<div class="topic-metadata">

**Author:** [@mathtd](https://discourse.julialang.org/u/mathtd)\
**Replies:** 1\
**Last updated:** [October 31, 2017, 1:37pm UTC](https://discourse.julialang.org/t/sharedarray-of-custom-types/6802 "2017-10-31T13:37:22Z")

</div>

Is there anyway to create SharedArray of some custom Type? I.e. I would like to do the following Type Foo a::Int64 end b = SharedArray{Foo,2}((2)) b\[2\].a = 3

---

## [How to transform this grid?](https://discourse.julialang.org/t/how-to-transform-this-grid/6759)

<div class="topic-metadata">

**Author:** [@yakir12](https://discourse.julialang.org/u/yakir12)\
**Replies:** 20\
**Last updated:** [October 31, 2017, 7:04am UTC](https://discourse.julialang.org/t/how-to-transform-this-grid/6759 "2017-10-31T07:04:42Z")

</div>

The following question is partly relevant to camera calibrations, but is relevant to any situation where you want to transform a set of coordinates from one map to another: Say I have a bunch of known coordinates, the…

---

## [What Julia Programmers will be called?](https://discourse.julialang.org/t/what-julia-programmers-will-be-called/6754)

<div class="topic-metadata">

**Author:** [@Arshpreet\_Singh](https://discourse.julialang.org/u/Arshpreet_Singh)\
**Replies:** 3\
**Last updated:** [October 31, 2017, 4:50am UTC](https://discourse.julialang.org/t/what-julia-programmers-will-be-called/6754 "2017-10-31T04:50:50Z")

</div>

I am asking This question only because I am going to build a new-Blog that would be related to my learnings of Julia Programming and machine-learning. I want to buy domain name so I want it should be somehow give essence…

---

## [How to import functions defined in a Julia script file without running the script itslef](https://discourse.julialang.org/t/how-to-import-functions-defined-in-a-julia-script-file-without-running-the-script-itslef/6603)

<div class="topic-metadata">

**Author:** [@lucatrv](https://discourse.julialang.org/u/lucatrv)\
**Replies:** 16\
**Last updated:** [October 30, 2017, 8:36pm UTC](https://discourse.julialang.org/t/how-to-import-functions-defined-in-a-julia-script-file-without-running-the-script-itslef/6603 "2017-10-30T20:36:56Z")

</div>

I would like to reopen this topic already discussed years ago at the following links: https://stackoverflow.com/questions/14462557/within-a-julia-script-can-you-tell-whether-the-script-has-been-imported-or-exec https:/…

---

## [Storage allocation in LAPACK.potrf!](https://discourse.julialang.org/t/storage-allocation-in-lapack-potrf/82)

<div class="topic-metadata">

**Author:** [@dmbates](https://discourse.julialang.org/u/dmbates)\
**Replies:** 4\
**Last updated:** [October 30, 2017, 6:02pm UTC](https://discourse.julialang.org/t/storage-allocation-in-lapack-potrf/82 "2017-10-30T18:02:12Z")

</div>

This is a duplicate of Redirecting to Google Groups . I decided to move the conversation to discourse because it allows for formatting of code. I am encountering an unexpected amount of storage allocation in the cfactor…

---

## [Named arguments in type](https://discourse.julialang.org/t/named-arguments-in-type/6780)

<div class="topic-metadata">

**Author:** [@sysint64](https://discourse.julialang.org/u/sysint64)\
**Replies:** 2\
**Last updated:** [October 30, 2017, 5:07pm UTC](https://discourse.julialang.org/t/named-arguments-in-type/6780 "2017-10-30T17:07:05Z")

</div>

Hello is there way to construct struct by their argument names e.g.: type Position x::Int y::Int end # OK Position(1, 2) # MethodError: no method matching Position(; x=1, y=2) Position(x=1, y=2)

---

## [Why are ↗, ↖ not useable as Binary infix operators?](https://discourse.julialang.org/t/why-are-not-useable-as-binary-infix-operators/6777)

<div class="topic-metadata">

**Author:** [@chakravala](https://discourse.julialang.org/u/chakravala)\
**Replies:** 2\
**Last updated:** [October 30, 2017, 3:50pm UTC](https://discourse.julialang.org/t/why-are-not-useable-as-binary-infix-operators/6777 "2017-10-30T15:50:06Z")

</div>

It seems to be possible to define all sorts of binary infix operators, like ∨, ⋖, ⋗, ⊴ work fine. But why can’t I assign ↗, ↖ as binary infix operators? they are \\nearrow and \\nwarrow. For example, in my Dendriform.jl …

---

## [Displaying IPython Widgets](https://discourse.julialang.org/t/displaying-ipython-widgets/6755)

<div class="topic-metadata">

**Author:** [@cortner](https://discourse.julialang.org/u/cortner)\
**Replies:** 2\
**Last updated:** [October 30, 2017, 12:12pm UTC](https://discourse.julialang.org/t/displaying-ipython-widgets/6755 "2017-10-30T12:12:16Z")

</div>

I am using the Python package nglview to create a visualisation. The object it generates is a PyObject \<nglview.widget.NGLWidget ...\> and looking at the source-code of nglview this is a subclass of ipywidgets.DOMWidget. …

---

## [@allocate in REPL, different results, same code](https://discourse.julialang.org/t/allocate-in-repl-different-results-same-code/6756)

<div class="topic-metadata">

**Author:** [@goretkin](https://discourse.julialang.org/u/goretkin)\
**Replies:** 3\
**Last updated:** [October 30, 2017, 12:39am UTC](https://discourse.julialang.org/t/allocate-in-repl-different-results-same-code/6756 "2017-10-30T00:39:23Z")

</div>

function ha(x) return (x, x) end function hs(x::StridedMatrix{Float64}) return (x, x) end In a global scope and/or REPL: x = eye(1); @show @allocated ha(x) @show @allocated ha(x) @show @allocated hs(x) @show @all…

---

## [How to generate expression inside the returned expression of a Macro](https://discourse.julialang.org/t/how-to-generate-expression-inside-the-returned-expression-of-a-macro/6758)

<div class="topic-metadata">

**Author:** [@favba](https://discourse.julialang.org/u/favba)\
**Replies:** 2\
**Last updated:** [October 29, 2017, 9:02pm UTC](https://discourse.julialang.org/t/how-to-generate-expression-inside-the-returned-expression-of-a-macro/6758 "2017-10-29T21:02:25Z")

</div>

Consider this macro: julia\> macro test(ex) return ex end @test (macro with 1 method) julia\> @macroexpand @test a=10 :(a = 10) Now, I want to make a macro that return that encapsulated in a expression, th…

---

## [In Sparse Matrices is posible condition in "combine"?](https://discourse.julialang.org/t/in-sparse-matrices-is-posible-condition-in-combine/6753)

<div class="topic-metadata">

**Author:** [@programista](https://discourse.julialang.org/u/programista)\
**Replies:** 4\
**Last updated:** [October 29, 2017, 7:13pm UTC](https://discourse.julialang.org/t/in-sparse-matrices-is-posible-condition-in-combine/6753 "2017-10-29T19:13:03Z")

</div>

sparse(I, J, V\[, m, n, combine \]) I must to igore new laue of V of old V is more then 0. is posible condition in combine ? e.g: + if V=0 else skip… Paul

---

## [Naive question about concurrency](https://discourse.julialang.org/t/naive-question-about-concurrency/3043)

<div class="topic-metadata">

**Author:** [@yakir12](https://discourse.julialang.org/u/yakir12)\
**Replies:** 4\
**Last updated:** [October 29, 2017, 2:13pm UTC](https://discourse.julialang.org/t/naive-question-about-concurrency/3043 "2017-10-29T14:13:08Z")

</div>

I really don’t know what I’m asking here, but: When writing code I frequently find that the points where different sections of code actually depend on each other are sparsely scattered across the code. This does not res…

---

## [User-defined primitive types -- how to access?](https://discourse.julialang.org/t/user-defined-primitive-types-how-to-access/6745)

<div class="topic-metadata">

**Author:** [@arch.d.robison](https://discourse.julialang.org/u/arch.d.robison)\
**Replies:** 2\
**Last updated:** [October 28, 2017, 6:22pm UTC](https://discourse.julialang.org/t/user-defined-primitive-types-how-to-access/6745 "2017-10-28T18:22:30Z")

</div>

The documentation explains how to declare a primitive type, but seems silent on how to set the bits or read them. For example, given: primitive type Foo 8 end how would I construct a Foo holding 42, or given a Foo, ho…

---

## [Is there any reason to set a metapackage to be precompiled?](https://discourse.julialang.org/t/is-there-any-reason-to-set-a-metapackage-to-be-precompiled/6744)

<div class="topic-metadata">

**Author:** [@ChrisRackauckas](https://discourse.julialang.org/u/ChrisRackauckas)\
**Replies:** 2\
**Last updated:** [October 28, 2017, 4:28pm UTC](https://discourse.julialang.org/t/is-there-any-reason-to-set-a-metapackage-to-be-precompiled/6744 "2017-10-28T16:28:55Z")

</div>

I am curious if there’s any benefit to precompiling a metapackage. DifferentialEquations.jl reexports a ton of packages which all themselves precompile. But precompiling DifferentialEquations.jl seems to precompile all …

---

## [Best way to handle variable types in function argument](https://discourse.julialang.org/t/best-way-to-handle-variable-types-in-function-argument/6719)

<div class="topic-metadata">

**Author:** [@Balinus](https://discourse.julialang.org/u/Balinus)\
**Replies:** 12\
**Last updated:** [October 28, 2017, 2:55pm UTC](https://discourse.julialang.org/t/best-way-to-handle-variable-types-in-function-argument/6719 "2017-10-28T14:55:18Z")

</div>

Hello! In my work (Climate sciences) we often use netCDF files. I’m wondering about the best way to handle the possible types in these files and how it affect the function that will use the extracted arrays inside those…

---

## [Using PyPlot =\> ERROR: InitError: PyError (ccall(@pysym(:PyImport\_ImportModule), PyPtr, (Cstring,), name)](https://discourse.julialang.org/t/using-pyplot-error-initerror-pyerror-ccall-pysym-pyimport-importmodule-pyptr-cstring-name/6733)

<div class="topic-metadata">

**Author:** [@XavierG](https://discourse.julialang.org/u/XavierG)\
**Replies:** 1\
**Last updated:** [October 28, 2017, 7:04am UTC](https://discourse.julialang.org/t/using-pyplot-error-initerror-pyerror-ccall-pysym-pyimport-importmodule-pyptr-cstring-name/6733 "2017-10-28T07:04:10Z")

</div>

Hi, I have Julia installed on 2 mac (macOS 10.12.6) since last June. All is perfect on both computers with ver 0.6.0 of Julia. I installed today the ver 0.6.1, and now I have a problem when I invoke “using PyPlot” (se…

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

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