- Martin
The language provides statement blocks, for loops,
and struct types, which cover all the possible meanings
of "pass multiple values" that I can think of.
Did you have something else in mind?
Russ
Can you not send structs down a channel?
--
Dr Rich Wareham
var c chan (int, os.Error)
then:
c<- 42, nil
or
val, err := <-c
- Martin
If you want to send multiple values through a channel, you need to
create a new struct type and send that
type s struct {
i int
err os.Error
}
c <- s{ i: 1, err: nil }
Cheers
Dave
Though it's possible to send a struct, it feels like idiomatic GO supports sending multiple values. A function can return multiple values, even though the same argument could have been made that a function does not need to support returning multiple values (ie just package them in a struct).I think Martin is asking if GO could be extended to allow channels support this same idiomatic mode which is currently supported for return values of functions.
Let me disagree. I think what OP is asking is more similar to support for multiple values in an array/slice item. That is done using a struct or a pointer to a struct or by an interface valued item, not by some 'var a [](int, string); a[i] = 42, "foo";'.In other words: -1