Git Product home page Git Product logo

Comments (2)

streadway avatar streadway commented on July 17, 2024

A send only chan communicates the intent better, but makes it impossible to return the user supplied parameter in this API as it's not possible to cast directional channels to the other side. The idea with returning the caller's param is to make it clear at the call site that the chan is only valid when having registered with NotifyReturn and reduce one intermediate variable.

go processReturn(channel.NotifyReturn(make(chan Return, 1)))

Alternatively, accepting a send only channel does make the intent clearer, though the code longer with even more stutter var string_ string = strings.NewString().

returns := make(chan Return, 1)
channel.NotifyReturn(returns)
go processReturn(returns)

For strictness sake, removing the return value and accepting a directional channel could be better but I'm not certain how much value that'd give as the call-site would need a bidirectional channel to be useful.

Do you have a concrete example where an API with a directional channel would resolve an ambiguous usage for the caller?

from amqp.

streadway avatar streadway commented on July 17, 2024

Feel free to reopen if you have a compelling case on the call site to change the API.

from amqp.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.