[go-nuts] Re: Types are contract -, v2

2018-11-20 Thread komuW
> > A contract can also be written in terms of a struct: > > contract linkedListNode { > X struct { > next *X > } > } > > In this example taken from the linked document; what is X? On Tuesday, 20 November 2018 05:38:31 UTC+3, Burak Serdar wrote: > > Hi, > > A while ago I sent an email

Re: [go-nuts] Re: Types are contract -, v2

2018-11-20 Thread Michel Levieux
I guess X is the type that is represented by the struct, the meaning being : "the type X is a struct that contains a field that is a pointer to a value of the same type". EDIT : I think the "next" word, which is here the name of the field, can even be omitted. The relevant information here is to k

Re: [go-nuts] Re: Types are contract -, v2

2018-11-20 Thread Burak Serdar
On Tue, Nov 20, 2018 at 4:38 AM komuW wrote: >> >> A contract can also be written in terms of a struct: >> >> contract linkedListNode { >> X struct { >> next *X >> } >> } > > > In this example taken from the linked document; what is X? X is the name of the struct type. This struct satisfi

Re: [go-nuts] Re: Types are contract -, v2

2018-11-20 Thread Burak Serdar
On Tue, Nov 20, 2018 at 6:27 AM Michel Levieux wrote: > > I guess X is the type that is represented by the struct, the meaning being : > "the type X is a struct that contains a field that is a pointer to a value of > the same type". > > EDIT : I think the "next" word, which is here the name of t

Re: [go-nuts] Re: Types are contract -, v2

2018-11-20 Thread Michel Levieux
Yes, but you can just specify the concract like : contract doubleLinkedListNode { X struct { *X *X } } which defines a type X containing at least two pointers to values of type X. You'd do the same currently for a function type --> func (int, int, string), which takes two

Re: [go-nuts] Re: Types are contract -, v2

2018-11-20 Thread Burak Serdar
On Tue, Nov 20, 2018 at 7:36 AM Michel Levieux wrote: > > Yes, but you can just specify the concract like : > > contract doubleLinkedListNode { > X struct { > *X > *X > } > } > > which defines a type X containing at least two pointers to values of type X. > You'd do the sa

Re: [go-nuts] Re: Types are contract -, v2

2018-11-20 Thread Michel Levieux
I'm not quite sure I understand your example . According to me a contract on a structure type only defines what the structure type should have (aka the minimum number of fields and their respective types). When you define a function with a generic type, the only thing the compiler should check is t

Re: [go-nuts] Re: Types are contract -, v2

2018-11-20 Thread Burak Serdar
On Tue, Nov 20, 2018 at 7:59 AM Michel Levieux wrote: > > I'm not quite sure I understand your example . > According to me a contract on a structure type only defines what the > structure type should have (aka the minimum number of fields and their > respective types). When you define a function

Re: [go-nuts] Re: Types are contract -, v2

2018-11-20 Thread Michel Levieux
Oh. Okay ! Yeah sorry I think my mind got stuck with the notion of "abstract definition" of any type and did not see the concrete use they could be subject to. I see what you mean : https://play.golang.org/p/8P3IJElTS7d would effectively not work. I think I didn't have the full picture of this.