On Thursday, November 24, 2016 at 1:30:55 AM UTC+8, Axel Wagner wrote: > > On Wed, Nov 23, 2016 at 4:30 PM, T L <tapi...@gmail.com <javascript:>> > wrote: > >> If two functions do completely different things, they mus be two >> different functions. >> > > No. An example has been given above, here is another one: > https://play.golang.org/p/uNN0G4gzFm > > >> Two different functions can also do the same thing, but they should be >> not equal. >> > > Why not? If someone who never read go code reads "f == g", why would they > assume that this is your definition? Why wouldn't they get confused, that > two functions who have the same definition (not "stem from the same > declaration", but "contain the same code") are not equal? > > I agree that your definition is *consistent*. But it is still a) confusing > for some cases and b) *not obviously the only sensible one*. Meaning, > newcomers won't be able to infer from the expression, what it does. At all. > (yes, go has similar problems elsewhere. But that doesn't mean, that we > should pile on) >
Then, how about let functions come from the same one function literal be equal? > > >> >> >>> >>> Can you give a good justification of that behavior? And do you really >>> think it won't confuse people like hell? >>> >>> One of the main reasons given for not making functions comparable, is >>> that there is no good, intuitive notion of what "equality" means in the >>> face of inlining and closures, so *no matter what behavior you choose*, >>> people will be confused. >>> >>> On Wed, Nov 23, 2016 at 4:01 PM, T L <tapi...@gmail.com> wrote: >>> >>>> >>>> >>>> On Wednesday, November 23, 2016 at 10:39:01 PM UTC+8, Volker Dobler >>>> wrote: >>>>> >>>>> Am Mittwoch, 23. November 2016 15:30:39 UTC+1 schrieb T L: >>>>>> >>>>>> >>>>>> >>>>>> On Wednesday, November 23, 2016 at 9:53:57 PM UTC+8, Volker Dobler >>>>>> wrote: >>>>>>> >>>>>>> Just one argument out of many: Closures. >>>>>>> x := 3 >>>>>>> f1 := func() int { >>>>>>> return x >>>>>>> } >>>>>>> f2 := func() int { return 3 } >>>>>>> // Is f1 == f2 ? >>>>>>> >>>>>>> x = 4 >>>>>>> // What now? Still f1 == f2? Or never equal? >>>>>>> >>>>>>> >>>>>> Any bad to think then never equal? >>>>>> >>>>> >>>>> That's basically is it: If functions are never equal so it is >>>>> not sensible make them comparable. >>>>> >>>>> V. >>>>> >>>> >>>> functions from the same declaration are equal. >>>> and function variables at the same address are equal. >>>> >>>> >>>> -- >>>> 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...@googlegroups.com <javascript:>. >> 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.