On Sun, Sep 9, 2018 at 11:08 PM Jonathan Amsterdam <jbamster...@gmail.com> wrote:
> func ShortestPath(type G Graph(Node, Edge), Node, Edge) (g G, from, to >> Node) []Edge >> > > I don't think this syntax is valid according to the draft design, or your > blog post. Node and Edge are used before they are declared. > I have not made any statements about that (and Ian/Robert's drafts don't allow for multiple contracts), but I don't think this is an actual problem, as long as the references aren't cyclic. You can unify the leafs in the dependency trees first. Maybe > > func ShortestPath(type Node, Edge, G Graph(Node, Edge)) (g G, from, to > Node) []Edge > > except according to your description, all three type parameters would have > Graph(Node, Edge) as constraints, which doesn't make sense either. > Yes, but my description allows for func ShortestPath(type Node, Edge interface{}, G Graph(Node, Edge)) (g G, from, to Node) []Edge (it's just that an interface{} as the last constraint is implied). But as I said, i don't think this is an actual issue. --- BTW, I actually went (like Ian suggested) through the examples in the draft design <https://go.googlesource.com/proposal/+/master/design/go2draft-contracts.md#examples> - at least that specific section, not the inline ones, as I found them harder to scan for - and they all can be written in my design idea by simply deleting the contracts and replacing cmp1/cmp2/cmp3 by comparable. There is a minor detail they brought up, which is that if all struct-keys are comparable, then the struct itself is too (which IMO should be clear, but *might* need some language in an actual spec?). Furthermore, it re-emphasizes that pseudo-interfaces are actually misnamed and definitely shouldn't be thought of as types themselves, because the question comes up how they would behave under struct embedding. But IMO that's a question of phrasing, not of semantics or an unsolvable issue. > >> On Sun, Sep 9, 2018 at 8:21 PM Jonathan Amsterdam <jbams...@gmail.com> >> wrote: >> >>> >>>> FWIW, in my pseudo-interface description >>>> <https://blog.merovius.de/2018/09/05/scrapping_contracts.html>, >>>> >>> >>> Unrelated to this particular issue, but since you link to your blog >>> post, I just want to mention that in your graph example, >>> >>> func ShortestPath(type Node, Edge) (g Graph(Node, Edge), from, to >>> Node) []Edge >>> >>> will have dynamic dispatches in the body (since g is an ordinary >>> interface value). The one in the draft design is completely static. >>> >>> -- >>> 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...@googlegroups.com. >>> For more options, visit https://groups.google.com/d/optout. >>> >> -- > 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. > For more options, visit https://groups.google.com/d/optout. > -- 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. For more options, visit https://groups.google.com/d/optout.