Graham Fawcett Wrote:

> On Fri, 12 Nov 2010 18:15:15 -0500, Sean Kelly wrote:
> > 
> > To be honest, I haven't spent much time with Go because my cursory
> > exposure to the language hasn't shown it to solve the problems I
> > care about better than the languages I currently use. I think Go is
> > in the right ballpark with channels though, and the rest is
> > passable. I'm trying to withhold my opinion about the lack of
> > generics and such and evaluate the language based on what's there.
> 
> Since you brought up channels...
> 
> One thing I very much like about Go (and Haskell, etc.) that I don't
> think has a counterpart in Phobos is type-safe message passing. I like
> the flexibility of the current "mailbox" design. But I'd really like
> an alternative that could enforce type-safety on messages. I don't
> think per-thread mailboxes could accommodate this, but Channel objects
> could; e.g.:
> 
> struct Channel(T) { 
>     T receive() { ... }
>     void send(T val) { ... }
> }

It shouldn't be too difficult to wrap send/receive with such a design to 
provide type safety.  In fact, it's one reason I wanted to use the flexible 
model.  Of course, using channels would be a matter of convention, since both 
would be available.

> (I am guessing that tricks might have to be played to pass Channel
> objects around as pure values across threads, but I'm also guessing
> this is surmountable...)

It should be possible to pass shared classes as well.  If the Channel is 
non-shared then you'll have to do some casting in the implementation for 
send/receive to allow it though.

Reply via email to