# General Usage

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

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

**Page:** 252

---

## ["Compiling" DSL code to Reduce Indirection](https://discourse.julialang.org/t/compiling-dsl-code-to-reduce-indirection/103516)

<div class="topic-metadata">

**Author:** [@Ian\_L](https://discourse.julialang.org/u/Ian_L)\
**Replies:** 0\
**Last updated:** [September 4, 2023, 5:43pm UTC](https://discourse.julialang.org/t/compiling-dsl-code-to-reduce-indirection/103516 "2023-09-04T17:43:56Z")

</div>

Hello, In my quest to learn more about how to write DSLs in Julia, I’ve reach a point in the design and would like feedback and suggestions. For reference, the DSL is based of the SPPL language for symbolic exact infere…

---

## [MethodError: ADgradient(::Val{:ForwardDiff}, ::LogDensityFunction{DynamicPPL.TypedVarInfo](https://discourse.julialang.org/t/methoderror-adgradient-val-forwarddiff-logdensityfunction-dynamicppl-typedvarinfo/103509)

<div class="topic-metadata">

**Author:** [@99dB](https://discourse.julialang.org/u/99dB)\
**Replies:** 4\
**Last updated:** [September 4, 2023, 3:12pm UTC](https://discourse.julialang.org/t/methoderror-adgradient-val-forwarddiff-logdensityfunction-dynamicppl-typedvarinfo/103509 "2023-09-04T15:12:25Z")

</div>

Hello all, When sampling a Turing problem involving an ode I got, the following error message: MethodError: ADgradient(::Val{:ForwardDiff}, ::LogDensityFunction{DynamicPPL.TypedVarInfo Closest candidates are: ADgrad…

---

## [Check if a function has a docstring](https://discourse.julialang.org/t/check-if-a-function-has-a-docstring/103489)

<div class="topic-metadata">

**Author:** [@jar1](https://discourse.julialang.org/u/jar1)\
**Replies:** 8\
**Last updated:** [September 4, 2023, 2:01pm UTC](https://discourse.julialang.org/t/check-if-a-function-has-a-docstring/103489 "2023-09-04T14:01:35Z")

</div>

How can I check programmatically if a function has a docstring?

---

## [Declaration of variables](https://discourse.julialang.org/t/declaration-of-variables/103508)

<div class="topic-metadata">

**Author:** [@Alois](https://discourse.julialang.org/u/Alois)\
**Replies:** 2\
**Last updated:** [September 4, 2023, 1:42pm UTC](https://discourse.julialang.org/t/declaration-of-variables/103508 "2023-09-04T13:42:00Z")

</div>

How is a variable declared as a simple Float64, say, without initializing it? Something like A= Array{Float64, 0}(undef), which works for vectors.

---

## [Using \`eval\` inside \`quote\`](https://discourse.julialang.org/t/using-eval-inside-quote/103505)

<div class="topic-metadata">

**Author:** [@pat-alt](https://discourse.julialang.org/u/pat-alt)\
**Replies:** 2\
**Last updated:** [September 4, 2023, 1:33pm UTC](https://discourse.julialang.org/t/using-eval-inside-quote/103505 "2023-09-04T13:33:47Z")

</div>

I’ve recently added a new feature to CounterfactualExplanations.jl that adds support for multi-processing through MPI. On the user-end, this is handled through a simple macro: ces = @with\_parallelizer parallelizer begin…

---

## [AWS S3 upload a file](https://discourse.julialang.org/t/aws-s3-upload-a-file/103503)

<div class="topic-metadata">

**Author:** [@Wikunia](https://discourse.julialang.org/u/Wikunia)\
**Replies:** 0\
**Last updated:** [September 4, 2023, 10:59am UTC](https://discourse.julialang.org/t/aws-s3-upload-a-file/103503 "2023-09-04T10:59:54Z")

</div>

Is there a way to easily upload a file to S3 or does one always have to create an IOBuffer read the file and upload the content that way. If that is the case is there any general way of doing this which works on text dat…

---

## [How to test all sub-packages from the root package?](https://discourse.julialang.org/t/how-to-test-all-sub-packages-from-the-root-package/103498)

<div class="topic-metadata">

**Author:** [@thinnerichs](https://discourse.julialang.org/u/thinnerichs)\
**Replies:** 0\
**Last updated:** [September 4, 2023, 9:16am UTC](https://discourse.julialang.org/t/how-to-test-all-sub-packages-from-the-root-package/103498 "2023-09-04T09:16:55Z")

</div>

Hello, We are currently developing a package with multiple sub-packages, all registered. I would like to jointly test all sub-packages when running the tests of the main package. However, I cannot find a neat way of do…

---

## [What callbacks/hooks exist in Base/stdlibs](https://discourse.julialang.org/t/what-callbacks-hooks-exist-in-base-stdlibs/103476)

<div class="topic-metadata">

**Author:** [@oxinabox](https://discourse.julialang.org/u/oxinabox)\
**Replies:** 4\
**Last updated:** [September 3, 2023, 5:35pm UTC](https://discourse.julialang.org/t/what-callbacks-hooks-exist-in-base-stdlibs/103476 "2023-09-03T17:35:42Z")

</div>

What hook exist in Base/Core/stdlibs? By hooks I mean places you can register an arbitrary function to run whenever something occurs. Ones I am aware of out of hand: finalizer(f, x) runs when object x has no program-…

---

## [How do I get the current variable value within a macro?](https://discourse.julialang.org/t/how-do-i-get-the-current-variable-value-within-a-macro/103487)

<div class="topic-metadata">

**Author:** [@Eben60](https://discourse.julialang.org/u/Eben60)\
**Replies:** 1\
**Last updated:** [September 3, 2023, 4:55pm UTC](https://discourse.julialang.org/t/how-do-i-get-the-current-variable-value-within-a-macro/103487 "2023-09-03T16:55:09Z")

</div>

macro getvar(x) println(x) return nothing end x = 1 @getvar x getvar sees x as a symbol and prints out “x” as expected. Now, let’s assume I need the x value for some further logic within the macro (not within…

---

## [Extreme memory usage in nested loop](https://discourse.julialang.org/t/extreme-memory-usage-in-nested-loop/103471)

<div class="topic-metadata">

**Author:** [@daviyan5](https://discourse.julialang.org/u/daviyan5)\
**Replies:** 8\
**Last updated:** [September 3, 2023, 1:05pm UTC](https://discourse.julialang.org/t/extreme-memory-usage-in-nested-loop/103471 "2023-09-03T13:05:41Z")

</div>

I need to conduct extensive memory and performance testing on a memory-intensive function that creates mutable structs, temporary arrays, and more, even though most of the variables are type-defined. Running a single ins…

---

## [Eager finalization insertion location question](https://discourse.julialang.org/t/eager-finalization-insertion-location-question/103477)

<div class="topic-metadata">

**Author:** [@Zentrik](https://discourse.julialang.org/u/Zentrik)\
**Replies:** 1\
**Last updated:** [September 3, 2023, 6:56am UTC](https://discourse.julialang.org/t/eager-finalization-insertion-location-question/103477 "2023-09-03T06:56:54Z")

</div>

If I modify the example given here https://github.com/JuliaLang/julia/pull/46651#issuecomment-1253471390 to const FINALIZATION\_COUNT = Ref(0) init\_finalization\_count!() = FINALIZATION\_COUNT\[\] = 0 get\_finalization\_count(…

---

## [Gram Schmidit python to julia](https://discourse.julialang.org/t/gram-schmidit-python-to-julia/103472)

<div class="topic-metadata">

**Author:** [@jcbritobr](https://discourse.julialang.org/u/jcbritobr)\
**Replies:** 10\
**Last updated:** [September 3, 2023, 1:46am UTC](https://discourse.julialang.org/t/gram-schmidit-python-to-julia/103472 "2023-09-03T01:46:58Z")

</div>

Hello, good evening, I’m having troubles to port an algorithm(Gram Schmidit for qr decompoosition) from python to julia. My results are going to infinity in Orthogonal Q matrix. May someone help? # create the matrix …

---

## [Custom nonlinear curve fitting package?](https://discourse.julialang.org/t/custom-nonlinear-curve-fitting-package/103468)

<div class="topic-metadata">

**Author:** [@PeX](https://discourse.julialang.org/u/PeX)\
**Replies:** 1\
**Last updated:** [September 2, 2023, 10:31pm UTC](https://discourse.julialang.org/t/custom-nonlinear-curve-fitting-package/103468 "2023-09-02T22:31:34Z")

</div>

Hi all! I have a dataset that I want to fit a function to in the form of: y = a x^4 + b x^3 + c x^2 + dx + e + f sin(gx + h) I was trying to use LsqFit.jl , but the results are not great (unless I guess the parameters…

---

## [Ceiling division](https://discourse.julialang.org/t/ceiling-division/103467)

<div class="topic-metadata">

**Author:** [@jar1](https://discourse.julialang.org/u/jar1)\
**Replies:** 1\
**Last updated:** [September 2, 2023, 7:57pm UTC](https://discourse.julialang.org/t/ceiling-division/103467 "2023-09-02T19:57:19Z")

</div>

x ÷ k is faster than floor(Int, x/k). Is there an ceiling division function that rounds up instead of down, equivalent to but faster than ceil(Int, x/k)? julia\> f(x) = floor(Int, x/4) f (generic function with 1 method) …

---

## [How to disable precompile statements while building Julia?](https://discourse.julialang.org/t/how-to-disable-precompile-statements-while-building-julia/103461)

<div class="topic-metadata">

**Author:** [@jishnub](https://discourse.julialang.org/u/jishnub)\
**Replies:** 2\
**Last updated:** [September 2, 2023, 12:15pm UTC](https://discourse.julialang.org/t/how-to-disable-precompile-statements-while-building-julia/103461 "2023-09-02T12:15:24Z")

</div>

I have added a Make.user with the content $ cat Make.user JULIA\_PRECOMPILE ?= 0 but when I build Julia (using make), I find Collecting and executing precompile statements └ Collect (Basic: ✓ 871, REPL 39/39: ✓ 1862) =\>…

---

## [Concrete class' type method not found error](https://discourse.julialang.org/t/concrete-class-type-method-not-found-error/103432)

<div class="topic-metadata">

**Author:** [@bryaan](https://discourse.julialang.org/u/bryaan)\
**Replies:** 6\
**Last updated:** [September 2, 2023, 11:36am UTC](https://discourse.julialang.org/t/concrete-class-type-method-not-found-error/103432 "2023-09-02T11:36:11Z")

</div>

How do I create a method in a supertype MyModel that uses a datetime method defined on child type? module M2 module M1 export MyModel abstract type MyModel end Base.isless(x::MyModel, y::…

---

## [Julia does not start on ARM64v8 | exec /usr/local/julia/bin/julia: exec format error](https://discourse.julialang.org/t/julia-does-not-start-on-arm64v8-exec-usr-local-julia-bin-julia-exec-format-error/97793)

<div class="topic-metadata">

**Author:** [@schlichtanders](https://discourse.julialang.org/u/schlichtanders)\
**Replies:** 6\
**Last updated:** [September 2, 2023, 10:17am UTC](https://discourse.julialang.org/t/julia-does-not-start-on-arm64v8-exec-usr-local-julia-bin-julia-exec-format-error/97793 "2023-09-02T10:17:58Z")

</div>

Hi there, I am using julia\_pod to run Julia on kubernetes. Everything works on local minikube, but when switching to my freshly created kubernetes on ARM, I get the following error log: exec /usr/local/julia/bin/julia: …

---

## [Effect of \`JULIA\_DEFINE\_FAST\_TLS\` and how to handle in shared library or Fortran](https://discourse.julialang.org/t/effect-of-julia-define-fast-tls-and-how-to-handle-in-shared-library-or-fortran/101114)

<div class="topic-metadata">

**Author:** [@sloede](https://discourse.julialang.org/u/sloede)\
**Replies:** 1\
**Last updated:** [September 2, 2023, 4:59am UTC](https://discourse.julialang.org/t/effect-of-julia-define-fast-tls-and-how-to-handle-in-shared-library-or-fortran/101114 "2023-09-02T04:59:53Z")

</div>

According to Embedding Julia · The Julia Language, one should define JULIA\_DEFINE\_FAST\_TLS in any program that embeds calls to Julia. The only documentation for this I could find is the attached inline comment (line brea…

---

## [What if we have one type recipe for the x-axis and one for the y-axis?](https://discourse.julialang.org/t/what-if-we-have-one-type-recipe-for-the-x-axis-and-one-for-the-y-axis/93563)

<div class="topic-metadata">

**Author:** [@singularitti](https://discourse.julialang.org/u/singularitti)\
**Replies:** 1\
**Last updated:** [August 31, 2023, 9:26pm UTC](https://discourse.julialang.org/t/what-if-we-have-one-type-recipe-for-the-x-axis-and-one-for-the-y-axis/93563 "2023-08-31T21:26:17Z")

</div>

If we define a type recipe for MyWrapper which is the independent variable (x) and one type recipe for MyOtherWrapper which is the dependent variable (y). It seems that the plot attributes defined in MyWrapper are prefer…

---

## [Change behavior of function based on program state?](https://discourse.julialang.org/t/change-behavior-of-function-based-on-program-state/103452)

<div class="topic-metadata">

**Author:** [@frylock](https://discourse.julialang.org/u/frylock)\
**Replies:** 5\
**Last updated:** [September 1, 2023, 8:51pm UTC](https://discourse.julialang.org/t/change-behavior-of-function-based-on-program-state/103452 "2023-09-01T20:51:26Z")

</div>

I’m reading a binary file that stores a UInt16 that tells me if the rest of the section of the file is little-endian or big-endian. If the result of the read is 0x4d4d, it is little endian, and if it is 0x4949 it is big-…

---

## [Memory leak in allocation-intensive multi-threaded code](https://discourse.julialang.org/t/memory-leak-in-allocation-intensive-multi-threaded-code/103105)

<div class="topic-metadata">

**Author:** [@Jad\_Zeitouni](https://discourse.julialang.org/u/Jad_Zeitouni)\
**Replies:** 8\
**Last updated:** [September 1, 2023, 6:02pm UTC](https://discourse.julialang.org/t/memory-leak-in-allocation-intensive-multi-threaded-code/103105 "2023-09-01T18:02:51Z")

</div>

I’m trying to run multiple threads to construct a random matrix that satisfies some constraints. The goal is to have them run in parallel, and when one task finds the matrix return it and stop running tasks. However, I …

---

## [Is multiple dispatch possible for an enumerated type?](https://discourse.julialang.org/t/is-multiple-dispatch-possible-for-an-enumerated-type/103420)

<div class="topic-metadata">

**Author:** [@andrey2185](https://discourse.julialang.org/u/andrey2185)\
**Replies:** 3\
**Last updated:** [September 1, 2023, 3:17pm UTC](https://discourse.julialang.org/t/is-multiple-dispatch-possible-for-an-enumerated-type/103420 "2023-09-01T15:17:18Z")

</div>

Hello, is multiple dispatch possible for an enumerated type ? my version: @enum Foo M=1 N=2 Bar(x) = Bar(Val(x)) Bar(::Val{M}) = 111 Bar(::Val{N}) = 222

---

## [Type Stable Iteration over Static Parameters](https://discourse.julialang.org/t/type-stable-iteration-over-static-parameters/103380)

<div class="topic-metadata">

**Author:** [@bmit](https://discourse.julialang.org/u/bmit)\
**Replies:** 5\
**Last updated:** [September 1, 2023, 2:48pm UTC](https://discourse.julialang.org/t/type-stable-iteration-over-static-parameters/103380 "2023-09-01T14:48:35Z")

</div>

I have a use case where I need to iterate over a set of static parameters. I’m not sure how to do that in a type stable way. A MWE is below: function foo(::Val{N}) where N n = 0 for i in 1:N n += sum(ntu…

---

## [Accessing an artifact from a doctest](https://discourse.julialang.org/t/accessing-an-artifact-from-a-doctest/88392)

<div class="topic-metadata">

**Author:** [@mroavi](https://discourse.julialang.org/u/mroavi)\
**Replies:** 3\
**Last updated:** [September 1, 2023, 12:40pm UTC](https://discourse.julialang.org/t/accessing-an-artifact-from-a-doctest/88392 "2023-09-01T12:40:35Z")

</div>

I’m using Documenter.doctest(MyPackage; manual=false) inside runtests.jl to run the doctests in my package (as explained here). In one of the doctests, I need to access an artifact. e.g. artifact"myartifact" . I’m gettin…

---

## [Unable to access value in dict via known keys](https://discourse.julialang.org/t/unable-to-access-value-in-dict-via-known-keys/103434)

<div class="topic-metadata">

**Author:** [@this\_josh](https://discourse.julialang.org/u/this_josh)\
**Replies:** 6\
**Last updated:** [September 1, 2023, 9:35am UTC](https://discourse.julialang.org/t/unable-to-access-value-in-dict-via-known-keys/103434 "2023-09-01T09:35:15Z")

</div>

I have a loop which Starts with a vector input Computes a value based on vector Stores the value in a dict with the vector as the key Randomly removes a value from the vector and replaces it with another from a distrib…

---

## [Any reason to prefer \`::Type{T}\` over \`T::Type\`?](https://discourse.julialang.org/t/any-reason-to-prefer-type-t-over-t-type/103400)

<div class="topic-metadata">

**Author:** [@mwallerb](https://discourse.julialang.org/u/mwallerb)\
**Replies:** 4\
**Last updated:** [September 1, 2023, 5:56am UTC](https://discourse.julialang.org/t/any-reason-to-prefer-type-t-over-t-type/103400 "2023-09-01T05:56:24Z")

</div>

Suppose you have a function which takes a type as argument, say for example convert function. If you want to constrain this type, idiomatic Julia seems to be the following: convert(::Type{T}, x::Foo) where {T \<: Integer…

---

## [Allocations when indexing (Abstract)Arrays with large dimension](https://discourse.julialang.org/t/allocations-when-indexing-abstract-arrays-with-large-dimension/103383)

<div class="topic-metadata">

**Author:** [@spionkaese](https://discourse.julialang.org/u/spionkaese)\
**Replies:** 6\
**Last updated:** [August 31, 2023, 9:49pm UTC](https://discourse.julialang.org/t/allocations-when-indexing-abstract-arrays-with-large-dimension/103383 "2023-08-31T21:49:30Z")

</div>

I’ve been working with tensors based on AbstractArrays (see https://gist.github.com/AlexanderNenninger/461f37315e45071a8c91b18d73901431 ) that map Base.getindex(A, i...) to a function call A.f(i). While the individual i…

---

## [Get user to input path, with tab completion](https://discourse.julialang.org/t/get-user-to-input-path-with-tab-completion/103399)

<div class="topic-metadata">

**Author:** [@user664303](https://discourse.julialang.org/u/user664303)\
**Replies:** 13\
**Last updated:** [August 31, 2023, 9:47pm UTC](https://discourse.julialang.org/t/get-user-to-input-path-with-tab-completion/103399 "2023-08-31T21:47:06Z")

</div>

At the Julia REPL, I can start to enter a path, and get tab completion. Is there a way to get the same thing, when interactively asking for user input from a program? Currently I use readline(), but tab completion doesn’…

---

## [Non-allocating leaf iterator over simple tree](https://discourse.julialang.org/t/non-allocating-leaf-iterator-over-simple-tree/103425)

<div class="topic-metadata">

**Author:** [@jules](https://discourse.julialang.org/u/jules)\
**Replies:** 0\
**Last updated:** [August 31, 2023, 8:30pm UTC](https://discourse.julialang.org/t/non-allocating-leaf-iterator-over-simple-tree/103425 "2023-08-31T20:30:59Z")

</div>

I have a tree made from a node type like this struct Node children::Vector{Node} end For the life of me, I cannot figure out how to write a non-allocating iterator over the leaves of that tree. I tried with genera…

---

## [Short Names for Keyword Arguments](https://discourse.julialang.org/t/short-names-for-keyword-arguments/103407)

<div class="topic-metadata">

**Author:** [@TI36XPro](https://discourse.julialang.org/u/TI36XPro)\
**Replies:** 3\
**Last updated:** [August 31, 2023, 3:31pm UTC](https://discourse.julialang.org/t/short-names-for-keyword-arguments/103407 "2023-08-31T15:31:11Z")

</div>

Can I alias keyword arguments for brevity? For example, in MATLAB I can do the following x = linspace(0, 1); y = x.^2; lw = "linewidth" close all plot(x, y, lw=2) There is a similar thing in python’s matplotlib where…

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

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