# Partial Application brackets without underscores

**URL:** <https://discourse.julialang.org/t/partial-application-brackets-without-underscores/90565>\
**Category:** Internals & Design\
**Tags:** proposal, currying, partial-evaluation\
**Created:** [November 21, 2022, 12:18am UTC](https://discourse.julialang.org/t/partial-application-brackets-without-underscores/90565 "2022-11-21T00:18:08Z")\
**Posts on this page:** 1\
**Showing post:** 4

<div class="post-metadata">

**Author:** ![uniment](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/uniment/32/24532_2.png) [@uniment](https://discourse.julialang.org/u/uniment)\
**Post date:** [November 21, 2022, 6:29am UTC](https://discourse.julialang.org/t/partial-application-brackets-without-underscores/90565/4 "2022-11-21T06:29:53Z")

</div>

That’s really neat, that `x.[i]` and `x.{i}` are unclaimed syntax! (and they parse!)

![HeheheLaughGIF](https://global.discourse-cdn.com/julialang/original/3X/6/0/60c414fa9b8c66904dbbcf5d42dc72b4c6a1770e.gif)

If you want to play around with your ideas a bit, using my demo code for the `Fix` partial applicator, you can do this:

**Function Currying with `[]`**

```julia
julia> f(a...) = a
f (generic function with 1 method)

julia> Base.getindex(f::Union{Function, Fix}, i) = FixFirst(f, i)

julia> f[:a][:b][:c]
f(:a, _..., )(:b, _..., )(:c, _..., )

julia> f[:a][:b][:c](1, 2, 3)
(:a, :b, :c, 1, 2, 3)

```

**Setting Arbitrary Indices with `Pair`s**

```julia
julia> f(a...) = a
f (generic function with 1 method)

julia> Base.getindex(f::Function, i::Pair{Int,<:Any}...) = 
           Fix{((x[1] for x ∈ i)...,), 0}(f, (x[2] for x ∈ i)...)

julia> f[2=>:a, 4=>:b, 6=>:c]
f(_, :a, _, :b, _, :c, _..., )

julia> f[2=>:a, 4=>:b, 6=>:c](1, 2, 3)
(1, :a, 2, :b, 3, :c)

```

Unfortunately, the generation of an applicator using `Pair`s is type-unstable. ~~You can use `Tuple`s instead though!~~

Do note, that the two methods are incompatible (i.e., you’d want to pick one or the other; to have both would cause inconsistent behavior).

Overall, given my rebuttal above, I don’t see this proposal as solving any problems in [my proposal](https://discourse.julialang.org/t/fixing-the-piping-chaining-partial-application-issue-rev-2/90408). Further, as currying is a subset of partial application, having syntax sugar only for partial application is probably good enough. Fixing arguments by position number, rather than visual position, I also don’t see as valuable enough to devote specialized syntax (and you can already do it fairly conveniently using my `Fix` constructor).

But who knows! I could be wrong. Maybe play around with it, and see if you can find examples where this is preferable?

---

_[View the full topic](https://discourse.julialang.org/t/partial-application-brackets-without-underscores/90565)._
