On Wed, Jun 17, 2020 at 5:18 PM Randall O'Reilly wrote:
>
> Good point!
>
> I can think of 2 possible (non-mutex) solutions:
>
> * Use an explicit type expression to refer to the type: `type(ms.T)` and the
> field is just `ms.T`
>
> * Within the method scope, make `T` a valid type name, so you ca
Good point!
I can think of 2 possible (non-mutex) solutions:
* Use an explicit type expression to refer to the type: `type(ms.T)` and the
field is just `ms.T`
* Within the method scope, make `T` a valid type name, so you can just use `T`
directly -- this might even be preferable overall as it
I think this syntax could get confusing when embedded fields is added to
the mix:
type MyStruct(type T) struct {
T
}
func (ms *MyStruct) MyMethod(t ms.T) {
ms.T = t
}
In this example. ms.T means two very different things depending on where
they are used.
On Wed, Jun 17, 2020 at 3:45 AM
You could save a fair amount of typing and eyestrain by not replicating the
type params for types, in their methods:
type Vector(type T) []T
func (v *Vector) Push(x v.T) { *v = append(*v, x) }
type Map(type K, V) struct {
root*node(K, V)
compare func(K, K) int