# Array argument naming convention: upper case or lower case?

**URL:** https://discourse.julialang.org/t/array-argument-naming-convention-upper-case-or-lower-case/8320
**Category:** New to Julia
**Created:** [January 12, 2018, 2:51pm UTC](https://discourse.julialang.org/t/array-argument-naming-convention-upper-case-or-lower-case/8320 "2018-01-12T14:51:13Z")
**Posts on this page:** 7
**Page:** 1

<div class="post-metadata">

### Author: ![jandehaan](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jandehaan/32/6805_2.png) [@jandehaan](https://discourse.julialang.org/u/jandehaan)
#### Post date: [January 12, 2018, 2:51pm UTC](https://discourse.julialang.org/t/array-argument-naming-convention-upper-case-or-lower-case/8320/1 "2018-01-12T14:51:13Z")

</div>

What is the official Julia convention for naming array arguments?

> f(x::AbstractArray) # lower case? or  
> f(A::AbstractArray) # upper case / CamelCase?

I think the convention is lower case for argument names, CamelCase for type names. But in Julia Base I see many examples of both lower case and upper case array arguments. Just do methodswith(AbstractArray) to convince yourself.

---

<div class="post-metadata">

### Author: ![Tamas\_Papp](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tamas_papp/32/25949_2.png) [@Tamas\_Papp](https://discourse.julialang.org/u/Tamas_Papp)
#### Post date: [January 12, 2018, 3:58pm UTC](https://discourse.julialang.org/t/array-argument-naming-convention-upper-case-or-lower-case/8320/2 "2018-01-12T15:58:47Z")

</div>

Both exist in the wild. Use what you like.

Technically, upper case variable names do go against the style recommendations, but they are single-letter so they are fine visually.

---

<div class="post-metadata">

### Author: ![kristoffer.carlsson](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/kristoffer.carlsson/32/22_2.png) [@kristoffer.carlsson](https://discourse.julialang.org/u/kristoffer.carlsson)
#### Post date: [January 12, 2018, 4:07pm UTC](https://discourse.julialang.org/t/array-argument-naming-convention-upper-case-or-lower-case/8320/3 "2018-01-12T16:07:43Z")

</div>

Usually matrices are written with uppercase like `A` because it is a common notation in the literature. Unless there is a good reason, use lowercase.

---

<div class="post-metadata">

### Author: ![jandehaan](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jandehaan/32/6805_2.png) [@jandehaan](https://discourse.julialang.org/u/jandehaan)
#### Post date: [January 12, 2018, 5:32pm UTC](https://discourse.julialang.org/t/array-argument-naming-convention-upper-case-or-lower-case/8320/4 "2018-01-12T17:32:32Z")

</div>

Thank you. I’ll go with that.

---

<div class="post-metadata">

### Author: ![bramtayl](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/bramtayl/32/3614_2.png) [@bramtayl](https://discourse.julialang.org/u/bramtayl)
#### Post date: [January 12, 2018, 6:28pm UTC](https://discourse.julialang.org/t/array-argument-naming-convention-upper-case-or-lower-case/8320/5 "2018-01-12T18:28:15Z")

</div>

The way I name arguments is the lowercase first letter of the type (if it is specificied and unique) or a descriptive name otherwise.

---

<div class="post-metadata">

### Author: ![ScottPJones](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/scottpjones/32/146_2.png) [@ScottPJones](https://discourse.julialang.org/u/ScottPJones)
#### Post date: [January 12, 2018, 8:52pm UTC](https://discourse.julialang.org/t/array-argument-naming-convention-upper-case-or-lower-case/8320/6 "2018-01-12T20:52:28Z")

</div>

> [@bramtayl](#):
>
> The way I name arguments is the lowercase first letter of the type

I’ve seen that a lot, but I dislike single character (esp. lowercase) variable names (although IMO `i`, `j`, `k` are fine for loop variables, as long as they stay strictly in the loop!).  
If you are trying to search for that variable in a file, it’s a pain. It’s not so hard with uppercase ones, because there are usually a lot fewer uppercase characters in a file, and I’ve become used to the convention of using `T` and `S` for type variables in Julia.

So instead of `s` for a string, `c` for a character, `l` for length, I tend to use 3 letter abbreviations, such as `str`, `chr`, `len`. Short enough the code doesn’t become unwieldy, just long enough to be more mnemonic and easier to find.

---

<div class="post-metadata">

### Author: ![bramtayl](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/bramtayl/32/3614_2.png) [@bramtayl](https://discourse.julialang.org/u/bramtayl)
#### Post date: [January 12, 2018, 10:22pm UTC](https://discourse.julialang.org/t/array-argument-naming-convention-upper-case-or-lower-case/8320/7 "2018-01-12T22:22:56Z")

</div>

In general I avoid any and all abbreviations. The reason I make exceptions for abbreviations from the type signature is that you can check to see what the variable stands for in the type signature itself.
