> On Jan 14, 2025, at 8:06 PM, Ian Lance Taylor <i...@golang.org> wrote: > > On Tue, Jan 14, 2025 at 4:19 PM Mike Schinkel <m...@newclarity.net> wrote: >> >> Given this I am now pondering why it would not be possible and acceptable it >> Go could allow relaxing of the need to type cast — on an opt-in basis — when >> going from a derived time to its base type? > > There is a related discussion in https://go.dev/issue/71183.
Thank you. OTOH, it appears Rob Pike has shut it down. Do you think his objections apply to my scalar type use-case? AFAICT they do not. Reading through https://go.dev/issue/71183 <https://go.dev/issue/71183> it appears the entire discussion is really related to slices and not so much about scalar types for which I do not think any of the objections mentioned would actually apply for the use-case I asked about. What I asked about would not cause a value to have two different types, it would just automatically "down" cast on assignment. Also I am not suggesting something like `float64` => `float32`, only for automatic down-casting of a type to a type it is derived from. Given that, it seems maybe I need to create my own proposal to ensure the type relaxing for non-slices does not get thrown out with the legitimate objections for doing the same for slices? > it's worth noting that you can already in part do what you want, by > using generics. > > func ToLower[S ~string](s S) S { ... } BTW, not really. That wouldn't give me what I really want, and would also not work for methods on types. What I REALLY want is to be able to call the standard library funcs that work on strings without having to typecast back to string (small wins, ya know.) Being able to do the same with my own funcs is only a secondary want. :-) -Mike P.S. If I instead asked that all funcs in the standard library accepting strings be converted to use that generic signature, I assume that would be a non-starter for performance reasons, right? -- 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+unsubscr...@googlegroups.com. To view this discussion visit https://groups.google.com/d/msgid/golang-nuts/475FA1ED-859F-4090-A4E6-E1C4B0A0F144%40newclarity.net.