Broadcasting for a new type & passing a value by ref

Let’s start with the interface:

https://docs.julialang.org/en/v1/manual/interfaces/#man-interfaces-broadcasting

From here, you can see “Methods to implement”:

  • Base.BroadcastStyle
  • Base.similar

So that is the absolute minimum you need. The former is just a trait with a type you define to allow for dispatching to your methods, the latter tells the broadcasting machinery how to allocate an object of your type (with given element type). In addition to the above, you’ll also want to define copyto! for your broadcast style for in-place broadcasting.

I’d recommend giving this talk a watch, it has an introduction to broadcasting a custom array in the second half: