# How to parameterize a producer?

**URL:** <https://discourse.julialang.org/t/how-to-parameterize-a-producer/7416>\
**Category:** General Usage\
**Created:** [November 30, 2017, 5:27pm UTC](https://discourse.julialang.org/t/how-to-parameterize-a-producer/7416 "2017-11-30T17:27:29Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![albertas-jn](https://avatars.discourse-cdn.com/v4/letter/a/f14d63/32.png) [@albertas-jn](https://discourse.julialang.org/u/albertas-jn)\
**Post date:** [November 30, 2017, 5:27pm UTC](https://discourse.julialang.org/t/how-to-parameterize-a-producer/7416/1 "2017-11-30T17:27:30Z")

</div>

The manual on Tasks (aka Coroutines) explains how to create a producer and use it with a Channel.  
[https://docs.julialang.org/en/latest/manual/control-flow/#man-tasks-1](https://docs.julialang.org/en/latest/manual/control-flow/#man-tasks-1)  
Then, it says “A common pattern is for the producer to be parameterized, in which case a partial function application is needed to create a 0 or 1 argument anonymous function.”. However, in the example that follows, it is not clear how to bind function `mytask(myarg)` with a Channel. Where does the Channel parameter in `mytask` go? How to use such a parameterized producer in a for loop?  
I’d appreciate any help!

---

<div class="post-metadata">

**Author:** ![albertas-jn](https://avatars.discourse-cdn.com/v4/letter/a/f14d63/32.png) [@albertas-jn](https://discourse.julialang.org/u/albertas-jn)\
**Post date:** [November 30, 2017, 8:37pm UTC](https://discourse.julialang.org/t/how-to-parameterize-a-producer/7416/2 "2017-11-30T20:37:15Z")

</div>

OK, I think I figured it out. The producer should be defined as `producer(c::Channel, myargs)` and the Channel should be created with `chnl = Channel(c-> producer(c, myargs));`  
I guess I got confused by `mytask(myarg)` definition in the example, but it probably only applies to Task objects.  
Perhaps the manual could use some clarification 🙂
