vrok / have

The Have Programming Language
http://havelang.org
BSD 2-Clause "Simplified" License
272 stars 11 forks source link

go Expressions #14

Closed robgssp closed 7 years ago

robgssp commented 7 years ago

It would be nice if you could write code of the form var x = go DoWork(y, z). This would be the more concise equivalent to

var x = make(chan T)
go func(y1, z1) {
    x <- DoWork(y1, z1)
} (y, z)

This eliminates some of the boilerplate of spinning off a background computation when you actually do care about its return value.

robgssp commented 7 years ago

On second thought this is probably a bad idea since it would silently drop panics. Promises as a library feature would be better (and now that generics are available, implementable).