# Allowing the object.method(args...) syntax as an alias for method(object, args ...)

**URL:** <https://discourse.julialang.org/t/allowing-the-object-method-args-syntax-as-an-alias-for-method-object-args/62051>\
**Category:** Internals & Design\
**Tags:** question, design\
**Created:** [May 29, 2021, 5:09pm UTC](https://discourse.julialang.org/t/allowing-the-object-method-args-syntax-as-an-alias-for-method-object-args/62051 "2021-05-29T17:09:54Z")\
**Posts on this page:** 1\
**Showing post:** 217

<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:** [October 27, 2022, 7:59pm UTC](https://discourse.julialang.org/t/allowing-the-object-method-args-syntax-as-an-alias-for-method-object-args/62051/217 "2022-10-27T19:59:45Z")

</div>

Looking at `Base.Fix1` and `Base.Fix2`, there’s a lot of overlap between [the proposed operators](https://discourse.julialang.org/t/allowing-the-object-method-args-syntax-as-an-alias-for-method-object-args/62051/206) and the internal fix functions. If `Fix1` were opened up to [accepting more than one argument](https://discourse.julialang.org/t/fix1-analogue-of-base-fix2/10161/2), it’d be completely equivalent to `/>`. And for two-argument functions, `\>` is equivalent to `Fix2`. In other words, the proposed operators `/>` and `\>` are simply the logical extension of `Fix1` and `Fix2`.

The only thing missing would be parametric types. Perhaps introduce parametric types `FixFirst` and `FixLast`, and then make `/>` and `\>` syntax sugar for them?

For example, in namedtuples.jl line 104 I see:

```julia
NamedTuple{names, T}(map(Fix1(getfield, nt), names))

```

with the proposed operators this could be written as

```julia
NamedTuple{names, T}(map(nt/>getfield, names))

```

and presumably, you’d see something like this:

```julia
julia> nt = (a=1, b=1.0);

julia> typeof(nt/>getfield)
Base.FixFirst{typeof(getfield), NamedTuple{(:a, :b), Tuple{Int64, Float64}}}

julia> nt/>getfield(:b)
1.0

```

similar for `\>` of course:

```julia
julia> arr = [1, 2, 3];

julia> typeof(arr\>map)
Base.FixLast{typeof(map), Vector{Int64}}

julia> arr\>map(x->x^2)
3-element Vector{Int64}:
 1
 4
 9

```

As mentioned, having a parametric type that embodies partial application

> [@Fix1 (analogue of Base.Fix2)](https://discourse.julialang.org/t/fix1-analogue-of-base-fix2/10161/4):
>
> exposes the components of what would be an otherwise opaque closure, and allows neat things like a `show` method for certain function/argument combinations

One can also conceive a `Base.Fix{n} where {n isa Int}` type… or for the truly deranged, `Base.Fix{k} where {k isa Symbol}` for currying into keyword arguments. I’m not sure what’s a good way to make a type that would cover underscore currying. 🤔

---

_[View the full topic](https://discourse.julialang.org/t/allowing-the-object-method-args-syntax-as-an-alias-for-method-object-args/62051)._
