From 84e38bbaccea1a5f1b74de46f75ae41d95835c80 Mon Sep 17 00:00:00 2001 From: Xavier Noria Date: Mon, 15 Dec 2014 18:22:21 +0100 Subject: autoloading guide: adds nesting rule for Kernel#load [ci skip] --- guides/source/constant_autoloading_and_reloading.md | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/guides/source/constant_autoloading_and_reloading.md b/guides/source/constant_autoloading_and_reloading.md index e2c0d7003d..a426fd75b3 100644 --- a/guides/source/constant_autoloading_and_reloading.md +++ b/guides/source/constant_autoloading_and_reloading.md @@ -141,13 +141,16 @@ executed, and popped after it. * The module object following a `module` keyword gets pushed when its body is executed, and popped after it. -* When a singleton class is opened with `class << object`, said singleton class -gets pushed when the body is executed, and popped after it. +* A singleton class opened with `class << object` gets pushed, and popped later. * When any of the `*_eval` family of methods is called using a string argument, the singleton class of the receiver is pushed to the nesting of the eval'ed code. +* The nesting at the top-level of code interpreted by `Kernel#load` is empty +unless the `load` call receives a true value as second argument, in which case +a newly created anonymous module is pushed by Ruby. + It is interesting to observe that blocks do not modify the stack. In particular the blocks that may be passed to `Class.new` and `Module.new` do not get the class or module being defined pushed to their nesting. That's one of the -- cgit v1.2.3