# General Usage

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

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

**Page:** 1071

---

## [Constraints on parametrized abstract types](https://discourse.julialang.org/t/constraints-on-parametrized-abstract-types/1344)

<div class="topic-metadata">

**Author:** [@juliohm](https://discourse.julialang.org/u/juliohm)\
**Replies:** 9\
**Last updated:** [January 8, 2017, 5:09pm UTC](https://discourse.julialang.org/t/constraints-on-parametrized-abstract-types/1344 "2017-01-08T17:09:05Z")

</div>

Is there any mechanism for constraining numerical parameters of abstract types? abstract Var{dim\<:Integer} # can we enforce dim \> 0 ?

---

## [Type signature for nested \`AbstractArray\`](https://discourse.julialang.org/t/type-signature-for-nested-abstractarray/1352)

<div class="topic-metadata">

**Author:** [@Tamas\_Papp](https://discourse.julialang.org/u/Tamas_Papp)\
**Replies:** 1\
**Last updated:** [January 8, 2017, 3:00pm UTC](https://discourse.julialang.org/t/type-signature-for-nested-abstractarray/1352 "2017-01-08T15:00:11Z")

</div>

I would like a method foo(x) to be called when x is a U{V{T,N}, where U \<: AbstractVector, S \<: AbstractArray{T,N} and I can’t figure out how. Thought that since Array{Int,2} \<: AbstractArray{Int,2}\` I would have V…

---

## [What exactly code lowering is an how to do "unlowering"?](https://discourse.julialang.org/t/what-exactly-code-lowering-is-an-how-to-do-unlowering/1315)

<div class="topic-metadata">

**Author:** [@dfdx](https://discourse.julialang.org/u/dfdx)\
**Replies:** 8\
**Last updated:** [January 8, 2017, 1:02am UTC](https://discourse.julialang.org/t/what-exactly-code-lowering-is-an-how-to-do-unlowering/1315 "2017-01-08T01:02:16Z")

</div>

I’ve seen a number of snippets produced by code\_lowered and have rough intuition of what it does, but what’s exact definition of code lowering? Does “lower” means “more low-level”? In my package I need to get an exp…

---

## [Equiavalent of @threadcall but for Julia code?](https://discourse.julialang.org/t/equiavalent-of-threadcall-but-for-julia-code/1335)

<div class="topic-metadata">

**Author:** [@jtravs](https://discourse.julialang.org/u/jtravs)\
**Replies:** 5\
**Last updated:** [January 7, 2017, 11:42pm UTC](https://discourse.julialang.org/t/equiavalent-of-threadcall-but-for-julia-code/1335 "2017-01-07T23:42:35Z")

</div>

Is there a way to run a Julia function on another thread? As far as I can tell the current (and I do understand experimental) threading support provides for parallel threaded for loops and @threadcall for calling a c fun…

---

## [Modifying vector in an immutable](https://discourse.julialang.org/t/modifying-vector-in-an-immutable/1339)

<div class="topic-metadata">

**Author:** [@Tamas\_Papp](https://discourse.julialang.org/u/Tamas_Papp)\
**Replies:** 3\
**Last updated:** [January 7, 2017, 5:49pm UTC](https://discourse.julialang.org/t/modifying-vector-in-an-immutable/1339 "2017-01-07T17:49:26Z")

</div>

When an immutable has a Vector field, is it allowed to modify that using ! functions (like these)? My understanding is that even if the underlying memory is remapped (eg because the vector grows or shrinks too much), it …

---

## [Union of Unions](https://discourse.julialang.org/t/union-of-unions/1348)

<div class="topic-metadata">

**Author:** [@krcools](https://discourse.julialang.org/u/krcools)\
**Replies:** 4\
**Last updated:** [January 7, 2017, 5:47pm UTC](https://discourse.julialang.org/t/union-of-unions/1348 "2017-01-07T17:47:24Z")

</div>

Is there a simple way to construct Union{A,B,C} from Union{A,B} and Union{B,C}? My initial guess was typejoin, but: AB = Union{Val{:A}, Val{:B}} BC = Union{Val{:B}, Val{:C}} typejoin(AB,BC) == Val Which I guess is corr…

---

## ["unzip" a vector of Pairs](https://discourse.julialang.org/t/unzip-a-vector-of-pairs/1346)

<div class="topic-metadata">

**Author:** [@Tamas\_Papp](https://discourse.julialang.org/u/Tamas_Papp)\
**Replies:** 2\
**Last updated:** [January 7, 2017, 4:20pm UTC](https://discourse.julialang.org/t/unzip-a-vector-of-pairs/1346 "2017-01-07T16:20:38Z")

</div>

Given a Vector of Pairs, what’s an idiomatic way of getting a vector of first and second elements in each Pair? MWE: x = \[Pair(x,2\*x) for x in 1:5\] then julia\> collect.(collect(zip(((a,b) for (a,b) in x)...))) # wor…

---

## [Subtleties of type and immutable and memory layout when using ccall](https://discourse.julialang.org/t/subtleties-of-type-and-immutable-and-memory-layout-when-using-ccall/1328)

<div class="topic-metadata">

**Author:** [@jtravs](https://discourse.julialang.org/u/jtravs)\
**Replies:** 4\
**Last updated:** [January 6, 2017, 8:39pm UTC](https://discourse.julialang.org/t/subtleties-of-type-and-immutable-and-memory-layout-when-using-ccall/1328 "2017-01-06T20:39:22Z")

</div>

I have spent considerable time finding a bug in my code related to memory layout of types and immutables when interfacing with structs in c. I want to summarize here to check my understanding and as it may be useful to o…

---

## [Quoting operator & literals](https://discourse.julialang.org/t/quoting-operator-literals/1327)

<div class="topic-metadata">

**Author:** [@Mike\_Aizatsky](https://discourse.julialang.org/u/Mike_Aizatsky)\
**Replies:** 4\
**Last updated:** [January 6, 2017, 4:14pm UTC](https://discourse.julialang.org/t/quoting-operator-literals/1327 "2017-01-06T16:14:10Z")

</div>

I’m trying to write some meta-code and I found that : operator return type is inconsistent: \> typeof(:(x)), typeof(:(1)) (Symbol,Int64) I would expect the result of : to be always Expr, but it doesn’t seem to be true f…

---

## [Defining a constructor for partially parameterized type](https://discourse.julialang.org/t/defining-a-constructor-for-partially-parameterized-type/1307)

<div class="topic-metadata">

**Author:** [@stevengj](https://discourse.julialang.org/u/stevengj)\
**Replies:** 3\
**Last updated:** [January 6, 2017, 2:57pm UTC](https://discourse.julialang.org/t/defining-a-constructor-for-partially-parameterized-type/1307 "2017-01-06T14:57:01Z")

</div>

If I have a parameterized type Foo{X,Y}, how can I define a constructor for Foo{X} that assigns a default value to Y? For example, the following didn’t work: julia\> type Foo{X,Y}; end julia\> (::Foo{X}){X}() = Foo{X,tru…

---

## [Create QuoteNode in Expr](https://discourse.julialang.org/t/create-quotenode-in-expr/1319)

<div class="topic-metadata">

**Author:** [@lobingera](https://discourse.julialang.org/u/lobingera)\
**Replies:** 6\
**Last updated:** [January 6, 2017, 9:22am UTC](https://discourse.julialang.org/t/create-quotenode-in-expr/1319 "2017-01-06T09:22:46Z")

</div>

I’m trying to build this ccall((:u3,"./u1.so"),Float64,(Float64,),x) as expression, so i can eval (it’s a longer story of library/code adaptation …) julia\> u1 = "ccall((:u3,\\"./u1.so\\"),Float64,(Float64,),x)" "ccall(…

---

## [Create a type with pointer to array](https://discourse.julialang.org/t/create-a-type-with-pointer-to-array/1306)

<div class="topic-metadata">

**Author:** [@mzilhao](https://discourse.julialang.org/u/mzilhao)\
**Replies:** 9\
**Last updated:** [January 6, 2017, 2:00am UTC](https://discourse.julialang.org/t/create-a-type-with-pointer-to-array/1306 "2017-01-06T02:00:26Z")

</div>

hi all, I’m new to Julia, and still getting used to the Julia-way of doing things. I was wondering if there is anything that would work as a pointer would in C, or as a reference variable in C++? the particular use cas…

---

## [Problem with escaping anonymous function expressions and let blocks](https://discourse.julialang.org/t/problem-with-escaping-anonymous-function-expressions-and-let-blocks/1314)

<div class="topic-metadata">

**Author:** [@ti-s](https://discourse.julialang.org/u/ti-s)\
**Replies:** 3\
**Last updated:** [January 6, 2017, 1:11am UTC](https://discourse.julialang.org/t/problem-with-escaping-anonymous-function-expressions-and-let-blocks/1314 "2017-01-06T01:11:02Z")

</div>

Consider a macro like: manipulate\_expr(expr) = esc(expr) macro test(expr) Expr(expr.head, esc(expr.args\[1\]), manipulate\_expr.(expr.args\[2:end\])...) end manipulate\_expr is a placeholder for a transformation of the A…

---

## [How to construct \`Expr(:tuple, ...)\` using templates](https://discourse.julialang.org/t/how-to-construct-expr-tuple-using-templates/1305)

<div class="topic-metadata">

**Author:** [@Tamas\_Papp](https://discourse.julialang.org/u/Tamas_Papp)\
**Replies:** 3\
**Last updated:** [January 5, 2017, 7:14pm UTC](https://discourse.julialang.org/t/how-to-construct-expr-tuple-using-templates/1305 "2017-01-05T19:14:30Z")

</div>

I tried to make an argument list for a closure from a tuple of symbols. MWE: ## what I want macro\_helper1(arguments, form) = :($(Expr(:tuple, arguments...)) -\> $form) ## how I tried to do it first macro\_helper2(argument…

---

## [Wrong results with multi-threading in Julia master](https://discourse.julialang.org/t/wrong-results-with-multi-threading-in-julia-master/1298)

<div class="topic-metadata">

**Author:** [@giordano](https://discourse.julialang.org/u/giordano)\
**Replies:** 1\
**Last updated:** [January 5, 2017, 3:24pm UTC](https://discourse.julialang.org/t/wrong-results-with-multi-threading-in-julia-master/1298 "2017-01-05T15:24:38Z")

</div>

I was playing with multi-threading in Julia master and noticed that my code currently gives wrong results when more than one thread is enabled. Julia 0.5: julia\> versioninfo() Julia Version 0.5.0 Commit 3c9d753 (2016-0…

---

## [Extend \`Base.+\` but don't export it by default](https://discourse.julialang.org/t/extend-base-but-dont-export-it-by-default/1282)

<div class="topic-metadata">

**Author:** [@dfdx](https://discourse.julialang.org/u/dfdx)\
**Replies:** 15\
**Last updated:** [January 5, 2017, 11:24am UTC](https://discourse.julialang.org/t/extend-base-but-dont-export-it-by-default/1282 "2017-01-05T11:24:47Z")

</div>

In my module A I have defined + for symbols. julia\> module A import Base: + +(x::Symbol, y::Symbol) = :(+($x, $y)) end A I would like to use it in some module B, but since adding 2 symbol…

---

## [@match type?](https://discourse.julialang.org/t/match-type/1232)

<div class="topic-metadata">

**Author:** [@stustd](https://discourse.julialang.org/u/stustd)\
**Replies:** 4\
**Last updated:** [January 5, 2017, 8:28am UTC](https://discourse.julialang.org/t/match-type/1232 "2017-01-05T08:28:02Z")

</div>

I’m utterly confused why the following code doesn’t produce identical results (i.e. selecting on type with @match (Match.jl) or if…elseif…end). With @match (get\_fmt1) regardless of the actual type, always an integer type…

---

## [How do I use catch\_backtrace()?](https://discourse.julialang.org/t/how-do-i-use-catch-backtrace/1218)

<div class="topic-metadata">

**Author:** [@bluesmoon](https://discourse.julialang.org/u/bluesmoon)\
**Replies:** 8\
**Last updated:** [January 4, 2017, 9:51pm UTC](https://discourse.julialang.org/t/how-do-i-use-catch-backtrace/1218 "2017-01-04T21:51:29Z")

</div>

I’m in Julia 0.4.5, and trying to use catch\_backtrace() in a catch block, but it just returns an array of Ptr objects and I’ve been unable to find any documentation detailing what to do with these Ptr objects. So, how d…

---

## [Named blocks and return](https://discourse.julialang.org/t/named-blocks-and-return/1267)

<div class="topic-metadata">

**Author:** [@Tamas\_Papp](https://discourse.julialang.org/u/Tamas_Papp)\
**Replies:** 5\
**Last updated:** [January 4, 2017, 10:16am UTC](https://discourse.julialang.org/t/named-blocks-and-return/1267 "2017-01-04T10:16:56Z")

</div>

Is there some control flow construct which would allow returning from an enclosing block instead of the current function? I am thinking of something similar to COMMON-LISP:RETURN-FROM. For example, it would be useful in …

---

## [Dispatch on both parametrized and non-parametrized type](https://discourse.julialang.org/t/dispatch-on-both-parametrized-and-non-parametrized-type/1246)

<div class="topic-metadata">

**Author:** [@Tamas\_Papp](https://discourse.julialang.org/u/Tamas_Papp)\
**Replies:** 4\
**Last updated:** [January 3, 2017, 6:32pm UTC](https://discourse.julialang.org/t/dispatch-on-both-parametrized-and-non-parametrized-type/1246 "2017-01-03T18:32:19Z")

</div>

I would like to write a function that returns something for each type it is defined for. Importantly, it needs to dispatch on types, not instances, since I need the result before I create the latter, it would be nice i…

---

## [Playing around with IntMod](https://discourse.julialang.org/t/playing-around-with-intmod/980)

<div class="topic-metadata">

**Author:** [@pitao](https://discourse.julialang.org/u/pitao)\
**Replies:** 13\
**Last updated:** [January 3, 2017, 4:18pm UTC](https://discourse.julialang.org/t/playing-around-with-intmod/980 "2017-01-03T16:18:50Z")

</div>

I was having a play with https://github.com/JuliaLang/julia/blob/master/examples/modint.jl I tried adding a few goodies (rand, ^ and /): import Base: +, -, \*, ^, / immutable ModInt{n} \<: Integer k::Int ModInt(…

---

## [Splitdrive under windows](https://discourse.julialang.org/t/splitdrive-under-windows/1083)

<div class="topic-metadata">

**Author:** [@augustinyiptong](https://discourse.julialang.org/u/augustinyiptong)\
**Replies:** 2\
**Last updated:** [January 3, 2017, 4:11pm UTC](https://discourse.julialang.org/t/splitdrive-under-windows/1083 "2017-01-03T16:11:10Z")

</div>

Hi, i traced an issue i am having to splitdrive behaviour: splitdrive("\\\\\\\\servername\\\\hello.world\\\\filename.ext") gives: ("\\\\\\\\servername\\\\hello",".world\\\\filename.ext") Which results in normpath("\\\\\\\\servername\\\\h…

---

## [Function returning a constant vector (avoid recalculation and reallocation)](https://discourse.julialang.org/t/function-returning-a-constant-vector-avoid-recalculation-and-reallocation/1259)

<div class="topic-metadata">

**Author:** [@Tamas\_Papp](https://discourse.julialang.org/u/Tamas_Papp)\
**Replies:** 5\
**Last updated:** [January 3, 2017, 2:24pm UTC](https://discourse.julialang.org/t/function-returning-a-constant-vector-avoid-recalculation-and-reallocation/1259 "2017-01-03T14:24:11Z")

</div>

I have a function that returns a constant Vector. It is called frequently, and I would prefer if it generated the result once (eg when compiled), and from then on simply returned it without reallocation/regeneration. Thi…

---

## [Constant function](https://discourse.julialang.org/t/constant-function/1249)

<div class="topic-metadata">

**Author:** [@Tamas\_Papp](https://discourse.julialang.org/u/Tamas_Papp)\
**Replies:** 7\
**Last updated:** [January 3, 2017, 6:50am UTC](https://discourse.julialang.org/t/constant-function/1249 "2017-01-03T06:50:41Z")

</div>

is something like constantly(x) = (\_...) -\> x defined anywhere in the standard library, or a package? Note that I am not asking for it to be added, just would like to use the standard name if it exists. Most functiona…

---

## [Azure Service Fabric](https://discourse.julialang.org/t/azure-service-fabric/1244)

<div class="topic-metadata">

**Author:** [@anon67531922](https://discourse.julialang.org/u/anon67531922)\
**Replies:** 0\
**Last updated:** [January 2, 2017, 9:23am UTC](https://discourse.julialang.org/t/azure-service-fabric/1244 "2017-01-02T09:23:10Z")

</div>

Hi, I would love to be able to use Julia as a microservice on Azure Service Fabric. I’m just beginning to learn ASF, but thought I would ask if anyone has tried and/or has any ideas how to get started. I know it is an …

---

## [Sorting big int with v"0.6"](https://discourse.julialang.org/t/sorting-big-int-with-v-0-6/1241)

<div class="topic-metadata">

**Author:** [@j\_verzani](https://discourse.julialang.org/u/j_verzani)\
**Replies:** 1\
**Last updated:** [January 2, 2017, 9:52am UTC](https://discourse.julialang.org/t/sorting-big-int-with-v-0-6/1241 "2017-01-02T09:52:47Z")

</div>

Is this by design: | | |\_| | | | (\_| | | Version 0.6.0-dev.1746 (2016-12-29 05:44 UTC) \_/ |\\\_\_'\_|\_|\_|\\\_\_'\_| | Commit 07b7a7f (3 days old master) |\_\_/ | x86\_64-apple-darwin13.4.0 julia\> sort(\[bi…

---

## [Precompile() @generated functions](https://discourse.julialang.org/t/precompile-generated-functions/1240)

<div class="topic-metadata">

**Author:** [@smldis](https://discourse.julialang.org/u/smldis)\
**Replies:** 3\
**Last updated:** [January 2, 2017, 12:34am UTC](https://discourse.julialang.org/t/precompile-generated-functions/1240 "2017-01-02T00:34:15Z")

</div>

Hello, I am writing the initialization part of my julia program and I want to define functions that depend on parameters already defined. I am using @generated for the definition of the function. Then I have to use pr…

---

## [Teaching julia starting 20 jan. v0.5 or v0.6?](https://discourse.julialang.org/t/teaching-julia-starting-20-jan-v0-5-or-v0-6/1216)

<div class="topic-metadata">

**Author:** [@floswald](https://discourse.julialang.org/u/floswald)\
**Replies:** 4\
**Last updated:** [December 30, 2016, 10:22pm UTC](https://discourse.julialang.org/t/teaching-julia-starting-20-jan-v0-5-or-v0-6/1216 "2016-12-30T22:22:52Z")

</div>

Hi all, I’m teaching a course using julia. it starts around the 20th of january. based on stefan’s announcement here: 0.6 release timeline I’m uncertain of what the best option is for my students. I’m inclined to run th…

---

## [ERROR: Target architecture mismatch. Trying to get Julia working on a machine with multiple CPUs](https://discourse.julialang.org/t/error-target-architecture-mismatch-trying-to-get-julia-working-on-a-machine-with-multiple-cpus/1129)

<div class="topic-metadata">

**Author:** [@musm](https://discourse.julialang.org/u/musm)\
**Replies:** 5\
**Last updated:** [December 30, 2016, 8:44pm UTC](https://discourse.julialang.org/t/error-target-architecture-mismatch-trying-to-get-julia-working-on-a-machine-with-multiple-cpus/1129 "2016-12-30T20:44:35Z")

</div>

On a machine with Ubuntu 16.04 and 2 intel CPUs. EDIT: see post at the end. Apparently I can’t get Julia running on the other CPU on this machine. So the real question is how to build Julia on a machine with two physica…

---

## [Help with solving a world age error in package on julia master](https://discourse.julialang.org/t/help-with-solving-a-world-age-error-in-package-on-julia-master/1126)

<div class="topic-metadata">

**Author:** [@kristoffer.carlsson](https://discourse.julialang.org/u/kristoffer.carlsson)\
**Replies:** 11\
**Last updated:** [December 30, 2016, 1:50pm UTC](https://discourse.julialang.org/t/help-with-solving-a-world-age-error-in-package-on-julia-master/1126 "2016-12-30T13:50:41Z")

</div>

My package https://github.com/KristofferC/OhMyREPL.jl started failing on master with the error. julia\> WARNING: Caught an exception in the keymap: ERROR: MethodError: no method matching (::OhMyREPL.Prompt.##1#28)(::Base…

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

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