Yeah, it would have performance implications, which is a good counter
argument. Regardless, it seems from the discussion that function values can
have multiple addresses, so it wouldn't work currently anyway.

On Thu, May 5, 2022 at 6:39 AM David Arroyo <dr...@aqwari.net> wrote:

> On Mon, May 2, 2022, at 22:43, will....@gmail.com wrote:
> >    - Functions: Compare the corresponding memory addresses. The time
> >    complexity is constant.
>
> How would this apply to inlined functions? supporting equality would
> essentially force the compiler to keep a the function in the output binary
> even if it's inlined everywhere it's called, just for comparisons. It would
> also complicate
>
> Here's another example:
>
>         type worker struct { ... }
>         func shutDown() { ... }
>
>         func (w *worker) run(orders <-chan func()) {
>                 for f := range orders {
>                         if(f == shutDown) {
>                                 log.Printf("got a shutdown command")
>                                 w.Cleanup()
>                         }
>                         f()
>                 }
>         }
>
> currently, Go programs run on a single computer. What if a Go runtime was
> built that ran Go programs across many computers? Or, put another way, what
> if a system architecture emerged where the instruction access time varied
> so drastically across CPU cores that it made sense to duplicate functions
> across cores' fast memory regions, so that the receive operation in the
> above example actually received a duplicate copy of a function? I will
> admit that closures with mutable data segments already complicate such an
> optimization, but function equality would thwart such an optimization
> altogether.
>
> David
>
> --
> You received this message because you are subscribed to a topic in the
> Google Groups "golang-nuts" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/golang-nuts/b-WtVh3H_oY/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to
> golang-nuts+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/golang-nuts/f566007f-aa47-4aaf-bc9e-a0fa9dab1e62%40www.fastmail.com
> .
>

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/CAKbcuKgo_xhpiMjjW-ePQ0TFW2%2BM0iiSy5KDpQCBwoLinx2Vqw%40mail.gmail.com.

Reply via email to