# General Usage

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

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

**Page:** 945

---

## [User-dependent meta-programming and recompilation](https://discourse.julialang.org/t/user-dependent-meta-programming-and-recompilation/14468)

<div class="topic-metadata">

**Author:** [@forgot\_the\_comma](https://discourse.julialang.org/u/forgot_the_comma)\
**Replies:** 7\
**Last updated:** [September 3, 2018, 4:42pm UTC](https://discourse.julialang.org/t/user-dependent-meta-programming-and-recompilation/14468 "2018-09-03T16:42:52Z")

</div>

So if you can’t tell by my username, I’m a horrendous programmer. That said, I’m hoping to get opinions on the following: 1. What would actually be a decent way to achieve this 2. Is there any hope for user-dependent m…

---

## [Is REQUIRE required?](https://discourse.julialang.org/t/is-require-required/14487)

<div class="topic-metadata">

**Author:** [@PetrKryslUCSD](https://discourse.julialang.org/u/PetrKryslUCSD)\
**Replies:** 2\
**Last updated:** [September 3, 2018, 3:45pm UTC](https://discourse.julialang.org/t/is-require-required/14487 "2018-09-03T15:45:55Z")

</div>

I am getting CI Travis erros: 11.09s$ julia -e 'import Pkg; Pkg.clone("https://github.com/PetrKryslUCSD/FinEtools.jl.git");' ┌ Warning: Pkg.clone is only kept for legacy CI script reasons, please use \`add\` └ @ Pkg.API /…

---

## [When my script crashes in REPL does GC also crash?](https://discourse.julialang.org/t/when-my-script-crashes-in-repl-does-gc-also-crash/14482)

<div class="topic-metadata">

**Author:** [@LeoK987](https://discourse.julialang.org/u/LeoK987)\
**Replies:** 5\
**Last updated:** [September 3, 2018, 3:06pm UTC](https://discourse.julialang.org/t/when-my-script-crashes-in-repl-does-gc-also-crash/14482 "2018-09-03T15:06:57Z")

</div>

So, I noticed that if my script crashes, and I need to make changes and rerun the script inside the REPL, after some time, julia’s memory usage goes up, and at some point I have to restart the REPL So, does GC crashes w…

---

## [Method overwritten by keyword-arguments-only version](https://discourse.julialang.org/t/method-overwritten-by-keyword-arguments-only-version/14484)

<div class="topic-metadata">

**Author:** [@DominiqueMakowski](https://discourse.julialang.org/u/DominiqueMakowski)\
**Replies:** 5\
**Last updated:** [September 3, 2018, 2:32pm UTC](https://discourse.julialang.org/t/method-overwritten-by-keyword-arguments-only-version/14484 "2018-09-03T14:32:05Z")

</div>

I’d like to have two versions of a function, with and without kwargs. On Julia 0.7, these two lines run without problem: f(x=3) = x+3 f(; x=3) = f(x) however, upon compilation of the module, it says WARNING: Method de…

---

## [Removing symbols from compiled julia code](https://discourse.julialang.org/t/removing-symbols-from-compiled-julia-code/14476)

<div class="topic-metadata">

**Author:** [@Jaap\_Haitsma](https://discourse.julialang.org/u/Jaap_Haitsma)\
**Replies:** 0\
**Last updated:** [September 3, 2018, 11:54am UTC](https://discourse.julialang.org/t/removing-symbols-from-compiled-julia-code/14476 "2018-09-03T11:54:47Z")

</div>

In order to make reverse engineering of my compiled Julia app more difficult I would like to remove all symbols of internal functions from the .dylib file that juliac.jl of Package Compiler produces. Is there a way to d…

---

## [Add \`nice -19\` worker process](https://discourse.julialang.org/t/add-nice-19-worker-process/14471)

<div class="topic-metadata">

**Author:** [@carstenbauer](https://discourse.julialang.org/u/carstenbauer)\
**Replies:** 2\
**Last updated:** [September 3, 2018, 10:57am UTC](https://discourse.julialang.org/t/add-nice-19-worker-process/14471 "2018-09-03T10:57:46Z")

</div>

I want to start a worker process on a different node with a certain niceness. Basically, I want to prepend the command generated by addprocs(\["mynode"\]) with nice -19. As has suggested to me on Slack, there is the exen…

---

## [Compact float printing in the REPL](https://discourse.julialang.org/t/compact-float-printing-in-the-repl/4561)

<div class="topic-metadata">

**Author:** [@DNF](https://discourse.julialang.org/u/DNF)\
**Replies:** 8\
**Last updated:** [September 3, 2018, 9:56am UTC](https://discourse.julialang.org/t/compact-float-printing-in-the-repl/4561 "2018-09-03T09:56:41Z")

</div>

How can I globally change the printing format of the REPL? I would specifically like to change the formatting of floats to a more compact style so that julia\> 10/3 3.3333 instead of julia\> 10/3 3.3333333333333335 I f…

---

## [Optim returns slightly different result in unit testing environment](https://discourse.julialang.org/t/optim-returns-slightly-different-result-in-unit-testing-environment/14460)

<div class="topic-metadata">

**Author:** [@tk3369](https://discourse.julialang.org/u/tk3369)\
**Replies:** 6\
**Last updated:** [September 3, 2018, 6:15am UTC](https://discourse.julialang.org/t/optim-returns-slightly-different-result-in-unit-testing-environment/14460 "2018-09-03T06:15:36Z")

</div>

I’ve been scratching my head in the past few hours with no answer. I hope someone has a clue. I added some unit test cases for the BoxCoxTrans.jl package (unregistered) but the test fails only in the unit testing enviro…

---

## [Is there a matlab-style linter for finding straggler code?](https://discourse.julialang.org/t/is-there-a-matlab-style-linter-for-finding-straggler-code/14447)

<div class="topic-metadata">

**Author:** [@djsegal](https://discourse.julialang.org/u/djsegal)\
**Replies:** 8\
**Last updated:** [September 3, 2018, 5:59am UTC](https://discourse.julialang.org/t/is-there-a-matlab-style-linter-for-finding-straggler-code/14447 "2018-09-03T05:59:05Z")

</div>

I remember in matlab, if you had some buggy line like the one that follows, it would give you a nice red squiggle and a note telling you that you probably messed up: cur\_RHS = K\_F(cur\_reactor) cur\_RHS = K\_n(cur\_reactor…

---

## [Issue with shell mode on 1.0](https://discourse.julialang.org/t/issue-with-shell-mode-on-1-0/14449)

<div class="topic-metadata">

**Author:** [@essenciary](https://discourse.julialang.org/u/essenciary)\
**Replies:** 3\
**Last updated:** [September 2, 2018, 8:59pm UTC](https://discourse.julialang.org/t/issue-with-shell-mode-on-1-0/14449 "2018-09-02T20:59:44Z")

</div>

Shell mode seems to be broken on v1.0 when trying to do this: shell\> cd ~/.julia/config/ ERROR: IOError: chdir 3035: no such file or directory (ENOENT) Stacktrace: \[1\] uv\_error at ./libuv.jl:85 \[inlined\] \[2\] cd(::Stri…

---

## [Preallocating an Array with a given size in Julia 1.0](https://discourse.julialang.org/t/preallocating-an-array-with-a-given-size-in-julia-1-0/14438)

<div class="topic-metadata">

**Author:** [@OvidiusCicero](https://discourse.julialang.org/u/OvidiusCicero)\
**Replies:** 4\
**Last updated:** [September 2, 2018, 7:21pm UTC](https://discourse.julialang.org/t/preallocating-an-array-with-a-given-size-in-julia-1-0/14438 "2018-09-02T19:21:43Z")

</div>

Hi there, I’m trying to preallocate an array of hundred elements of Float64 just as one would declare in C or something else. It seems that before the code was Vector{Float64,1}(1000) but now I get an error when trying…

---

## [Way to split symbolic product into individual parts?](https://discourse.julialang.org/t/way-to-split-symbolic-product-into-individual-parts/14445)

<div class="topic-metadata">

**Author:** [@djsegal](https://discourse.julialang.org/u/djsegal)\
**Replies:** 0\
**Last updated:** [September 2, 2018, 7:05pm UTC](https://discourse.julialang.org/t/way-to-split-symbolic-product-into-individual-parts/14445 "2018-09-02T19:05:28Z")

</div>

Let’s say you have a symbolic equation: @syms w x y z cur\_eq = w^2 · x · ( z + 1/2 ) How can you work that equation down so you have the following? cur\_w\_part = w^2 cur\_x\_part = x cur\_y\_part = nothing cur\_eq = ( z + …

---

## [Strings and embedding](https://discourse.julialang.org/t/strings-and-embedding/14433)

<div class="topic-metadata">

**Author:** [@bjornerstedt](https://discourse.julialang.org/u/bjornerstedt)\
**Replies:** 1\
**Last updated:** [September 2, 2018, 6:03pm UTC](https://discourse.julialang.org/t/strings-and-embedding/14433 "2018-09-02T18:03:48Z")

</div>

I am trying to convert a String returned from Julia. How do you get a string from a jl\_value\_t to a char \* in C?

---

## [Changing order of Type Parameters (0.6)](https://discourse.julialang.org/t/changing-order-of-type-parameters-0-6/14423)

<div class="topic-metadata">

**Author:** [@rakeshvar](https://discourse.julialang.org/u/rakeshvar)\
**Replies:** 1\
**Last updated:** [September 2, 2018, 10:55am UTC](https://discourse.julialang.org/t/changing-order-of-type-parameters-0-6/14423 "2018-09-02T10:55:36Z")

</div>

Why is B ok and BB not? How do I get BB to work? abstract type AbsA{F\<:AbstractFloat} end struct A{F} \<: AbsA{F} data::F end a = A(9.) # OK abstract type AbsB{F\<:AbstractFloat} end struct B{F, TA\<:AbsA{F}} \<: AbsB…

---

## [How to accelerate matrix operations(multiplication, add, inverse) in a for loop?](https://discourse.julialang.org/t/how-to-accelerate-matrix-operations-multiplication-add-inverse-in-a-for-loop/14157)

<div class="topic-metadata">

**Author:** [@complexfilter](https://discourse.julialang.org/u/complexfilter)\
**Replies:** 22\
**Last updated:** [September 2, 2018, 6:35am UTC](https://discourse.julialang.org/t/how-to-accelerate-matrix-operations-multiplication-add-inverse-in-a-for-loop/14157 "2018-09-02T06:35:49Z")

</div>

How to accelerate typical matrix operations in a for loop? I am currently rewriting my Matlab code to Julia. However, I find it only 3.5X the speed as Matlab. Are there any ways to further improve the Julia speed? Like…

---

## [Many examples included in the docs don't work in Julia 1.0](https://discourse.julialang.org/t/many-examples-included-in-the-docs-dont-work-in-julia-1-0/14410)

<div class="topic-metadata">

**Author:** [@justwawre](https://discourse.julialang.org/u/justwawre)\
**Replies:** 8\
**Last updated:** [September 2, 2018, 4:32am UTC](https://discourse.julialang.org/t/many-examples-included-in-the-docs-dont-work-in-julia-1-0/14410 "2018-09-02T04:32:00Z")

</div>

e.g. julia\> search("xylophone", 'p') ERROR: UndefVarError: search not defined Stacktrace: \[1\] top-level scope at none:0

---

## [Best way to make "present?" function in Julia?](https://discourse.julialang.org/t/best-way-to-make-present-function-in-julia/14394)

<div class="topic-metadata">

**Author:** [@djsegal](https://discourse.julialang.org/u/djsegal)\
**Replies:** 9\
**Last updated:** [September 1, 2018, 1:42pm UTC](https://discourse.julialang.org/t/best-way-to-make-present-function-in-julia/14394 "2018-09-01T13:42:16Z")

</div>

Rails has this function called .present? that really helps with one-liners // i.e. is something not nothing, nil, missing, zilch, nada What is the best way to replicate this behavior in Julia? edit: this is kind of…

---

## [Help me refine my blog post introducing the value type](https://discourse.julialang.org/t/help-me-refine-my-blog-post-introducing-the-value-type/13857)

<div class="topic-metadata">

**Author:** [@Wenjie](https://discourse.julialang.org/u/Wenjie)\
**Replies:** 11\
**Last updated:** [September 1, 2018, 9:38am UTC](https://discourse.julialang.org/t/help-me-refine-my-blog-post-introducing-the-value-type/13857 "2018-09-01T09:38:53Z")

</div>

I am amazed by the value type in Julia and hence wrote a blog post about it. During the writing, some idea came to my mind, and I’ll express it as follows. I want to define the root function in a weird way root( x::Flo…

---

## [No Way to Rename Macros?](https://discourse.julialang.org/t/no-way-to-rename-macros/14344)

<div class="topic-metadata">

**Author:** [@mattcbro](https://discourse.julialang.org/u/mattcbro)\
**Replies:** 4\
**Last updated:** [September 1, 2018, 2:29am UTC](https://discourse.julialang.org/t/no-way-to-rename-macros/14344 "2018-09-01T02:29:40Z")

</div>

After the significant changes between 0.6.4 and 0.7 and up, I have tasked myself the job of creating version independent code. There are several instances where a simple replacement of one macro name with another woul…

---

## [@code\_warntype infers DArray as Any](https://discourse.julialang.org/t/code-warntype-infers-darray-as-any/14386)

<div class="topic-metadata">

**Author:** [@sparrowhawk](https://discourse.julialang.org/u/sparrowhawk)\
**Replies:** 0\
**Last updated:** [August 31, 2018, 11:05pm UTC](https://discourse.julialang.org/t/code-warntype-infers-darray-as-any/14386 "2018-08-31T23:05:59Z")

</div>

Why does my function show this warning on the type of output DArray? addprocs(4) using DistributedArrays function myfill(v::Int) D = DArray((nworkers(),), workers()) do I \[v\] end return D end…

---

## [Determine possibility to sort via hasmethod(isless, (T,T) for AbstractVector{T}](https://discourse.julialang.org/t/determine-possibility-to-sort-via-hasmethod-isless-t-t-for-abstractvector-t/14291)

<div class="topic-metadata">

**Author:** [@laborg](https://discourse.julialang.org/u/laborg)\
**Replies:** 6\
**Last updated:** [August 31, 2018, 10:28pm UTC](https://discourse.julialang.org/t/determine-possibility-to-sort-via-hasmethod-isless-t-t-for-abstractvector-t/14291 "2018-08-31T22:28:07Z")

</div>

I want to decide if an AbstractVector is sorted to adequately choose the code path for my algorithm. For this I first need to know if it is safe to call issorted(A). Are there faster/better/more robust ways than doing it…

---

## [Best way to repeatedly multiply a Vector by a SparseMatrix](https://discourse.julialang.org/t/best-way-to-repeatedly-multiply-a-vector-by-a-sparsematrix/14355)

<div class="topic-metadata">

**Author:** [@teored90](https://discourse.julialang.org/u/teored90)\
**Replies:** 10\
**Last updated:** [August 31, 2018, 9:03pm UTC](https://discourse.julialang.org/t/best-way-to-repeatedly-multiply-a-vector-by-a-sparsematrix/14355 "2018-08-31T21:03:35Z")

</div>

Hi, in my code I need to evaluate A^n \* v where A is a possibly very large sparse matrix and v is a vector. I suppose it is much faster to perform A \* (A \* ... \* (A \* v) rather than elevating A to the n-th power, but wh…

---

## [Using \> and \>\> as kwargs](https://discourse.julialang.org/t/using-and-as-kwargs/14363)

<div class="topic-metadata">

**Author:** [@joa-quim](https://discourse.julialang.org/u/joa-quim)\
**Replies:** 13\
**Last updated:** [August 31, 2018, 8:30pm UTC](https://discourse.julialang.org/t/using-and-as-kwargs/14363 "2018-08-31T20:30:28Z")

</div>

Hi, I would like to be able to use the \> and \>\> characters as valid kwarg names. Example julia\> grd2xyz(G, \>="lixo.xyz") ERROR: syntax: "\>=" is not a unary operator The reason why it fails seems understandable, but I …

---

## ["do" notation over tuples](https://discourse.julialang.org/t/do-notation-over-tuples/14379)

<div class="topic-metadata">

**Author:** [@cscherrer](https://discourse.julialang.org/u/cscherrer)\
**Replies:** 5\
**Last updated:** [August 31, 2018, 7:26pm UTC](https://discourse.julialang.org/t/do-notation-over-tuples/14379 "2018-08-31T19:26:45Z")

</div>

What am I doing wrong here? julia\> inds = \[(i,j) for i in 1:3, j in 1:5\] 3×5 Array{Tuple{Int64,Int64},2}: (1, 1) (1, 2) (1, 3) (1, 4) (1, 5) (2, 1) (2, 2) (2, 3) (2, 4) (2, 5) (3, 1) (3, 2) (3, 3) (3, 4) …

---

## [Memory allocations in for loop variable](https://discourse.julialang.org/t/memory-allocations-in-for-loop-variable/14332)

<div class="topic-metadata">

**Author:** [@amit112amit](https://discourse.julialang.org/u/amit112amit)\
**Replies:** 28\
**Last updated:** [August 31, 2018, 3:39pm UTC](https://discourse.julialang.org/t/memory-allocations-in-for-loop-variable/14332 "2018-08-31T15:39:29Z")

</div>

Can someone explain how to minimize the memory allocations in the line for i=1:N. The following is output from running --track-allocation=user for a simple function. - using LinearAlgebra: norm - functi…

---

## [Output for @code\_llvm changed from 0.6 to 0.7, 1.0](https://discourse.julialang.org/t/output-for-code-llvm-changed-from-0-6-to-0-7-1-0/14166)

<div class="topic-metadata">

**Author:** [@John\_Gibson](https://discourse.julialang.org/u/John_Gibson)\
**Replies:** 17\
**Last updated:** [August 31, 2018, 2:01pm UTC](https://discourse.julialang.org/t/output-for-code-llvm-changed-from-0-6-to-0-7-1-0/14166 "2018-08-31T14:01:10Z")

</div>

The output of @code\_llvm is more verbose on 0.7 and 1.0 than it was on 0.6. On 0.6.4 julia\> f(x) = 3x+2 f (generic function with 1 method) julia\> @code\_llvm f(1.0) define double @julia\_f\_62581(double) #0 !dbg !5 { to…

---

## [Function runs much slower from the Julia command prompt](https://discourse.julialang.org/t/function-runs-much-slower-from-the-julia-command-prompt/14305)

<div class="topic-metadata">

**Author:** [@pythonuser](https://discourse.julialang.org/u/pythonuser)\
**Replies:** 5\
**Last updated:** [August 31, 2018, 12:06pm UTC](https://discourse.julialang.org/t/function-runs-much-slower-from-the-julia-command-prompt/14305 "2018-08-31T12:06:50Z")

</div>

Ok, so I am a relatively new Julia user. I have a program which uses parallelism. When i run a test script to execute the function from the Juno editor, the function execution speed is good. However, when i run the same…

---

## [Chain several shell commands to get current commit of git folder](https://discourse.julialang.org/t/chain-several-shell-commands-to-get-current-commit-of-git-folder/14359)

<div class="topic-metadata">

**Author:** [@migarstka](https://discourse.julialang.org/u/migarstka)\
**Replies:** 1\
**Last updated:** [August 31, 2018, 12:02pm UTC](https://discourse.julialang.org/t/chain-several-shell-commands-to-get-current-commit-of-git-folder/14359 "2018-08-31T12:02:27Z")

</div>

Let’s say I want to print the information of the latest commit hash of a git repo to a result file. The following command would give a string of the latest commit for the current folder. commit = read(\`git rev-parse H…

---

## [Broadcasting of minus as prefix operator](https://discourse.julialang.org/t/broadcasting-of-minus-as-prefix-operator/14353)

<div class="topic-metadata">

**Author:** [@stakaz](https://discourse.julialang.org/u/stakaz)\
**Replies:** 8\
**Last updated:** [August 31, 2018, 8:12am UTC](https://discourse.julialang.org/t/broadcasting-of-minus-as-prefix-operator/14353 "2018-08-31T08:12:29Z")

</div>

Hello, I have the following technical question: when using - as prefix operator, does it get broadcasted as it would be an operator with a dot, i.e. is this x = 2 y = \[1,2,3\] z = -x .+ y equivalent to x = 2 y = \[1,2,3…

---

## [Program execution is really slow from command line/HTTP server endpoint](https://discourse.julialang.org/t/program-execution-is-really-slow-from-command-line-http-server-endpoint/14307)

<div class="topic-metadata">

**Author:** [@pythonuser](https://discourse.julialang.org/u/pythonuser)\
**Replies:** 2\
**Last updated:** [August 31, 2018, 6:27am UTC](https://discourse.julialang.org/t/program-execution-is-really-slow-from-command-line-http-server-endpoint/14307 "2018-08-31T06:27:32Z")

</div>

Ok, so I am a relatively new Julia user. I have a program which uses parallelism. I am also building an API endpoint around this program using HTTP.jl. The function execution time is really fast from the Juno editor. Ho…

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

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