On Thu, Aug 25, 2016 at 2:08 PM, Nate Finch <nate.fi...@gmail.com> wrote:
> The type seems unnecessary.  It doesn't actually do anything different than
> a regular func().

You are correct that the behavior of the function doesn't differ, but
then again behavior isn't necessarily the point of the type system.
Having this be a type allows us to ensure that our methods only take
functions which we know cancel contexts (because they were returned by
one of the context methods or explicitly created by us for that
purpose). Also, If we're checking the underlying type of an empty
interface, checking if the underlying value is a CancelFunc is more
specific than just checking if it's any old func().

I think it's more about semantics and being explicit than it is about behavior.


> Also, how come WithCancel has named return values but WithDeadline and
> WithTimeout don't?

Glancing at the source there's no reason it needs to be. Probably just
because it was done this way originally, and it stuck around.

—Sam


-- 
Sam Whited
pub 4096R/54083AE104EA7AD3

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to