Sorry for the noise - looks like you meant when passing around objects by 
this type, not just creating objects.

On Friday, May 3, 2024 at 11:02:37 AM UTC-6 Kevin Chowski wrote:

> If you are just unhappy about the A and A* while using a literal for C: 
> note that if you are willing/able to write a wrapper function instead of 
> using a literal, type inference works well today:
>
> func NewC[E any, P Settable[E]](val []E) C[E, P] {
> return C[E, P]{Val: val}
> }
> var c = NewC([]A{1, 2, 3})
>
> Full: https://go.dev/play/p/JIk1L4rBXEs
>
> On Tuesday, April 23, 2024 at 11:35:03 AM UTC-6 Ian Lance Taylor wrote:
>
>> On Mon, Apr 22, 2024 at 11:01 PM Jochen Voss <joche...@gmail.com> wrote: 
>> > 
>> > This works, see my code below. Followup question: is there a way to 
>> refer to the new type without having to list both the element type and the 
>> pointer type separately? 
>>
>> Unfortunately there is not. At some point in the future the language 
>> may support type inference for type arguments to types, for cases 
>> where one type argument can be inferred from another type argument. 
>> Currently that is not supported because there are some complex issues 
>> involving cyclical types that need to be resolved or side-stepped. 
>>
>> In Go 1.23 I think it should be possible to simplify using these kinds 
>> of types with a type alias as in "type X[E] = C[E, *E]". 
>>
>> Ian 
>>
>

-- 
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/0791f433-23f2-45d9-961a-28c90bed6d77n%40googlegroups.com.

Reply via email to