[generics] Violates beauty ethos

93 views
Skip to first unread message

Oliver Smith

unread,
Aug 11, 2020, 2:29:04 PM8/11/20
to golang-nuts
I recognize the hefty constraints in introducing generics, but for me the most egregious part is the cognitive and visual overhead it introduces by pushing more and more stuff off-screen-right and the processing overhead of so many sequences of parens on the same line.

My key thought is "the same line".

Could I suggest, to convert an extension of the 'type' construct:

````go
    func divide(a, b int) (int, error) {
    if b == 0 {
        return 0, DivideByZero
    }
    return a/b
    }
```

becomes

```go
    type divide generic { type V, type D }
    func divide(a V, b D) (int, error) {
    ...
    }
```

and potentially the ability to be selective about types:

type divide generic { type V union { type int, type uint, type float }, type D }
func divide ...
Reply all
Reply to author
Forward
0 new messages