# LazyCall, again, sorry

**URL:** https://discourse.julialang.org/t/lazycall-again-sorry/8629
**Category:** Internals & Design
**Created:** [January 26, 2018, 8:53pm UTC](https://discourse.julialang.org/t/lazycall-again-sorry/8629 "2018-01-26T20:53:48Z")
**Posts on this page:** 6
**Page:** 1

<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 26, 2018, 8:53pm UTC](https://discourse.julialang.org/t/lazycall-again-sorry/8629/1 "2018-01-26T20:53:48Z")

</div>

It seems like the only way out of this pickle is to either mark containers you want to iterate (or scalars you don’t want to iterate). Anyways, here’s a proposal:

A lazy call object contains both a function and its arguments. For example,

```julia
LazyCall((a, b) -> a + b + 1, (A, B))

```

There is special syntax for making a lazy call.

`.( ~A + ~B)` is syntactic sugar for the above

You can call a function on a LazyCall, also with special syntax:

```julia
broadcast.( ~A + ~B + 1)

```

You could just as easily do:

```julia
filter.( ~A > 1)

```

Sorry for possibly derailing the thread. I just though I’d mention that an abstraction I’ve been working on for a long time could unequivocally sort out this conflict.

Here is another idea: ~ alone could signify an anonymous function, so

```julia
.( ~ + 1)

```

goes to

```julia
x - x + 1

```

so that

```julia
A |>
    .( ~ + 1)

```

could be a syntax for chaining

---

<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 26, 2018, 8:55pm UTC](https://discourse.julialang.org/t/lazycall-again-sorry/8629/2 "2018-01-26T20:55:50Z")

</div>

Not sure how to deal with functions like `broadcast!` in this proposal

---

<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 26, 2018, 9:04pm UTC](https://discourse.julialang.org/t/lazycall-again-sorry/8629/3 "2018-01-26T21:04:46Z")

</div>

Maybe

```julia
.( ~A = ~B + ~C + 1)

```

Goes to

```julia
LazyEquation( (b, c) -> b + c + 1, A, (B, C) )

```

???

---

<div class="post-metadata">

### Author: ![mbauman](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mbauman/32/31082_2.png) [@mbauman](https://discourse.julialang.org/u/mbauman)
#### Post date: [January 26, 2018, 10:50pm UTC](https://discourse.julialang.org/t/lazycall-again-sorry/8629/4 "2018-01-26T22:50:49Z")

</div>

Are you “marking” the objects to be treated as containers with a `~`? Instead of always assuming everything is a scalar unless specially marked, it’s easier to go the other way since that requires no special syntax: `(1,) .+ A .* (3,)`.

It might also be worth pointing out that I’m actively working on getting a “lazy” broadcast representation into 1.0: [https://github.com/JuliaLang/julia/pull/25377](https://github.com/JuliaLang/julia/pull/25377). You won’t typically see or work with it, but it’s what will enable extensible fusion.

---

<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 26, 2018, 11:22pm UTC](https://discourse.julialang.org/t/lazycall-again-sorry/8629/5 "2018-01-26T23:22:38Z")

</div>

I guess `(1,) .+ A .* (3,)` could work too. You are missing out on the ability to choose other verbs. I’m not sure if it’s more terse or not.

---

<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 26, 2018, 11:26pm UTC](https://discourse.julialang.org/t/lazycall-again-sorry/8629/6 "2018-01-26T23:26:06Z")

</div>

#25377 looks really cool btw
