# \[API Design\] Callable objects with side effect in Julia

**URL:** <https://discourse.julialang.org/t/api-design-callable-objects-with-side-effect-in-julia/15243>\
**Category:** Numerics\
**Tags:** development\
**Created:** [September 20, 2018, 6:13pm UTC](https://discourse.julialang.org/t/api-design-callable-objects-with-side-effect-in-julia/15243 "2018-09-20T18:13:42Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Roger-luo](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/roger-luo/32/3399_2.png) [@Roger-luo](https://discourse.julialang.org/u/Roger-luo)\
**Post date:** [September 20, 2018, 6:13pm UTC](https://discourse.julialang.org/t/api-design-callable-objects-with-side-effect-in-julia/15243/1 "2018-09-20T18:13:42Z")

</div>

In a recent package we developed ([https://github.com/QuantumBFS/Yao.jl](https://github.com/QuantumBFS/Yao.jl)) we represent quantum circuit as a tree (just think about operators compiled as a tree), which is called **block** in the packages.

It looks **natural and convenient** to use pipeline `|>` to compose (chain) a circuit with blocks, however, the blocks have side effect on registers, which you will not notice with `|>`.

So the problem is: **Should we use/overload `|>` for callable types that has side effect?** Or we should delete it at all. Since you cannot always name the instance with a `!` (which can be dangerous).

We had a quite long discussion around that, but still have no idea if there is a better way with this API. A related issue: [Remove `with` and pip interface for blocks · Issue #113 · QuantumBFS/Yao.jl · GitHub](https://github.com/QuantumBFS/Yao.jl/issues/113)
