Regarding the question of why “named” functions behave differently from anonymous functions for serialization, I just came across this post in a different thread:
Just for completeness, another small difference is how they’re serialized. For the anonymous version, the function definition is actually serialized, where as the non-anonymous one just the name is serialized. The niche place where this might come up is when using Distributed’s auto-global shipping, so e.g. this works,
foo = () -> 3
@fetch foo() # foo definition shipped to worker, run there, answer returned
whereas the non-anonymous version you need to have foo actually defined on all workers …