On Mon, Jun 29, 2020 at 7:28 PM Jake Montgomery <jake6...@gmail.com> wrote:

> I'm curious how you would propose rewriting:
> func Foo(type T comparable, B interface{})(a T, b B, c T) {
>

You could just annotate each distinct type on first appeareance:

func Foo(a T:type comparable, b B:type interface{}, c T) {



>
>
>
>
> On Friday, June 19, 2020 at 6:57:45 PM UTC-4, mit...@gmail.com wrote:
>>
>> Hello, Ian,
>>
>> Would it be possible to have a generic type annotation syntax like this:
>>
>> // Print prints the elements of any slice.// Print has a type parameter T, 
>> and has a single (non-type)// parameter s which is a slice of that type 
>> parameter.
>> func Print(type T)(s []T) {
>>
>>
>> ==>
>>
>> // Print prints the elements of any slice.// Print has a type parameter T, 
>> and has a single (non-type)// parameter s which is a slice of that type 
>> parameter.
>> func Print(s []T:type) {
>>
>>
>> This doesn't seem to clash with existing syntax, doesn't require a new
>> pair of parenthesis, marks T as a generic type (and can have added
>> constraint names right next to it, e.g: Print(s []T:type constraint)
>>
>> Or anything similar really, that keeps the generic type description
>> in-line with regular types, e.g. could be a special sigil added to a type
>> parameter as well (@T, $T, etc to mark it as generic, e.g.: Print(s []$T
>> constraint)
>>
>> haven't thought this through by any means, but it strikes me as a cleaner
>> option than a new set of parenthesis and duplication of the generic
>> parameter names.
>>
>> Does it make any sense? Don't recall seeing this in some other language...
>>
> --
> 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 on the web visit
> https://groups.google.com/d/msgid/golang-nuts/0fbc45cf-1fe0-4910-adc1-9a6c77422566o%40googlegroups.com
> <https://groups.google.com/d/msgid/golang-nuts/0fbc45cf-1fe0-4910-adc1-9a6c77422566o%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
>

-- 
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 on the web visit 
https://groups.google.com/d/msgid/golang-nuts/CAACdnTBj4rUMUBEBHhr%3Du12SkfJcj3RC2Afhw%3DHOXW1%2BRjLb8A%40mail.gmail.com.

Reply via email to