Hi Stephen, max(5,slice) has no sense by itself, I'm agree with you. But the issue is about max(5,*slice...*) which should accept the "unpacking" operation like the append function. I know there's a buildin type "Type" for append while the min/max functions use the Generic with the interface cmp.Ordered but from an "usage point of view", it doesn't seem "understandable".
Le lundi 20 janvier 2025 à 16:14:54 UTC+1, Stephen Illingworth a écrit : > What value do you think should be returned for "max(5, slice)" ? > > On Monday, 20 January 2025 at 15:00:04 UTC Benoît Marguerie wrote: > >> Hi, >> >> Even if the spec precises : >> > slice arguments are not permitted >> >> I wonder if there's any real technical reason to prohibit the use of the >> slice variadics during *min/max* buildin functions, when it's allowed >> with *append* (which creates inconsistent behavior between buildin >> functions)? >> >> Example: >> ``` >> func main() { >> slice := []int{0, 1, 2, 3, 4, 5, 6, 7} >> padding := []int{8, 9} >> >> slice = append(slice, padding...) >> forbidden := max(5, slice...) //Doesn't build due to this line.... >> >> fmt.Println(forbidden) >> } >> ``` >> -> https://go.dev/play/p/pWzf9WKgW3q >> >> -- 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/12193a1c-e322-4cd8-8033-efc8ab2bbeb0n%40googlegroups.com.