# \#argument

**URL:** https://discourse.julialang.org/tag/argument/243.md

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

---

## [Test.jl seems to have problems catching ArgParse.jl's exceptions](https://discourse.julialang.org/t/test-jl-seems-to-have-problems-catching-argparse-jls-exceptions/131795)

<div class="topic-metadata">

**Author:** [@pkalaczynski](https://discourse.julialang.org/u/pkalaczynski)\
**Replies:** 6\
**Last updated:** [September 4, 2025, 3:35pm UTC](https://discourse.julialang.org/t/test-jl-seems-to-have-problems-catching-argparse-jls-exceptions/131795 "2025-09-04T15:35:36Z")

</div>

Hi, I’ve been implementing unit tests for my project, and generally I’m very happy with Test.jl, however I stumbled across a weird problem when trying to do tests for argument parsing. I handle it using ArgParse.jl and …

---

## [Naming convention for functions when an argument is optionally mutated](https://discourse.julialang.org/t/naming-convention-for-functions-when-an-argument-is-optionally-mutated/125180)

<div class="topic-metadata">

**Author:** [@frankwswang](https://discourse.julialang.org/u/frankwswang)\
**Replies:** 5\
**Last updated:** [January 25, 2025, 4:20am UTC](https://discourse.julialang.org/t/naming-convention-for-functions-when-an-argument-is-optionally-mutated/125180 "2025-01-25T04:20:35Z")

</div>

I have a function f with a signature: f(x, y, cache::Union{T1, T2}) where cache will be mutated (modified) when it’s of type T1 and not mutated when it’s of type T2. The type of cache is determined by the combinations …

---

## [Running A Julia Script Through SLURM](https://discourse.julialang.org/t/running-a-julia-script-through-slurm/123268)

<div class="topic-metadata">

**Author:** [@leespen1](https://discourse.julialang.org/u/leespen1)\
**Replies:** 4\
**Last updated:** [December 15, 2024, 3:26am UTC](https://discourse.julialang.org/t/running-a-julia-script-through-slurm/123268 "2024-12-15T03:26:46Z")

</div>

I have a julia script that run a physics simulation. The physics simulation takes around 8 hours, and I want to run it with many random initial conditions, so I planned to run the script multiple times using a SLURM job …

---

## [Types and arguments](https://discourse.julialang.org/t/types-and-arguments/121612)

<div class="topic-metadata">

**Author:** [@martin\_sanchez](https://discourse.julialang.org/u/martin_sanchez)\
**Replies:** 4\
**Last updated:** [October 22, 2024, 10:59pm UTC](https://discourse.julialang.org/t/types-and-arguments/121612 "2024-10-22T22:59:40Z")

</div>

I have a doubt. Sorry if is very obvious. First: is the type specification used as a cast? For example, if f receives a real number as argument, is a=2 f(a::Real) doing a type conversion? And a second doubt is: can’t …

---

## [Defining a function that modifies its argument in place defines a new function instead](https://discourse.julialang.org/t/defining-a-function-that-modifies-its-argument-in-place-defines-a-new-function-instead/109462)

<div class="topic-metadata">

**Author:** [@keynescoefen](https://discourse.julialang.org/u/keynescoefen)\
**Replies:** 2\
**Last updated:** [January 30, 2024, 5:42pm UTC](https://discourse.julialang.org/t/defining-a-function-that-modifies-its-argument-in-place-defines-a-new-function-instead/109462 "2024-01-30T17:42:33Z")

</div>

Hello! I have the following function using SpecialFunctions function CDFFoldedNormal(x,μ,σ) #follow the example: https://en.wikipedia.org/wiki/Folded\_normal\_distribution #Note that the folded normal is NOT the h…

---

## [PackageCompiler.jl does not support ARGS (arguments)?](https://discourse.julialang.org/t/packagecompiler-jl-does-not-support-args-arguments/103513)

<div class="topic-metadata">

**Author:** [@Miroslav-Stimac](https://discourse.julialang.org/u/Miroslav-Stimac)\
**Replies:** 3\
**Last updated:** [September 5, 2023, 6:14am UTC](https://discourse.julialang.org/t/packagecompiler-jl-does-not-support-args-arguments/103513 "2023-09-05T06:14:21Z")

</div>

Hello, It seems that PackageCompiler does not work with ARGS. I tried several ways and none worked: CASE 1: In precompile\_app.jl: MyProgram.julia\_main(\["CHECK\_DATA\_1", "DEV"\]) In MyProgram.jl: module MyProgram a…

---

## [Package-Compiler stops compile process because of arguments missing](https://discourse.julialang.org/t/package-compiler-stops-compile-process-because-of-arguments-missing/102472)

<div class="topic-metadata">

**Author:** [@Miroslav-Stimac](https://discourse.julialang.org/u/Miroslav-Stimac)\
**Replies:** 0\
**Last updated:** [August 4, 2023, 7:51am UTC](https://discourse.julialang.org/t/package-compiler-stops-compile-process-because-of-arguments-missing/102472 "2023-08-04T07:51:16Z")

</div>

Hello, I developed a program that requires a few arguments and when the program starts, it checks whether the correct arguments were given and if not, then it raises an exception. For example: # Read the arguments give…

---

## [Why do Julia functions handle keyword arguments as \`Base.Pairs\` instead of \`NamedTuple\` or \`Dict\`?](https://discourse.julialang.org/t/why-do-julia-functions-handle-keyword-arguments-as-base-pairs-instead-of-namedtuple-or-dict/102263)

<div class="topic-metadata">

**Author:** [@singularitti](https://discourse.julialang.org/u/singularitti)\
**Replies:** 2\
**Last updated:** [July 30, 2023, 5:25am UTC](https://discourse.julialang.org/t/why-do-julia-functions-handle-keyword-arguments-as-base-pairs-instead-of-namedtuple-or-dict/102263 "2023-07-30T05:25:36Z")

</div>

In Python, where we use \*args and \*\*kwargs to handle an arbitrary number of positional and keyword arguments in a function. In Python, these positional arguments are gathered into a tuple, and keyword arguments are gathe…

---

## [PSA: Julia 1.9 Change in argument processing --](https://discourse.julialang.org/t/psa-julia-1-9-change-in-argument-processing/95253)

<div class="topic-metadata">

**Author:** [@mkitti](https://discourse.julialang.org/u/mkitti)\
**Replies:** 0\
**Last updated:** [February 27, 2023, 7:00am UTC](https://discourse.julialang.org/t/psa-julia-1-9-change-in-argument-processing/95253 "2023-02-27T07:00:13Z")

</div>

@MilesCranmer discovered a bug in pyjulia that only manifested in Julia 1.9 due to a correction in argument processing. Suppose we have a file printargs.jl with the following content. println(ARGS) If you placed a -- …

---

## [What is a good way to write methods that help the user not mix up input order?](https://discourse.julialang.org/t/what-is-a-good-way-to-write-methods-that-help-the-user-not-mix-up-input-order/94803)

<div class="topic-metadata">

**Author:** [@philip](https://discourse.julialang.org/u/philip)\
**Replies:** 7\
**Last updated:** [February 23, 2023, 4:04am UTC](https://discourse.julialang.org/t/what-is-a-good-way-to-write-methods-that-help-the-user-not-mix-up-input-order/94803 "2023-02-23T04:04:47Z")

</div>

I’ve often encountered issues similar to Keyword argument types - what's going on? - #11 by sijo . I like to write methods with keyword arguments because I find them harder to silently screw up calling than positional ar…

---

## [Concise call keyword arg with default by conditional](https://discourse.julialang.org/t/concise-call-keyword-arg-with-default-by-conditional/90716)

<div class="topic-metadata">

**Author:** [@taotree](https://discourse.julialang.org/u/taotree)\
**Replies:** 2\
**Last updated:** [November 23, 2022, 5:04pm UTC](https://discourse.julialang.org/t/concise-call-keyword-arg-with-default-by-conditional/90716 "2022-11-23T17:04:05Z")

</div>

I tried to show an example below. This might be a bit persnickety, but it seems like it would be nice to have a cleaner solution for this situation. I have function A with a keyword argument that specifies a default val…

---

## [How can I access struct fields](https://discourse.julialang.org/t/how-can-i-access-struct-fields/88259)

<div class="topic-metadata">

**Author:** [@ali1](https://discourse.julialang.org/u/ali1)\
**Replies:** 11\
**Last updated:** [October 5, 2022, 12:53pm UTC](https://discourse.julialang.org/t/how-can-i-access-struct-fields/88259 "2022-10-05T12:53:37Z")

</div>

Hello Everyone! I am new to Julia and I am trying to create a function that checks if it is possible to insert a request in between 2 reservations. First I want to check the (Time) interval between the reservations, and …

---

## [Given a function with only one method, how to determine the number of arguments that it accepts?](https://discourse.julialang.org/t/given-a-function-with-only-one-method-how-to-determine-the-number-of-arguments-that-it-accepts/88030)

<div class="topic-metadata">

**Author:** [@jishnub](https://discourse.julialang.org/u/jishnub)\
**Replies:** 2\
**Last updated:** [September 30, 2022, 10:59am UTC](https://discourse.julialang.org/t/given-a-function-with-only-one-method-how-to-determine-the-number-of-arguments-that-it-accepts/88030 "2022-09-30T10:59:55Z")

</div>

And would it be possible to determine this statically? An example of what I want julia\> f = x -\> x #5 (generic function with 1 method) julia\> applicable(f, 0) true julia\> applicable(f, 0, 0) false From this, I may d…

---

## [Best practices for dealing with functions taking multiple vector variables](https://discourse.julialang.org/t/best-practices-for-dealing-with-functions-taking-multiple-vector-variables/86759)

<div class="topic-metadata">

**Author:** [@samerb](https://discourse.julialang.org/u/samerb)\
**Replies:** 5\
**Last updated:** [September 4, 2022, 3:50pm UTC](https://discourse.julialang.org/t/best-practices-for-dealing-with-functions-taking-multiple-vector-variables/86759 "2022-09-04T15:50:31Z")

</div>

Sometimes I want to use a function like f(x,y,z,w), where x,y,z,w are themselves vectors of potentially different lengths. But sometimes when I call solvers (e.g. NLSolve, Optim, Implicit Differentiation, JuMP) or other …

---

## [Difference between allowrankdeficient and dropcollinear in lm function](https://discourse.julialang.org/t/difference-between-allowrankdeficient-and-dropcollinear-in-lm-function/86047)

<div class="topic-metadata">

**Author:** [@valperez](https://discourse.julialang.org/u/valperez)\
**Replies:** 2\
**Last updated:** [August 21, 2022, 6:44pm UTC](https://discourse.julialang.org/t/difference-between-allowrankdeficient-and-dropcollinear-in-lm-function/86047 "2022-08-21T18:44:04Z")

</div>

Hi there! I have a question regarding the documentation of the GLM package. I want to use the function lm(formula, data, allowrankdeficient=false; \[wts::AbstractVector\], dropcollinear::Bool=true) but I have a doubt…

---

## [Retrieve variable name inside function](https://discourse.julialang.org/t/retrieve-variable-name-inside-function/83753)

<div class="topic-metadata">

**Author:** [@ellocco](https://discourse.julialang.org/u/ellocco)\
**Replies:** 9\
**Last updated:** [July 5, 2022, 8:33am UTC](https://discourse.julialang.org/t/retrieve-variable-name-inside-function/83753 "2022-07-05T08:33:36Z")

</div>

Is it possible inside a function to retrieve the variable name of an argument to that function in form of a string? Here my example function to investigate the nature of variables during the degugging phase: function \_…

---

## [How to pass ARGS to multiple processes?](https://discourse.julialang.org/t/how-to-pass-args-to-multiple-processes/80075)

<div class="topic-metadata">

**Author:** [@JedPhillips](https://discourse.julialang.org/u/JedPhillips)\
**Replies:** 4\
**Last updated:** [April 26, 2022, 6:17pm UTC](https://discourse.julialang.org/t/how-to-pass-args-to-multiple-processes/80075 "2022-04-26T18:17:54Z")

</div>

I’m trying to pass command line arguments to a script that calls multiple processes, but I can’t seem to have the other processes access these arguments. Here’s a simple example: using Distributed addprocs(1) @everywher…

---

## [Methods of a function that has both optional positional argument and keyword argument](https://discourse.julialang.org/t/methods-of-a-function-that-has-both-optional-positional-argument-and-keyword-argument/78869)

<div class="topic-metadata">

**Author:** [@frankwswang](https://discourse.julialang.org/u/frankwswang)\
**Replies:** 6\
**Last updated:** [April 7, 2022, 1:45pm UTC](https://discourse.julialang.org/t/methods-of-a-function-that-has-both-optional-positional-argument-and-keyword-argument/78869 "2022-04-07T13:45:41Z")

</div>

I know keyword arguments don’t invoke multiple dispatch. So methods with the same positional arguments except keyword arguments can overload each other: julia\> f(a) = a f (generic function with 1 method) julia\> methods…

---

## [Specializing on keyword arguments](https://discourse.julialang.org/t/specializing-on-keyword-arguments/78263)

<div class="topic-metadata">

**Author:** [@etienne\_dg](https://discourse.julialang.org/u/etienne_dg)\
**Replies:** 7\
**Last updated:** [March 22, 2022, 2:44pm UTC](https://discourse.julialang.org/t/specializing-on-keyword-arguments/78263 "2022-03-22T14:44:37Z")

</div>

I have a function f(a; b=default\_b, c=default\_c), and want to implement a method f(a) = f(a, b=default\_b, c=c\_specialized\_for\_default\_b), which should override f when neither b and c are provided. If I implement it lik…

---

## [How to pass NamedTuples as arguments to a function?](https://discourse.julialang.org/t/how-to-pass-namedtuples-as-arguments-to-a-function/34911)

<div class="topic-metadata">

**Author:** [@Elmer\_Cusipuma](https://discourse.julialang.org/u/Elmer_Cusipuma)\
**Replies:** 4\
**Last updated:** [January 31, 2022, 5:47pm UTC](https://discourse.julialang.org/t/how-to-pass-namedtuples-as-arguments-to-a-function/34911 "2022-01-31T17:47:22Z")

</div>

I have the following function defined. f(a::Int64,r::Float64,q::Float64,p::Int64) = a + r + q + p t1 = (a=1,c=3,r=5.3) t2 = (d=3,q=6.2,p=8) How do I pass the namedtuples as function arguments? e.g. \_f(t1,t2) = f(a,r…

---

## [Returning Arrays from Functions - Recommended Approach?](https://discourse.julialang.org/t/returning-arrays-from-functions-recommended-approach/75448)

<div class="topic-metadata">

**Author:** [@TI36XPro](https://discourse.julialang.org/u/TI36XPro)\
**Replies:** 3\
**Last updated:** [January 30, 2022, 10:38pm UTC](https://discourse.julialang.org/t/returning-arrays-from-functions-recommended-approach/75448 "2022-01-30T22:38:03Z")

</div>

I have been working through an exercise of reviewing and re-reviewing some code I have that solves a one-dimensional system of coupled ODEs using finite differences (just as a toy problem to get better with Julia). I hav…

---

## [\[ANN\] ArgumentModes.jl - an implementation of set-of-symbols like type for function arguments](https://discourse.julialang.org/t/ann-argumentmodes-jl-an-implementation-of-set-of-symbols-like-type-for-function-arguments/71429)

<div class="topic-metadata">

**Author:** [@Icarus](https://discourse.julialang.org/u/Icarus)\
**Replies:** 0\
**Last updated:** [November 13, 2021, 1:10pm UTC](https://discourse.julialang.org/t/ann-argumentmodes-jl-an-implementation-of-set-of-symbols-like-type-for-function-arguments/71429 "2021-11-13T13:10:36Z")

</div>

I’d like to announce the package ArgumentModes.jl (also available in the registry) which provides type Mode for usage as a function argument type and in function calls. Conceptually it is similar to Val type, but working…

---

## [Extracting Default Arguments from Function Signature](https://discourse.julialang.org/t/extracting-default-arguments-from-function-signature/70112)

<div class="topic-metadata">

**Author:** [@anicusan](https://discourse.julialang.org/u/anicusan)\
**Replies:** 1\
**Last updated:** [October 22, 2021, 9:14am UTC](https://discourse.julialang.org/t/extracting-default-arguments-from-function-signature/70112 "2021-10-22T09:14:41Z")

</div>

Is there any way to extract the default values from a method’s signature? For example, say I define: # Function with two keyword arguments that have default values function f(x, y; kx = 3, ky = 4) end # Call function w…

---

## [Get the name of a function in the argument](https://discourse.julialang.org/t/get-the-name-of-a-function-in-the-argument/40027)

<div class="topic-metadata">

**Author:** [@janrpeters](https://discourse.julialang.org/u/janrpeters)\
**Replies:** 11\
**Last updated:** [September 9, 2021, 9:53am UTC](https://discourse.julialang.org/t/get-the-name-of-a-function-in-the-argument/40027 "2021-09-09T09:53:07Z")

</div>

I would like to have a function that returns the name of the function in the argument, e.g.: function give\_me\_my\_name(f::Function) return ??? (f); end such that give\_me\_my\_name(sin) returns sin as a string. How…

---

## [Avoiding memory allocation with function passed as argument](https://discourse.julialang.org/t/avoiding-memory-allocation-with-function-passed-as-argument/67494)

<div class="topic-metadata">

**Author:** [@Joris\_Pinkse](https://discourse.julialang.org/u/Joris_Pinkse)\
**Replies:** 14\
**Last updated:** [September 2, 2021, 3:19pm UTC](https://discourse.julialang.org/t/avoiding-memory-allocation-with-function-passed-as-argument/67494 "2021-09-02T15:19:56Z")

</div>

Consider the code at the bottom. The actual case is more complex, so something that does not depend on the definition of the function A would be appreciated. This gives the time and allocation numbers below. Presumabl…

---

## [Handling of package inter-dependency](https://discourse.julialang.org/t/handling-of-package-inter-dependency/64568)

<div class="topic-metadata">

**Author:** [@BambOoxX](https://discourse.julialang.org/u/BambOoxX)\
**Replies:** 37\
**Last updated:** [July 16, 2021, 4:00pm UTC](https://discourse.julialang.org/t/handling-of-package-inter-dependency/64568 "2021-07-16T16:00:13Z")

</div>

Introduction Hello. I am currently developing a software involving A GUI in C# / vb.net A computation kernel in julia To handle to communication business I am using Json.net for the C# part and the BSON package in jul…

---

## [Passing arguments to julia functions](https://discourse.julialang.org/t/passing-arguments-to-julia-functions/64335)

<div class="topic-metadata">

**Author:** [@BambOoxX](https://discourse.julialang.org/u/BambOoxX)\
**Replies:** 16\
**Last updated:** [July 14, 2021, 8:17am UTC](https://discourse.julialang.org/t/passing-arguments-to-julia-functions/64335 "2021-07-14T08:17:15Z")

</div>

Former Matlab user here, still discovering new things about type stability and multiple dispatch… Currently working on a private package involving mostly linear algebra, I tried to follow the philosophy of julia’s multi…

---

## [How to create a function that uses an object attribute if it exists](https://discourse.julialang.org/t/how-to-create-a-function-that-uses-an-object-attribute-if-it-exists/62972)

<div class="topic-metadata">

**Author:** [@lpratafe](https://discourse.julialang.org/u/lpratafe)\
**Replies:** 3\
**Last updated:** [June 16, 2021, 2:55am UTC](https://discourse.julialang.org/t/how-to-create-a-function-that-uses-an-object-attribute-if-it-exists/62972 "2021-06-16T02:55:31Z")

</div>

Hey everyone, I believe what I am trying to do is pretty simple, but I couldn’t figure it out by myself, and what I read from the documentation wasn’t very helpful. Also, I did search in the forum but couldn’t find exact…

---

## [\[Julia usage\] Passing "complex" arguments to a function with default values](https://discourse.julialang.org/t/julia-usage-passing-complex-arguments-to-a-function-with-default-values/60506)

<div class="topic-metadata">

**Author:** [@erwanlecarpentier](https://discourse.julialang.org/u/erwanlecarpentier)\
**Replies:** 5\
**Last updated:** [May 4, 2021, 2:51pm UTC](https://discourse.julialang.org/t/julia-usage-passing-complex-arguments-to-a-function-with-default-values/60506 "2021-05-04T14:51:17Z")

</div>

Hi! This is a quite general question on the correct way to pass arguments with default values in Julia. I am concerned about the facts that 1) my function’s signature could get quite unreadable if I have many arguments …

---

## [Multiple-choice (dropdown) arguments](https://discourse.julialang.org/t/multiple-choice-dropdown-arguments/58353)

<div class="topic-metadata">

**Author:** [@RainerHeintzmann](https://discourse.julialang.org/u/RainerHeintzmann)\
**Replies:** 10\
**Last updated:** [April 1, 2021, 2:46pm UTC](https://discourse.julialang.org/t/multiple-choice-dropdown-arguments/58353 "2021-04-01T14:46:56Z")

</div>

Writing code in julia, I often encounter the need for an argument which can assume a number of different choices. E.g. in IndexFunArrays many functions (e.g. rr(mysize; offset=CtrFT)) have the offset parameter which can …

[Next page](https://discourse.julialang.org/tag/argument/243.md?match_all_tags=true&page=1&tags%5B%5D=argument)
