[Documentation Incomplete Explanation?] Methods Chapter - Redefining Methods

Hi - I’m currently reading the manual to learn Julia.

I’ve spotted maybe an incomplete example in the Methods chapter on redefining methods.

It seems to say that there are two definitions of the newfun() function, but I can only spot what must be the “new” definition within the tryeval() function body.

Could someone maybe confirm this or explain why I might be wrong/misunderstanding?

Many thanks,
Jaimin

The definition of newfun is not a closure inside tryeval, it’s evaluated into the global scope. That’s true for all @eval code. The old (or nonexistent) versus new definitions are split across different world ages. You could study world age in that section and the linked page, but in practice, you’ll want to stick to closures or wait until function calls like tryeval() return all the way to the global scope before calling any of the methods.