# Defining methods without binding variables

**URL:** <https://discourse.julialang.org/t/defining-methods-without-binding-variables/112485>\
**Category:** General Usage\
**Created:** [April 3, 2024, 8:28pm UTC](https://discourse.julialang.org/t/defining-methods-without-binding-variables/112485 "2024-04-03T20:28:50Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![awasserman](https://avatars.discourse-cdn.com/v4/letter/a/9de0a6/32.png) [@awasserman](https://discourse.julialang.org/u/awasserman)\
**Post date:** [April 3, 2024, 8:28pm UTC](https://discourse.julialang.org/t/defining-methods-without-binding-variables/112485/1 "2024-04-03T20:28:50Z")

</div>

I’ve seen many examples of Julia code where methods are defined without any variable name bindings. My usage of terminology my be inaccurate here, but for example:

```julia
eltype(::Type{<:AbstractArray{T}}) where {T} = T

```

As far as I can tell, this is equivalent to the following code.

```julia
eltype(S::Type{<:AbstractArray{T}}) where {T} = T

```

But since we don’t need to do any computation with the value `S`, we don’t need to bind the value to this symbol, so we can just use the first way of defining the method, so long as we have keep the reference to `T`, which we do care about in this context.

Is my understanding correct here?

Regardless, is this pattern documented anywhere? I’ve read through the [manual sections on methods](https://docs.julialang.org/en/v1/manual/methods/#Extracting-the-type-parameter-from-a-super-type), and the only places I’ve found this kind of method definition don’t explicitly call out this pattern.

---

<div class="post-metadata">

**Author:** ![stevengj](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/stevengj/32/71_2.png) [@stevengj](https://discourse.julialang.org/u/stevengj)\
**Post date:** [April 3, 2024, 8:34pm UTC](https://discourse.julialang.org/t/defining-methods-without-binding-variables/112485/2 "2024-04-03T20:34:20Z")

</div>

There is a stackoverflow post that calls these [anonymous arguments](https://stackoverflow.com/questions/57480771/anonymous-arguments-in-julia), which is a nice nomenclature.

But the same post was complaining 4 years ago that this was not explicitly documented — it seems like it should be added to the docs (unless there is a PR that I missed?). Would be an easy short PR for someone to write.

---

<div class="post-metadata">

**Author:** ![awasserman](https://avatars.discourse-cdn.com/v4/letter/a/9de0a6/32.png) [@awasserman](https://discourse.julialang.org/u/awasserman)\
**Post date:** [April 4, 2024, 4:48am UTC](https://discourse.julialang.org/t/defining-methods-without-binding-variables/112485/3 "2024-04-04T04:48:24Z")

</div>

Thanks for helping find a name for this!

> Would be an easy short PR for someone to write.

I’ll take a stab at this later this week.
