# General Usage

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

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

**Page:** 969

---

## [ReadOnlyMemoryError in ccall](https://discourse.julialang.org/t/readonlymemoryerror-in-ccall/11781)

<div class="topic-metadata">

**Author:** [@jonathanBieler](https://discourse.julialang.org/u/jonathanBieler)\
**Replies:** 11\
**Last updated:** [June 24, 2018, 10:09pm UTC](https://discourse.julialang.org/t/readonlymemoryerror-in-ccall/11781 "2018-06-24T22:09:20Z")

</div>

I’m trying to make my SDL bindings work on Linux but I’m getting this error that I don’t understand: julia\> ccall((:SDL\_Init, SDL2.libSDL2), Cint, (UInt32,), SDL2.INIT\_VIDEO) ERROR: ReadOnlyMemoryError() The function s…

---

## [Simple usage question reading a file](https://discourse.julialang.org/t/simple-usage-question-reading-a-file/11908)

<div class="topic-metadata">

**Author:** [@mkretlow](https://discourse.julialang.org/u/mkretlow)\
**Replies:** 14\
**Last updated:** [June 24, 2018, 7:53pm UTC](https://discourse.julialang.org/t/simple-usage-question-reading-a-file/11908 "2018-06-24T19:53:31Z")

</div>

Hi all. I have a very simple code snippet and I can’t figure out why I get this error: Simple text file to read: test.dat contains Fred 50 Mike 51 Ida 52 Code: f = open("test.dat") i = 1 for ln in eachli…

---

## [How to call a function that returns a function efficiently](https://discourse.julialang.org/t/how-to-call-a-function-that-returns-a-function-efficiently/11851)

<div class="topic-metadata">

**Author:** [@drarnau](https://discourse.julialang.org/u/drarnau)\
**Replies:** 24\
**Last updated:** [June 24, 2018, 4:52pm UTC](https://discourse.julialang.org/t/how-to-call-a-function-that-returns-a-function-efficiently/11851 "2018-06-24T16:52:47Z")

</div>

Dear all, I trying to move a computationally-intensive project from Fortran to Julia. Currently, the Fortran code takes around 7 minutes to run in my machine, while the Julia version takes around 106. Here is the bottl…

---

## [@fastmath switched off in Julia 0.7-Dev, deliberately?](https://discourse.julialang.org/t/fastmath-switched-off-in-julia-0-7-dev-deliberately/11898)

<div class="topic-metadata">

**Author:** [@Seif\_Shebl](https://discourse.julialang.org/u/Seif_Shebl)\
**Replies:** 7\
**Last updated:** [June 24, 2018, 9:41am UTC](https://discourse.julialang.org/t/fastmath-switched-off-in-julia-0-7-dev-deliberately/11898 "2018-06-24T09:41:03Z")

</div>

I noticed that the @fastmath macro is no longer effective in version 0.7-Dev. Has it been switched off deliberately, or something wrong with my installation is preventing it from taking off? I tested on both Windows 10 a…

---

## [A type question](https://discourse.julialang.org/t/a-type-question/11899)

<div class="topic-metadata">

**Author:** [@e3c6](https://discourse.julialang.org/u/e3c6)\
**Replies:** 1\
**Last updated:** [June 23, 2018, 10:33pm UTC](https://discourse.julialang.org/t/a-type-question/11899 "2018-06-23T22:33:12Z")

</div>

Why this is false? Dict{NTuple{4, Int}, Float64}() isa (Dict{NTuple{L, \<:Integer}, \<:Real} where L) # returns false Interestingly, this is true: Dict{NTuple{4, Int}, Float64}() isa (Dict{NTuple{L, T}, \<:Real} where {L…

---

## [Websocket client in Julia (how to)](https://discourse.julialang.org/t/websocket-client-in-julia-how-to/3788)

<div class="topic-metadata">

**Author:** [@hgeorgako](https://discourse.julialang.org/u/hgeorgako)\
**Replies:** 9\
**Last updated:** [June 23, 2018, 10:25am UTC](https://discourse.julialang.org/t/websocket-client-in-julia-how-to/3788 "2018-06-23T10:25:48Z")

</div>

Websockets.jl seems to be a server side implementation only. On the client side, I’ve found the following DandelionWebSockets.jl. Is this the recommended way to listen and work with web-sockets in Julia? If not, what are…

---

## [Error with NullableArrays when trying to install or remove packages or run Pkg.update()](https://discourse.julialang.org/t/error-with-nullablearrays-when-trying-to-install-or-remove-packages-or-run-pkg-update/11225)

<div class="topic-metadata">

**Author:** [@mrapo](https://discourse.julialang.org/u/mrapo)\
**Replies:** 7\
**Last updated:** [June 23, 2018, 5:15am UTC](https://discourse.julialang.org/t/error-with-nullablearrays-when-trying-to-install-or-remove-packages-or-run-pkg-update/11225 "2018-06-23T05:15:23Z")

</div>

When I try to add or remove any packages or even run Pkg.update() with Julia, I get the following error: ERROR: resolve is unable to satisfy package requirements. The problem was detected when trying to find a feasible…

---

## [Findmax on ranges](https://discourse.julialang.org/t/findmax-on-ranges/11870)

<div class="topic-metadata">

**Author:** [@DNF](https://discourse.julialang.org/u/DNF)\
**Replies:** 3\
**Last updated:** [June 22, 2018, 3:28pm UTC](https://discourse.julialang.org/t/findmax-on-ranges/11870 "2018-06-22T15:28:45Z")

</div>

This had me surprised: julia\> @btime findmax($(2:10^9)) 1.191 s (0 allocations: 0 bytes) (1000000000, 999999999) julia\> @btime maximum($(2:10^9)) 4.441 ns (0 allocations: 0 bytes) 1000000000 Apparently, findmax / a…

---

## [Accumulated memory usage in optimize() Optim package](https://discourse.julialang.org/t/accumulated-memory-usage-in-optimize-optim-package/5706)

<div class="topic-metadata">

**Author:** [@WenlongGong](https://discourse.julialang.org/u/WenlongGong)\
**Replies:** 1\
**Last updated:** [June 21, 2018, 9:06pm UTC](https://discourse.julialang.org/t/accumulated-memory-usage-in-optimize-optim-package/5706 "2018-06-21T21:06:43Z")

</div>

I use the optimize() function with default method like below, to estimate some parameters. optimize(nloglikT,g\_tol = 1e-8, init, iterations=500, store\_trace=true, show\_trace=true, show\_every=1) It consumed accumulating…

---

## [SYSTEM: show(lasterr) caused an error](https://discourse.julialang.org/t/system-show-lasterr-caused-an-error/11856)

<div class="topic-metadata">

**Author:** [@cortner](https://discourse.julialang.org/u/cortner)\
**Replies:** 8\
**Last updated:** [June 21, 2018, 6:58pm UTC](https://discourse.julialang.org/t/system-show-lasterr-caused-an-error/11856 "2018-06-21T18:58:18Z")

</div>

This is an error that I’ve seen for the first time a few weeks ago - it only occurred when I imported a package I’m developing from within the Atom editor. And it was difficult to reproduce. If I change code in some rand…

---

## [Fluent APIs in Julia](https://discourse.julialang.org/t/fluent-apis-in-julia/11161)

<div class="topic-metadata">

**Author:** [@essenciary](https://discourse.julialang.org/u/essenciary)\
**Replies:** 12\
**Last updated:** [June 21, 2018, 4:12pm UTC](https://discourse.julialang.org/t/fluent-apis-in-julia/11161 "2018-06-21T16:12:26Z")

</div>

I’m working on a SQL query builder module and I’d like to provide a fluent API using method chaining (Fluent interface - Wikipedia). My goal was something like: select(...).from(...).where(...).limit(...). After a bit …

---

## [Macro definition throws MethodError that doesn't make sense](https://discourse.julialang.org/t/macro-definition-throws-methoderror-that-doesnt-make-sense/11858)

<div class="topic-metadata">

**Author:** [@pearlzli](https://discourse.julialang.org/u/pearlzli)\
**Replies:** 4\
**Last updated:** [June 21, 2018, 3:35pm UTC](https://discourse.julialang.org/t/macro-definition-throws-methoderror-that-doesnt-make-sense/11858 "2018-06-21T15:35:02Z")

</div>

Hello, I’m trying to define a macro which will evaluate an expression using @sync @parallel if the Boolean argument passed in is true. When I define this macro in the REPL, it seems to work fine, but it throws a mysteri…

---

## [Package succesfully registered but not present in https://pkg.julialang.org/](https://discourse.julialang.org/t/package-succesfully-registered-but-not-present-in-https-pkg-julialang-org/6649)

<div class="topic-metadata">

**Author:** [@sylvaticus](https://discourse.julialang.org/u/sylvaticus)\
**Replies:** 11\
**Last updated:** [June 21, 2018, 11:50am UTC](https://discourse.julialang.org/t/package-succesfully-registered-but-not-present-in-https-pkg-julialang-org/6649 "2018-06-21T11:50:36Z")

</div>

Hello, some weeks ago I registered MultiDimEquations, a small package to write multi-dimensional equations in Julia using an easy and compact syntax . Registration has been successful, but it is still not listed on http…

---

## [How to make a demonized process](https://discourse.julialang.org/t/how-to-make-a-demonized-process/11614)

<div class="topic-metadata">

**Author:** [@haides](https://discourse.julialang.org/u/haides)\
**Replies:** 3\
**Last updated:** [June 21, 2018, 11:28am UTC](https://discourse.julialang.org/t/how-to-make-a-demonized-process/11614 "2018-06-21T11:28:54Z")

</div>

Hello everyone. I am quite new to julia and it’s multiprocessing model. What I need is a way to make a demonized process in julia. In python I have done it through double fork but I have not been able to find a way for…

---

## [Type instability with SubArray on custom Array type](https://discourse.julialang.org/t/type-instability-with-subarray-on-custom-array-type/11775)

<div class="topic-metadata">

**Author:** [@jinliangwei](https://discourse.julialang.org/u/jinliangwei)\
**Replies:** 2\
**Last updated:** [June 20, 2018, 5:44pm UTC](https://discourse.julialang.org/t/type-instability-with-subarray-on-custom-array-type/11775 "2018-06-20T17:44:16Z")

</div>

I have a program that requires me to use my own array type. However, my own array definition seems to cause a type instability problem, leaving lots of performance on the table (potentially 2~3x improvements). The issue…

---

## [Erroneous automatic promotion](https://discourse.julialang.org/t/erroneous-automatic-promotion/11822)

<div class="topic-metadata">

**Author:** [@FMeirinhos](https://discourse.julialang.org/u/FMeirinhos)\
**Replies:** 1\
**Last updated:** [June 20, 2018, 1:41pm UTC](https://discourse.julialang.org/t/erroneous-automatic-promotion/11822 "2018-06-20T13:41:15Z")

</div>

While composing a minimal working example for #11821, I came across the following: struct foo{T} \<: T where {T\<:Real} bar::T end seems to not throw a convert MethodError for declarations such as julia\> foo(3.0 + 1…

---

## [Inverse fma](https://discourse.julialang.org/t/inverse-fma/11812)

<div class="topic-metadata">

**Author:** [@Tamas\_Papp](https://discourse.julialang.org/u/Tamas_Papp)\
**Replies:** 4\
**Last updated:** [June 20, 2018, 11:25am UTC](https://discourse.julialang.org/t/inverse-fma/11812 "2018-06-20T11:25:18Z")

</div>

Is there an inverse of fma, in the sense of y = fma(x, A, B) x2 = ???(y, A, B) # this is what I am looking for x ≈ x2 # "reasonably" close I found that sometimes either (y - B)/A or fma(y, inv(A), -B/A) is…

---

## [Anonymous function as argument cant be optimized](https://discourse.julialang.org/t/anonymous-function-as-argument-cant-be-optimized/11814)

<div class="topic-metadata">

**Author:** [@stakaz](https://discourse.julialang.org/u/stakaz)\
**Replies:** 5\
**Last updated:** [June 20, 2018, 10:23am UTC](https://discourse.julialang.org/t/anonymous-function-as-argument-cant-be-optimized/11814 "2018-06-20T10:23:05Z")

</div>

Hello, I have the following (simplified) code where I wonder why the second algorithm runs slower: nn(x, bc) = x \> 2 ? x : bc(x) function algorithm\_direct(Λ::AbstractArray{T, N}, bc::Function = x-\>x, bond\_condition = (…

---

## [Sequence of replace in text files](https://discourse.julialang.org/t/sequence-of-replace-in-text-files/11802)

<div class="topic-metadata">

**Author:** [@tlienart](https://discourse.julialang.org/u/tlienart)\
**Replies:** 0\
**Last updated:** [June 20, 2018, 12:40am UTC](https://discourse.julialang.org/t/sequence-of-replace-in-text-files/11802 "2018-06-20T00:40:04Z")

</div>

I’m writing a “converter” for files which takes a file (say f1) and outputs a file (say g1) after having done a bunch of replace. Each file is likely to be reasonably short (\< 1mb) but there are potentially many files to…

---

## [How to convert an IOBuffer to an IOStream?](https://discourse.julialang.org/t/how-to-convert-an-iobuffer-to-an-iostream/11801)

<div class="topic-metadata">

**Author:** [@nabla](https://discourse.julialang.org/u/nabla)\
**Replies:** 0\
**Last updated:** [June 19, 2018, 10:18pm UTC](https://discourse.julialang.org/t/how-to-convert-an-iobuffer-to-an-iostream/11801 "2018-06-19T22:18:38Z")

</div>

Hi there, I would like to feed a string as standard input to a command; a silly example is that I want to print “b” as follows: julia\> input = IOBuffer("a") julia\> open(\`tr a b\`, "r", input) do output print(readlin…

---

## [How to access the parameter list of a super type](https://discourse.julialang.org/t/how-to-access-the-parameter-list-of-a-super-type/11739)

<div class="topic-metadata">

**Author:** [@Qiyamah](https://discourse.julialang.org/u/Qiyamah)\
**Replies:** 7\
**Last updated:** [June 19, 2018, 9:14pm UTC](https://discourse.julialang.org/t/how-to-access-the-parameter-list-of-a-super-type/11739 "2018-06-19T21:14:51Z")

</div>

Hi fellows, Here is what i want to do: abstract type DEF{super\<:Tuple} struct X \<: DEF{Tuple{F,Y,Z{Int}}} end I want to access the supertype of X which is DEF and specifically what types are in the tuple Tuple{F,…

---

## [Do syntax for macro invocations no longer works (v0.7)](https://discourse.julialang.org/t/do-syntax-for-macro-invocations-no-longer-works-v0-7/11792)

<div class="topic-metadata">

**Author:** [@essenciary](https://discourse.julialang.org/u/essenciary)\
**Replies:** 3\
**Last updated:** [June 19, 2018, 8:46pm UTC](https://discourse.julialang.org/t/do-syntax-for-macro-invocations-no-longer-works-v0-7/11792 "2018-06-19T20:46:29Z")

</div>

I have this macro definition: julia\> macro foreach(f, arr) quote isempty($arr) && return "" mapreduce(\*, $arr) do \_s $f(\_s) end end end @foreach (ma…

---

## [How to handle system-dependent dependencies with \`Pkg3\`?](https://discourse.julialang.org/t/how-to-handle-system-dependent-dependencies-with-pkg3/11796)

<div class="topic-metadata">

**Author:** [@00vareladavid](https://discourse.julialang.org/u/00vareladavid)\
**Replies:** 1\
**Last updated:** [June 19, 2018, 8:38pm UTC](https://discourse.julialang.org/t/how-to-handle-system-dependent-dependencies-with-pkg3/11796 "2018-06-19T20:38:36Z")

</div>

The old REQUIRE format uses something like @osx homebrew. What is the equivalent for Pkg3? I looked at latest docs and latest Pkg.jl docs but I couldn’t find anything.

---

## [SharedArray - not updated](https://discourse.julialang.org/t/sharedarray-not-updated/11795)

<div class="topic-metadata">

**Author:** [@pedro.rafae](https://discourse.julialang.org/u/pedro.rafae)\
**Replies:** 0\
**Last updated:** [June 19, 2018, 8:20pm UTC](https://discourse.julialang.org/t/sharedarray-not-updated/11795 "2018-06-19T20:20:01Z")

</div>

I have a problem with the ekwg\_monte\_carlo\_bias function. In this function there are SharedArray which are not updated. Any suggestion? Note: The function works as expected by replacing @parallel for i in 1:m with for i…

---

## [How does julia parse julia syntax and make it lisp?](https://discourse.julialang.org/t/how-does-julia-parse-julia-syntax-and-make-it-lisp/11791)

<div class="topic-metadata">

**Author:** [@Qiyamah](https://discourse.julialang.org/u/Qiyamah)\
**Replies:** 1\
**Last updated:** [June 19, 2018, 8:21pm UTC](https://discourse.julialang.org/t/how-does-julia-parse-julia-syntax-and-make-it-lisp/11791 "2018-06-19T20:21:04Z")

</div>

Hi fellows, I was wondering, where does julia parse the julia code and make it into pico lisp? Thanks

---

## [Float comparison error](https://discourse.julialang.org/t/float-comparison-error/11779)

<div class="topic-metadata">

**Author:** [@jayce\_ram](https://discourse.julialang.org/u/jayce_ram)\
**Replies:** 4\
**Last updated:** [June 19, 2018, 3:18pm UTC](https://discourse.julialang.org/t/float-comparison-error/11779 "2018-06-19T15:18:31Z")

</div>

Inside a project I have been working in, I detected an anomaly when I make comparisons between two floats numbers. I have reproduced this error in a very basic loop just to show the problem in a simple way : clearconsol…

---

## [Very sparse matrix but still out-of-memory?](https://discourse.julialang.org/t/very-sparse-matrix-but-still-out-of-memory/11766)

<div class="topic-metadata">

**Author:** [@MaximilianJHuber](https://discourse.julialang.org/u/MaximilianJHuber)\
**Replies:** 6\
**Last updated:** [June 19, 2018, 11:57am UTC](https://discourse.julialang.org/t/very-sparse-matrix-but-still-out-of-memory/11766 "2018-06-19T11:57:38Z")

</div>

On Julia 0.6.3, a very sparse matrix with 1000 rows and 100000 columns with only 10 entries is multiplied by a vector column-wise: sparse(rand(1:1000, 10), rand(1:100000, 10), rand(10), 1000, 100000) .\* rand(1000, 1) T…

---

## [Problem to install StatPlots](https://discourse.julialang.org/t/problem-to-install-statplots/11651)

<div class="topic-metadata">

**Author:** [@jayce\_ram](https://discourse.julialang.org/u/jayce_ram)\
**Replies:** 5\
**Last updated:** [June 19, 2018, 10:32am UTC](https://discourse.julialang.org/t/problem-to-install-statplots/11651 "2018-06-19T10:32:20Z")

</div>

I have tried to install the pack StatPlots and I got the following error: julia\> Pkg.add("StatPlots") WARNING: PyCall is fixed at 1.16.1 conflicting with top-level requirement: \[1.15.0,1.15.0+) ERROR: fixed packages int…

---

## [ManifoldLearning methods broken?](https://discourse.julialang.org/t/manifoldlearning-methods-broken/9058)

<div class="topic-metadata">

**Author:** [@burfel](https://discourse.julialang.org/u/burfel)\
**Replies:** 6\
**Last updated:** [June 19, 2018, 8:20am UTC](https://discourse.julialang.org/t/manifoldlearning-methods-broken/9058 "2018-06-19T08:20:29Z")

</div>

I am trying to get the methods in the ManifoldLearning.jl package running and get the following error messages… I use the sample code from the documentation. # Isomap Y\_Isomap = transform(Isomap,data\_array; k=12,d=2) M…

---

## [How to install SQLite package with Julia 0.7?](https://discourse.julialang.org/t/how-to-install-sqlite-package-with-julia-0-7/11771)

<div class="topic-metadata">

**Author:** [@00vareladavid](https://discourse.julialang.org/u/00vareladavid)\
**Replies:** 6\
**Last updated:** [June 19, 2018, 4:29am UTC](https://discourse.julialang.org/t/how-to-install-sqlite-package-with-julia-0-7/11771 "2018-06-19T04:29:30Z")

</div>

I’m trying Julia 0.7 and things have been running smoothly so far, but I can’t get SQLite.jl to install. I run add SQLite (after hitting \] in the REPL) and I get no errors. Then I run using SQLite and the precompilatio…

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

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