Re: [go-nuts] Is this a known problem?

2021-11-12 Thread Robert Engels
I think all of this will probably be handled with wrapper collections types and 
the iterator pattern. 

Generics should make this easy. It would be great is range supported this but 
it seems doubtful. 

> On Nov 12, 2021, at 10:37 AM, 'Axel Wagner' via golang-nuts 
>  wrote:
> 
> 
> It is still a different operation. For example, a range over a map is not 
> necessarily deterministic.
> 
> If you continue to ask detail-questions like this, it would be useful if you 
> could provide an actual program you'd want to write using them. Otherwise, it 
> makes a lot more sense to just wait for the spec-changes to be known. At that 
> point, it'll be easier to talk about if a specific example does or does not 
> conform to the spec.
> 
>> On Fri, Nov 12, 2021 at 5:08 PM T L  wrote:
>> 
>> 
>>> On Fri, Nov 12, 2021 at 11:54 PM Axel Wagner 
>>>  wrote:
>>> Oh, sorry, I just re-read. Your example still requires `range` to return 
>>> distinct types, so that probably shouldn't work.
>> 
>> Not this reason:
>> 
>> func Bar[T []byte|map[int]byte](s T) {
>> for i, v := range s { _, _ = i, v} // cannot range over s (variable of 
>> type T constrained by []byte|map[int]byte) (type set has no single 
>> underlying type)
>> }
>>  
>>> 
 On Fri, Nov 12, 2021 at 4:52 PM Axel Wagner 
  wrote:
 The error message gives you a reason - there is no single underlying type. 
 This works:
 
 type B []byte
 func Bar[T []byte|B](s T) {
 for range s {}
 }
 
 But yes, your example arguably should be made to work eventually. I would 
 suggest filing an issue about that.
 
> On Fri, Nov 12, 2021 at 4:47 PM tapi...@gmail.com  
> wrote:
> This one doesn't compile either.
> So the range operation doesn't support values of parameter types?
> 
> type MyByte byte
> 
> func Bar[T []byte|[]MyByte](s T) {
> for range s {} // cannot range over s (variable of type T constrained 
> by []byte|[]MyByte) (type set has no single underlying 
> } 
> 
>> On Friday, November 12, 2021 at 11:40:53 PM UTC+8 
>> axel.wa...@googlemail.com wrote:
>>> On Fri, Nov 12, 2021 at 4:29 PM tapi...@gmail.com  
>>> wrote:
 On Friday, November 12, 2021 at 11:10:17 PM UTC+8 
 axel.wa...@googlemail.com wrote:
 `range s` works differently for string and []byte. In the former case 
 it iterates over utf8-encoded unicode codepoints, in the latter it 
 iterates over bytes.
>>> 
>>> It is true, but why it matters here?
>> 
>> Because it makes `range` different operations for the purposes of 
>> determining the allowed operations on a type-parameter.
>>  
>> 
>>>  
 
> On Fri, Nov 12, 2021 at 3:18 PM tapi...@gmail.com  
> wrote:
> 
> func Bar[T []byte|string](s T) bool {
> for _, v := range s { // cannot range over s (variable of type T 
> constrained by []byte|string) (T has no structural type)
> if v > 100 {
> return true
> }
> }
> return false
> }
> 
> The message is quite confusing.
 
> -- 
> 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...@googlegroups.com.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/golang-nuts/44b5f535-adc8-4049-ba41-638f90becc3cn%40googlegroups.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...@googlegroups.com.
>> 
>>> To view this discussion on the web visit 
>>> https://groups.google.com/d/msgid/golang-nuts/abd83194-8198-40e8-ad12-82953f85fba5n%40googlegroups.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/42054eee-a9df-40d1-b148-4e5ead89ee0cn%40googlegroups.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/CAEkBMfHFJavSL%3DtrB8ZJgXRmyzqm3PE1ae139RLy1KkkCKkRDQ%40mail.gmail.com.

-- 
You received this message because you are subscribed to the Google 

Re: [go-nuts] Is this a known problem?

2021-11-12 Thread 'Axel Wagner' via golang-nuts
It is still a different operation. For example, a range over a map is not
necessarily deterministic.

If you continue to ask detail-questions like this, it would be useful if
you could provide an actual program you'd want to write using them.
Otherwise, it makes a lot more sense to just wait for the spec-changes to
be known. At that point, it'll be easier to talk about if a specific
example does or does not conform to the spec.

On Fri, Nov 12, 2021 at 5:08 PM T L  wrote:

>
>
> On Fri, Nov 12, 2021 at 11:54 PM Axel Wagner <
> axel.wagner...@googlemail.com> wrote:
>
>> Oh, sorry, I just re-read. Your example still requires `range` to return
>> distinct types, so that probably shouldn't work.
>>
>
> Not this reason:
>
> func Bar[T []byte|map[int]byte](s T) {
> for i, v := range s { _, _ = i, v} // cannot range over s (variable of
> type T constrained by []byte|map[int]byte) (type set has no single
> underlying type)
> }
>
>
>>
>> On Fri, Nov 12, 2021 at 4:52 PM Axel Wagner <
>> axel.wagner...@googlemail.com> wrote:
>>
>>> The error message gives you a reason - there is no single underlying
>>> type. This works:
>>>
>>> type B []byte
>>> func Bar[T []byte|B](s T) {
>>> for range s {}
>>> }
>>>
>>> But yes, your example arguably should be made to work eventually. I
>>> would suggest filing an issue about that.
>>>
>>> On Fri, Nov 12, 2021 at 4:47 PM tapi...@gmail.com 
>>> wrote:
>>>
 This one doesn't compile either.
 So the range operation doesn't support values of parameter types?

 type MyByte byte

 func Bar[T []byte|[]MyByte](s T) {
 for range s {} // cannot range over s (variable of type T
 constrained by []byte|[]MyByte) (type set has no single underlying
 }

 On Friday, November 12, 2021 at 11:40:53 PM UTC+8
 axel.wa...@googlemail.com wrote:

> On Fri, Nov 12, 2021 at 4:29 PM tapi...@gmail.com 
> wrote:
>
>> On Friday, November 12, 2021 at 11:10:17 PM UTC+8
>> axel.wa...@googlemail.com wrote:
>>
>>> `range s` works differently for string and []byte. In the former
>>> case it iterates over utf8-encoded unicode codepoints, in the latter it
>>> iterates over bytes.
>>>
>>
>> It is true, but why it matters here?
>>
>
> Because it makes `range` different operations for the purposes of
> determining the allowed operations on a type-parameter.
>
>
>>
>>
>>>
>>> On Fri, Nov 12, 2021 at 3:18 PM tapi...@gmail.com 
>>> wrote:
>>>

 func Bar[T []byte|string](s T) bool {
 for _, v := range s { // cannot range over s (variable of type
 T constrained by []byte|string) (T has no structural type)
 if v > 100 {
 return true
 }
 }
 return false
 }

 The message is quite confusing.

 --
 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...@googlegroups.com.
 To view this discussion on the web visit
 https://groups.google.com/d/msgid/golang-nuts/44b5f535-adc8-4049-ba41-638f90becc3cn%40googlegroups.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...@googlegroups.com.
>>
> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/golang-nuts/abd83194-8198-40e8-ad12-82953f85fba5n%40googlegroups.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/42054eee-a9df-40d1-b148-4e5ead89ee0cn%40googlegroups.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 

Re: [go-nuts] Is this a known problem?

2021-11-12 Thread T L
On Fri, Nov 12, 2021 at 11:54 PM Axel Wagner 
wrote:

> Oh, sorry, I just re-read. Your example still requires `range` to return
> distinct types, so that probably shouldn't work.
>

Not this reason:

func Bar[T []byte|map[int]byte](s T) {
for i, v := range s { _, _ = i, v} // cannot range over s (variable of
type T constrained by []byte|map[int]byte) (type set has no single
underlying type)
}


>
> On Fri, Nov 12, 2021 at 4:52 PM Axel Wagner 
> wrote:
>
>> The error message gives you a reason - there is no single underlying
>> type. This works:
>>
>> type B []byte
>> func Bar[T []byte|B](s T) {
>> for range s {}
>> }
>>
>> But yes, your example arguably should be made to work eventually. I would
>> suggest filing an issue about that.
>>
>> On Fri, Nov 12, 2021 at 4:47 PM tapi...@gmail.com 
>> wrote:
>>
>>> This one doesn't compile either.
>>> So the range operation doesn't support values of parameter types?
>>>
>>> type MyByte byte
>>>
>>> func Bar[T []byte|[]MyByte](s T) {
>>> for range s {} // cannot range over s (variable of type T
>>> constrained by []byte|[]MyByte) (type set has no single underlying
>>> }
>>>
>>> On Friday, November 12, 2021 at 11:40:53 PM UTC+8
>>> axel.wa...@googlemail.com wrote:
>>>
 On Fri, Nov 12, 2021 at 4:29 PM tapi...@gmail.com 
 wrote:

> On Friday, November 12, 2021 at 11:10:17 PM UTC+8
> axel.wa...@googlemail.com wrote:
>
>> `range s` works differently for string and []byte. In the former case
>> it iterates over utf8-encoded unicode codepoints, in the latter it 
>> iterates
>> over bytes.
>>
>
> It is true, but why it matters here?
>

 Because it makes `range` different operations for the purposes of
 determining the allowed operations on a type-parameter.


>
>
>>
>> On Fri, Nov 12, 2021 at 3:18 PM tapi...@gmail.com 
>> wrote:
>>
>>>
>>> func Bar[T []byte|string](s T) bool {
>>> for _, v := range s { // cannot range over s (variable of type T
>>> constrained by []byte|string) (T has no structural type)
>>> if v > 100 {
>>> return true
>>> }
>>> }
>>> return false
>>> }
>>>
>>> The message is quite confusing.
>>>
>>> --
>>> 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...@googlegroups.com.
>>> To view this discussion on the web visit
>>> https://groups.google.com/d/msgid/golang-nuts/44b5f535-adc8-4049-ba41-638f90becc3cn%40googlegroups.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...@googlegroups.com.
>
 To view this discussion on the web visit
> https://groups.google.com/d/msgid/golang-nuts/abd83194-8198-40e8-ad12-82953f85fba5n%40googlegroups.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/42054eee-a9df-40d1-b148-4e5ead89ee0cn%40googlegroups.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/CAHbs%3DNb133_JRg%2BJCYsdSbZN24OM_pA1S92zY%2BKACEF8MC%3Da6g%40mail.gmail.com.


Re: [go-nuts] Is this a known problem?

2021-11-12 Thread 'Axel Wagner' via golang-nuts
Oh, sorry, I just re-read. Your example still requires `range` to return
distinct types, so that probably shouldn't work.

On Fri, Nov 12, 2021 at 4:52 PM Axel Wagner 
wrote:

> The error message gives you a reason - there is no single underlying type.
> This works:
>
> type B []byte
> func Bar[T []byte|B](s T) {
> for range s {}
> }
>
> But yes, your example arguably should be made to work eventually. I would
> suggest filing an issue about that.
>
> On Fri, Nov 12, 2021 at 4:47 PM tapi...@gmail.com 
> wrote:
>
>> This one doesn't compile either.
>> So the range operation doesn't support values of parameter types?
>>
>> type MyByte byte
>>
>> func Bar[T []byte|[]MyByte](s T) {
>> for range s {} // cannot range over s (variable of type T constrained
>> by []byte|[]MyByte) (type set has no single underlying
>> }
>>
>> On Friday, November 12, 2021 at 11:40:53 PM UTC+8
>> axel.wa...@googlemail.com wrote:
>>
>>> On Fri, Nov 12, 2021 at 4:29 PM tapi...@gmail.com 
>>> wrote:
>>>
 On Friday, November 12, 2021 at 11:10:17 PM UTC+8
 axel.wa...@googlemail.com wrote:

> `range s` works differently for string and []byte. In the former case
> it iterates over utf8-encoded unicode codepoints, in the latter it 
> iterates
> over bytes.
>

 It is true, but why it matters here?

>>>
>>> Because it makes `range` different operations for the purposes of
>>> determining the allowed operations on a type-parameter.
>>>
>>>


>
> On Fri, Nov 12, 2021 at 3:18 PM tapi...@gmail.com 
> wrote:
>
>>
>> func Bar[T []byte|string](s T) bool {
>> for _, v := range s { // cannot range over s (variable of type T
>> constrained by []byte|string) (T has no structural type)
>> if v > 100 {
>> return true
>> }
>> }
>> return false
>> }
>>
>> The message is quite confusing.
>>
>> --
>> 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...@googlegroups.com.
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/golang-nuts/44b5f535-adc8-4049-ba41-638f90becc3cn%40googlegroups.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...@googlegroups.com.

>>> To view this discussion on the web visit
 https://groups.google.com/d/msgid/golang-nuts/abd83194-8198-40e8-ad12-82953f85fba5n%40googlegroups.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/42054eee-a9df-40d1-b148-4e5ead89ee0cn%40googlegroups.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/CAEkBMfF-N7%3DApH7bt8WfFeQ99rL8wh%3D0PP1YL4rWVsGk7_TQJQ%40mail.gmail.com.


Re: [go-nuts] Is this a known problem?

2021-11-12 Thread 'Axel Wagner' via golang-nuts
The error message gives you a reason - there is no single underlying type.
This works:

type B []byte
func Bar[T []byte|B](s T) {
for range s {}
}

But yes, your example arguably should be made to work eventually. I would
suggest filing an issue about that.

On Fri, Nov 12, 2021 at 4:47 PM tapi...@gmail.com 
wrote:

> This one doesn't compile either.
> So the range operation doesn't support values of parameter types?
>
> type MyByte byte
>
> func Bar[T []byte|[]MyByte](s T) {
> for range s {} // cannot range over s (variable of type T constrained
> by []byte|[]MyByte) (type set has no single underlying
> }
>
> On Friday, November 12, 2021 at 11:40:53 PM UTC+8
> axel.wa...@googlemail.com wrote:
>
>> On Fri, Nov 12, 2021 at 4:29 PM tapi...@gmail.com 
>> wrote:
>>
>>> On Friday, November 12, 2021 at 11:10:17 PM UTC+8
>>> axel.wa...@googlemail.com wrote:
>>>
 `range s` works differently for string and []byte. In the former case
 it iterates over utf8-encoded unicode codepoints, in the latter it iterates
 over bytes.

>>>
>>> It is true, but why it matters here?
>>>
>>
>> Because it makes `range` different operations for the purposes of
>> determining the allowed operations on a type-parameter.
>>
>>
>>>
>>>

 On Fri, Nov 12, 2021 at 3:18 PM tapi...@gmail.com 
 wrote:

>
> func Bar[T []byte|string](s T) bool {
> for _, v := range s { // cannot range over s (variable of type T
> constrained by []byte|string) (T has no structural type)
> if v > 100 {
> return true
> }
> }
> return false
> }
>
> The message is quite confusing.
>
> --
> 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...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/golang-nuts/44b5f535-adc8-4049-ba41-638f90becc3cn%40googlegroups.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...@googlegroups.com.
>>>
>> To view this discussion on the web visit
>>> https://groups.google.com/d/msgid/golang-nuts/abd83194-8198-40e8-ad12-82953f85fba5n%40googlegroups.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/42054eee-a9df-40d1-b148-4e5ead89ee0cn%40googlegroups.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/CAEkBMfGfo42fR7_JONduVEPX6yA5-A7-beMutne6hWoLLFK_2g%40mail.gmail.com.


Re: [go-nuts] Is this a known problem?

2021-11-12 Thread tapi...@gmail.com
This one doesn't compile either.
So the range operation doesn't support values of parameter types?

type MyByte byte

func Bar[T []byte|[]MyByte](s T) {
for range s {} // cannot range over s (variable of type T constrained 
by []byte|[]MyByte) (type set has no single underlying 
} 

On Friday, November 12, 2021 at 11:40:53 PM UTC+8 axel.wa...@googlemail.com 
wrote:

> On Fri, Nov 12, 2021 at 4:29 PM tapi...@gmail.com  
> wrote:
>
>> On Friday, November 12, 2021 at 11:10:17 PM UTC+8 
>> axel.wa...@googlemail.com wrote:
>>
>>> `range s` works differently for string and []byte. In the former case it 
>>> iterates over utf8-encoded unicode codepoints, in the latter it iterates 
>>> over bytes.
>>>
>>
>> It is true, but why it matters here?
>>
>
> Because it makes `range` different operations for the purposes of 
> determining the allowed operations on a type-parameter.
>  
>
>>  
>>
>>>
>>> On Fri, Nov 12, 2021 at 3:18 PM tapi...@gmail.com  
>>> wrote:
>>>

 func Bar[T []byte|string](s T) bool {
 for _, v := range s { // cannot range over s (variable of type T 
 constrained by []byte|string) (T has no structural type)
 if v > 100 {
 return true
 }
 }
 return false
 }

 The message is quite confusing.

 -- 
 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...@googlegroups.com.
 To view this discussion on the web visit 
 https://groups.google.com/d/msgid/golang-nuts/44b5f535-adc8-4049-ba41-638f90becc3cn%40googlegroups.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...@googlegroups.com.
>>
> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/golang-nuts/abd83194-8198-40e8-ad12-82953f85fba5n%40googlegroups.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/42054eee-a9df-40d1-b148-4e5ead89ee0cn%40googlegroups.com.


Re: [go-nuts] Is this a known problem?

2021-11-12 Thread 'Axel Wagner' via golang-nuts
On Fri, Nov 12, 2021 at 4:29 PM tapi...@gmail.com 
wrote:

> On Friday, November 12, 2021 at 11:10:17 PM UTC+8
> axel.wa...@googlemail.com wrote:
>
>> `range s` works differently for string and []byte. In the former case it
>> iterates over utf8-encoded unicode codepoints, in the latter it iterates
>> over bytes.
>>
>
> It is true, but why it matters here?
>

Because it makes `range` different operations for the purposes of
determining the allowed operations on a type-parameter.


>
>
>>
>> On Fri, Nov 12, 2021 at 3:18 PM tapi...@gmail.com 
>> wrote:
>>
>>>
>>> func Bar[T []byte|string](s T) bool {
>>> for _, v := range s { // cannot range over s (variable of type T
>>> constrained by []byte|string) (T has no structural type)
>>> if v > 100 {
>>> return true
>>> }
>>> }
>>> return false
>>> }
>>>
>>> The message is quite confusing.
>>>
>>> --
>>> 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...@googlegroups.com.
>>> To view this discussion on the web visit
>>> https://groups.google.com/d/msgid/golang-nuts/44b5f535-adc8-4049-ba41-638f90becc3cn%40googlegroups.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/abd83194-8198-40e8-ad12-82953f85fba5n%40googlegroups.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/CAEkBMfGoMM7ofPimitGfEtp%2BhsT0ifnDHdLae7r6T0gJ_V46Ww%40mail.gmail.com.


Re: [go-nuts] Is this a known problem?

2021-11-12 Thread tapi...@gmail.com


On Friday, November 12, 2021 at 11:10:17 PM UTC+8 axel.wa...@googlemail.com 
wrote:

> `range s` works differently for string and []byte. In the former case it 
> iterates over utf8-encoded unicode codepoints, in the latter it iterates 
> over bytes.
>

It is true, but why it matters here?
 

>
> On Fri, Nov 12, 2021 at 3:18 PM tapi...@gmail.com  
> wrote:
>
>>
>> func Bar[T []byte|string](s T) bool {
>> for _, v := range s { // cannot range over s (variable of type T 
>> constrained by []byte|string) (T has no structural type)
>> if v > 100 {
>> return true
>> }
>> }
>> return false
>> }
>>
>> The message is quite confusing.
>>
>> -- 
>> 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...@googlegroups.com.
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/golang-nuts/44b5f535-adc8-4049-ba41-638f90becc3cn%40googlegroups.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/abd83194-8198-40e8-ad12-82953f85fba5n%40googlegroups.com.


Re: [go-nuts] Is this a known problem?

2021-11-12 Thread 'Axel Wagner' via golang-nuts
`range s` works differently for string and []byte. In the former case it
iterates over utf8-encoded unicode codepoints, in the latter it iterates
over bytes.

On Fri, Nov 12, 2021 at 3:18 PM tapi...@gmail.com 
wrote:

>
> func Bar[T []byte|string](s T) bool {
> for _, v := range s { // cannot range over s (variable of type T
> constrained by []byte|string) (T has no structural type)
> if v > 100 {
> return true
> }
> }
> return false
> }
>
> The message is quite confusing.
>
> --
> 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/44b5f535-adc8-4049-ba41-638f90becc3cn%40googlegroups.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/CAEkBMfHKr4m3sAsuCVG0_-AZniF1vDyWU1Umoi3sO1Jujq1ZTA%40mail.gmail.com.


[go-nuts] Is this a known problem?

2021-11-12 Thread tapi...@gmail.com

func Bar[T []byte|string](s T) bool {
for _, v := range s { // cannot range over s (variable of type T 
constrained by []byte|string) (T has no structural type)
if v > 100 {
return true
}
}
return false
}

The message is quite confusing.

-- 
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/44b5f535-adc8-4049-ba41-638f90becc3cn%40googlegroups.com.