On Sun, Feb 13, 2022 at 11:23 PM Kamil Ziemian <kziemian...@gmail.com>
wrote:

> "So, no, this is not something that I made up to have an example or
> anything like that. I thought about a couple alternative ways to do it and
> they all don't work for one reason or another."
>
> Thank you for the information. Do you check if performance of generic code
> is good? I always want to know if there is regression in performance.
>

Performance does not matter in ~all cases I'm concerned with so far.

I see no reason why performance would suffer for my case, though, as it
currently uses interfaces and reflect. If anything, performance should
improve (even if calls are still indirect) as I can completely remove
reflect and remove some of the type assertions.

There are certainly cases where performance will suffer, when compared to
generated code for a specific types, FWIW. It's just that they are not what
I'm talking about here.

"FWIW, here is code that assigns to varSI in two ways:
> https://go.dev/play/p/ypj6rQbpBBl";
>
> From what I understand "type someInterface [3]interface{ SomeMethod() }"
> define interface array of three elements of "interface{ SomeMethod() }" and
> as such it should rather be name "someArrayOfInterfaces". Am I right?
>
> Also, can someone give me an example, where it is desired to use such type?
>
> Best,
> Kamil
> niedziela, 13 lutego 2022 o 17:44:30 UTC+1 jake...@gmail.com napisaƂ(a):
>
>> On Friday, February 11, 2022 at 10:02:42 AM UTC-5 kziem...@gmail.com
>> wrote:
>>
>>> I'm seriously lost here. Code below works in both Go 1.17 and Go
>>> 1.18beta2
>>>
>>> > package main
>>> >
>>> > import "fmt"
>>> >
>>> > type someInterface[3] interface {
>>> >         SomeMethod()
>>> > }
>>> >
>>> > func main() {
>>> >         var varSI someInterface
>>> >
>>> >         fmt.Printf("varSI value: %v\n", varSI)
>>> >         fmt.Printf("varSI type:  %T\n", varSI)
>>> > }
>>>
>>> and give in both cases result
>>> > varSI value: [<nil> <nil> <nil>]
>>> > varSI type:  main.someInterface
>>>
>>> I didn't find any way to assign some new value to "varSI", but this is
>>> already disturbing to me.
>>>
>>
>> FWIW, here is code that assigns to varSI in two ways:
>> https://go.dev/play/p/ypj6rQbpBBl
>> Note that running this code in the playground will reformat ' type
>> someInterface[3] interface' to the proper ' type someInterface
>> [3]interface'. This is not a change in meaning, just a clarifying white
>> space change made by `go fmt`.
>>
> --
> 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/0966efb7-7b73-4001-87f6-71a6362fe350n%40googlegroups.com
> <https://groups.google.com/d/msgid/golang-nuts/0966efb7-7b73-4001-87f6-71a6362fe350n%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/CAEkBMfH7F806dH4ihk%3DqeiXcNFwhDMutbF_VNs863bHW2E7DVw%40mail.gmail.com.

Reply via email to