Re: [go-nuts] Generics syntax suggestion

2021-01-19 Thread 'Axel Wagner' via golang-nuts
On Tue, Jan 19, 2021 at 11:45 PM Kevin Chadwick  wrote:

> On January 19, 2021 9:13:55 PM UTC, Levieux Michel 
> wrote:
> >I think the question was: "given your proposal here, I can write func
> >(string | []byte in1, string | []byte in2) which enforces that in1 and
> >in2
> >must be either of type string or type []byte, but how do I tell the
> >compiler that in1 and in2 must be of the *same type* (whether it is
> >string
> >or []byte) ? "
> >
>
> You could always use a well placed &. That isn't the point. 
>

People (including me) do not understand your suggestion. They are asking
question in an attempt to change that. If you want your suggestion to
receive consideration, it would help if you could answer those questions.
Write down the actual proposed syntax.

Better yet would be to write down an actual description of how the syntax
would be defined could be parsed and what the semantics are, that are
ascribed to it.

Again, this is in your interest - if you want people to consider your
suggestion (or help you refine it into a workable solution), they first
need to understand it.


>
> --
> 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/BDDBF610-2D1C-4F8A-880B-AAB2ED321004%40gmail.com
> .
>

-- 
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/CAEkBMfEGGEz4gVs%3D7ZLrw-CK4CE4gfsQVCijXwgFZxjonKGPxQ%40mail.gmail.com.


Re: [go-nuts] Generics syntax suggestion

2021-01-19 Thread 'Dan Kortschak' via golang-nuts
On Tue, 2021-01-19 at 22:44 +, Kevin Chadwick wrote:
> On January
19, 2021 9:13:55 PM UTC, Levieux Michel <
> mlevieu...@gmail.com> wrote:
> > I think the question was: "given your proposal here, I can write
> >
func
> > (string | []byte in1, string | []byte in2) which enforces that
in1
> > and
> > in2
> > must be either of type string or type []byte, but
how do I tell the
> > compiler that in1 and in2 must be of the *same
type* (whether it is
> > string
> > or []byte) ? "
> > 
> 
> You could
always use a well placed &. That isn't the point. 

What? How does that help?


-- 
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/ca069c336bf0dd981b1a7ee1306d5f47e39f40df.camel%40kortschak.io.


Re: [go-nuts] Generics syntax suggestion

2021-01-19 Thread Kevin Chadwick


>>string
>>or []byte) ? "
>>
> 
>You could always use a well placed &. That isn't the point. 

Or perhaps group with {} like Darts optional parameters. Again though, not the 
point.

-- 
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/FE5449DD-8060-4845-9FFB-228D9AAB5FF3%40gmail.com.


Re: [go-nuts] Generics syntax suggestion

2021-01-19 Thread Kevin Chadwick
On January 19, 2021 9:13:55 PM UTC, Levieux Michel  wrote:
>I think the question was: "given your proposal here, I can write func
>(string | []byte in1, string | []byte in2) which enforces that in1 and
>in2
>must be either of type string or type []byte, but how do I tell the
>compiler that in1 and in2 must be of the *same type* (whether it is
>string
>or []byte) ? "
>
 
You could always use a well placed &. That isn't the point. 

-- 
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/BDDBF610-2D1C-4F8A-880B-AAB2ED321004%40gmail.com.


Re: [go-nuts] Generics syntax suggestion

2021-01-19 Thread 'Dan Kortschak' via golang-nuts
On Tue, 2021-01-19 at 21:09 +, Kevin Chadwick wrote:
> On January 19, 2021 8:22:01 PM UTC, 'Dan Kortschak' via golang-nuts <
> golang-nuts@googlegroups.com> wrote:
> > On Tue, 2021-01-19 at 20:01 +, Kevin Chadwick wrote:
> > > I was inquiring about the possibility of no identifiers or
> > > abstraction but simply like Gos non generic functions (possibly
> > > reversed if needed). Using type OR type.
> > > 
> > > func (String | []byte firstInput, myType | publicKey
> > > secondInput)   {
> > > 
> > >   firstInput[0]
> > >   firstInput[[]byte]
> > > }
> > 
> > 
> > How does this encode the desire that parameter types match?
> 
> These are the parameters. dynamic var firstInput must be a String or
> byte slice.

Yeah, that doesn't answer the question.

How do you make sure that types match where you have more than one
parameter where the types must match?

func find(s, pattern string | []byte) (string | []byte)

If find is looking for pattern in s and then returning it, how do you
indicate to the compiler that typeof(s) == typeof(pattern) and how do
you indicate what the return type is?


-- 
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/cf8b268b57abec5c45879dbcce70c80838206489.camel%40kortschak.io.


Re: [go-nuts] Generics syntax suggestion

2021-01-19 Thread Levieux Michel
I think the question was: "given your proposal here, I can write func
(string | []byte in1, string | []byte in2) which enforces that in1 and in2
must be either of type string or type []byte, but how do I tell the
compiler that in1 and in2 must be of the *same type* (whether it is string
or []byte) ? "

Le mar. 19 janv. 2021 à 22:09, Kevin Chadwick  a
écrit :

> On January 19, 2021 8:22:01 PM UTC, 'Dan Kortschak' via golang-nuts <
> golang-nuts@googlegroups.com> wrote:
> >On Tue, 2021-01-19 at 20:01 +, Kevin Chadwick wrote:
> >> I was inquiring about the possibility of no identifiers or
> >> abstraction but simply like Gos non generic functions (possibly
> >> reversed if needed). Using type OR type.
> >>
> >> func (String | []byte firstInput, myType | publicKey
> >> secondInput)   {
> >>
> >>   firstInput[0]
> >>   firstInput[[]byte]
> >> }
> >
> >
> >How does this encode the desire that parameter types match?
>
> These are the parameters. dynamic var firstInput must be a String or byte
> slice.
>
> --
> 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/F183269A-E743-4069-90C3-0357F5C6D36D%40gmail.com
> .
>

-- 
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/CAL4P9zzcf4qg6wYkeRX6v%2BhOEtQSvm2kJnQM0_Pc_xZyS%3D_AhA%40mail.gmail.com.


Re: [go-nuts] Generics syntax suggestion

2021-01-19 Thread Kevin Chadwick
On January 19, 2021 8:22:01 PM UTC, 'Dan Kortschak' via golang-nuts 
 wrote:
>On Tue, 2021-01-19 at 20:01 +, Kevin Chadwick wrote:
>> I was inquiring about the possibility of no identifiers or
>> abstraction but simply like Gos non generic functions (possibly
>> reversed if needed). Using type OR type.
>> 
>> func (String | []byte firstInput, myType | publicKey
>> secondInput)   {
>> 
>>   firstInput[0]
>>   firstInput[[]byte]
>> }
>
>
>How does this encode the desire that parameter types match?

These are the parameters. dynamic var firstInput must be a String or byte slice.

-- 
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/F183269A-E743-4069-90C3-0357F5C6D36D%40gmail.com.


Re: [go-nuts] Generics syntax suggestion

2021-01-19 Thread 'Dan Kortschak' via golang-nuts
On Tue, 2021-01-19 at 20:01 +, Kevin Chadwick wrote:
> I was inquiring about the possibility of no identifiers or
> abstraction but simply like Gos non generic functions (possibly
> reversed if needed). Using type OR type.
> 
> func (String | []byte firstInput, myType | publicKey
> secondInput)   {
> 
>   firstInput[0]
>   firstInput[[]byte]
> }


How does this encode the desire that parameter types match?


-- 
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/e8a2cd7d31c89f7aa3eced33f1ce9c43ef944dfe.camel%40kortschak.io.


Re: [go-nuts] Generics syntax suggestion

2021-01-19 Thread 'Axel Wagner' via golang-nuts
How would you express the equivalent of

func Min[T constraints.Ordered](a []T) T {
min := a[0]
for _, v := range a[1:] {
if v < min {
min = v
}
}
return min
}

using this syntax? More generally, it is probably useful to go through the
examples from the design draft

and check if they can be clearly expressed using your suggested syntax.

On Tue, Jan 19, 2021 at 9:01 PM Kevin Chadwick  wrote:

>
> >> Seems to me that most generics implementations use a capital letter
> >> abstracted type syntax that I hate.
> >>
> >
> >This is just a convention and not part of the syntax, which means it's
> >irrelevant to the discussion about the proposal. You can easily use
> >lowercase letters/identifiers:
> >https://go2goplay.golang.org/p/eWgJSLNTZw8
>
> I was inquiring about the possibility of no identifiers or abstraction but
> simply like Gos non generic functions (possibly reversed if needed). Using
> type OR type.
>
> func (String | []byte firstInput, myType | publicKey secondInput)   {
>
>   firstInput[0]
>   firstInput[[]byte]
> }
>
> --
> 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/17BEE437-A5BB-4152-8215-B3F27A7265C1%40gmail.com
> .
>

-- 
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/CAEkBMfEh0-BM3-QKXgDRDAn00Rw49mSg0vtwOG5omaPx9c%3DDjg%40mail.gmail.com.