Hi fellow Gophers

I'd like to propose that we allow type casting between `[]T` and 
`[]U`, when the underlying types `T` and `U` are identical.

For example:

```
type Symbol byte

func Index(a, b []Symbol) int {
        return bytes.Index(a, b)
}
```

Currently, the above code does not compile with the error:

`cannot use a (variable of type []Symbol) as []byte value in argument to 
bytes.Index`

This proposal suggests to make this allowed since `Symbol` is exactly 
identical to `byte`.

I am aware this has been proposed before, but was turned down since real 
world needs at that time were minimal.
However, I now have a real need 
<https://github.com/fumin/nag/blob/master/nag.go#L774> in my code for this 
feature.
Alternatively, if this kind of slice type conversion is truly disallowed, 
can anyone suggest a better way of writing the above function that 
maintains its readability and performance?

Thanks

-- 
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 [email protected].
To view this discussion visit 
https://groups.google.com/d/msgid/golang-nuts/5bb6ca8a-9a69-4262-a2f5-c6fb109a40a4n%40googlegroups.com.

Reply via email to