Or any map type with a specified key type but ignore the element type.
On Saturday, June 20, 2020 at 9:16:39 AM UTC-4, T L wrote:
>
> .
>
--
You received this message because you are subscribed to the Google Groups
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails fr
I mean I don't care about the element and key types of the parameter type.
For a simple example, I want to define a generic function which prints the
length of a container (do do some other things):
func Print(type T Container) (v T) {
// ... do some things
fmt.Println(len(v))
// ...
I would assume it's
type MapConstraint(type K comparable, V interface{}) interface {
type map[K]V
}
func F(type M MapConstraint(K, V), K comparable, V interface{}) (m M) {
}
Note that you are under no obligation to make use of a type-parameter if
you don't need it.
On Sat, Jun 20, 2020 at 4
On Saturday, June 20, 2020 at 10:21:56 AM UTC-4, Axel Wagner wrote:
>
> I would assume it's
>
> type MapConstraint(type K comparable, V interface{}) interface {
> type map[K]V
> }
>
> func F(type M MapConstraint(K, V), K comparable, V interface{}) (m M) {
> }
>
> Note that you are under no ob
On Sat, Jun 20, 2020 at 11:03 AM T L wrote:
>
>
> On Saturday, June 20, 2020 at 10:21:56 AM UTC-4, Axel Wagner wrote:
>>
>> I would assume it's
>>
>> type MapConstraint(type K comparable, V interface{}) interface {
>> type map[K]V
>> }
>>
>> func F(type M MapConstraint(K, V), K comparable, V
Maps and Slices don't have a lot of operations in common. In general, the
only ones I can think of are
- `make(T, someInt)`, though it means *very* different things for both, so
a generic function doing this is likely not super sensible
- `for _, v := range x`, though even this differs, as the orde
On Sat, Jun 20, 2020 at 12:08 PM David Finkel wrote:
>
> Here's an almost working example:
> https://go2goplay.golang.org/p/qcdfl0tuHlb
>
> It looks like there's a bug in the type-parameter constraint checking because
> in the above example code, I get:
>
> type checking failed for main
>
> prog.
On Saturday, June 20, 2020 at 3:08:42 PM UTC-4, David Finkel wrote:
>
>
>
> On Sat, Jun 20, 2020 at 11:03 AM T L >
> wrote:
>
>>
>>
>> On Saturday, June 20, 2020 at 10:21:56 AM UTC-4, Axel Wagner wrote:
>>>
>>> I would assume it's
>>>
>>> type MapConstraint(type K comparable, V interface{}) inte
On Sat, Jun 20, 2020 at 4:53 PM Ian Lance Taylor wrote:
> On Sat, Jun 20, 2020 at 12:08 PM David Finkel
> wrote:
> >
> > Here's an almost working example:
> > https://go2goplay.golang.org/p/qcdfl0tuHlb
> >
> > It looks like there's a bug in the type-parameter constraint checking
> because in the
On Sat, Jun 20, 2020 at 8:08 PM T L wrote:
>
>
>
> On Saturday, June 20, 2020 at 3:08:42 PM UTC-4, David Finkel wrote:
>>
>>
>>
>> On Sat, Jun 20, 2020 at 11:03 AM T L wrote:
>>>
>>>
>>>
>>> On Saturday, June 20, 2020 at 10:21:56 AM UTC-4, Axel Wagner wrote:
I would assume it's
>>>
On Sunday, June 21, 2020 at 11:24:37 PM UTC-4, Ian Lance Taylor wrote:
>
> On Sat, Jun 20, 2020 at 8:08 PM T L >
> wrote:
> >
> >
> >
> > On Saturday, June 20, 2020 at 3:08:42 PM UTC-4, David Finkel wrote:
> >>
> >>
> >>
> >> On Sat, Jun 20, 2020 at 11:03 AM T L wrote:
> >>>
> >>>
>
On Mon, Jun 22, 2020 at 8:49 AM T L wrote:
>
> One example is the above Print function example.
> Another example I current get is to iterate and print
> all the key and values of a container in a current format.
> There should be more examples with this need I think.
I want to stress that we wan
On Monday, June 22, 2020 at 1:25:33 PM UTC-4, Ian Lance Taylor wrote:
>
> On Mon, Jun 22, 2020 at 8:49 AM T L >
> wrote:
> >
> > One example is the above Print function example.
> > Another example I current get is to iterate and print
> > all the key and values of a container in a current f
On Tue, Jun 23, 2020 at 8:34 AM T L wrote:
>
> On Monday, June 22, 2020 at 1:25:33 PM UTC-4, Ian Lance Taylor wrote:
>>
>> On Mon, Jun 22, 2020 at 8:49 AM T L wrote:
>> >
>> > One example is the above Print function example.
>> > Another example I current get is to iterate and print
>> > all the
14 matches
Mail list logo