Well, I don't have a 10 values example :-)
I just have this function, with 4 and a half return values:
// ReadTOSI is the same as Read, but it also indicates if the data
comes
// from an expedited TPDU, and if it is the end of a
TSDU.
func (c *TOSIConn) ReadTOSI(b []byte) (n int, err error, expedited, end
bool) {
the half is the buffer b, since it is both an input and an output. :-)
I was thinking that, since "n", "expedited", and "end" are all information
about the data returned in the buffer b, it would be more correct to pack
them inside a struct, like this:
type ReadInfo struct {
N int
Expedited, End bool
}
so that I have
func (c *TOSIConn) ReadTOSI(b []byte) (ReadInfo, err error) {
...maybe this can be the guideline about return values.
Regards,
Daniele
Il giorno domenica 26 maggio 2013 09:45:30 UTC+2, Jan Mercl ha scritto:
On Sun, May 26, 2013 at 9:38 AM, <pala.d...@gmail.com <javascript:>>
wrote:
what is an "acceptable" number of return values from a
function? Is it ok to have a function with 10 return values? Any
guideline?
42.
Okay, now seriously. Never seen any Go code using 10 return values.
Not sure if I've seen 5 return values. I'd estimate that up to 3, to
maybe 4 return values are just common. Above that I'd guess there's
some better way how to design the code. However, it's definitely
specific to a real code piece. One would have to first see the 10
return values monster to be able to give it a fair judgement ;-)
-j
--
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+unsubscribe@googlegroups.com.
For more options, visit
https://groups.google.com/groups/opt_out.