From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: AS4713 221.184.0.0/13 X-Spam-Status: No, score=-3.0 required=3.0 tests=AWL,BAYES_00, DKIM_ADSP_CUSTOM_MED,FORGED_GMAIL_RCVD,FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED,SPF_PASS shortcircuit=no autolearn=ham autolearn_force=no version=3.4.2 Received: from neon.ruby-lang.org (neon.ruby-lang.org [221.186.184.75]) by dcvr.yhbt.net (Postfix) with ESMTP id D97AA1F453 for ; Thu, 7 Feb 2019 18:13:53 +0000 (UTC) Received: from neon.ruby-lang.org (localhost [IPv6:::1]) by neon.ruby-lang.org (Postfix) with ESMTP id 3A8BE12180C; Fri, 8 Feb 2019 03:13:50 +0900 (JST) Received: from o1678948x4.outbound-mail.sendgrid.net (o1678948x4.outbound-mail.sendgrid.net [167.89.48.4]) by neon.ruby-lang.org (Postfix) with ESMTPS id D08AD1216F3 for ; Fri, 8 Feb 2019 03:13:47 +0900 (JST) Received: by filter0180p3mdw1.sendgrid.net with SMTP id filter0180p3mdw1-12231-5C5C7559-1C 2019-02-07 18:13:45.637101423 +0000 UTC m=+167992.845262195 Received: from herokuapp.com (ec2-54-226-126-161.compute-1.amazonaws.com [54.226.126.161]) by ismtpd0029p1mdw1.sendgrid.net (SG) with ESMTP id ddKGl7-BRv2l8qgBPkupyA for ; Thu, 07 Feb 2019 18:13:45.566 +0000 (UTC) Date: Thu, 07 Feb 2019 18:13:46 +0000 (UTC) From: eregontp@gmail.com To: ruby-core@ruby-lang.org Message-ID: References: Mime-Version: 1.0 X-Redmine-MailingListIntegration-Message-Ids: 66928 X-Redmine-Project: ruby-trunk X-Redmine-Issue-Id: 15592 X-Redmine-Issue-Author: akr X-Redmine-Sender: Eregon X-Mailer: Redmine X-Redmine-Host: bugs.ruby-lang.org X-Redmine-Site: Ruby Issue Tracking System X-Auto-Response-Suppress: All Auto-Submitted: auto-generated X-SG-EID: ync6xU2WACa70kv/Ymy4QrNMhiuLXJG8OTL2vJD1yS4l51/EWG4EwISD3YS2pyZ747xUwOl59Fgd9J kApl+LeqAGL65go1yZQDqK86/9TwxFDiKTs8ASe8UiRcdG2V1aI/5/qpleGKy6oVwynT6/oY2aB1jT 4d184T+ajMAMf8u4/H2eLQXxvEK/J8gz/xWCt/eJX4FGBJs55bH36JKv5g== X-ML-Name: ruby-core X-Mail-Count: 91475 Subject: [ruby-core:91475] [Ruby trunk Feature#15592] mode that "autoload" behaves "require" immediately X-BeenThere: ruby-core@ruby-lang.org X-Mailman-Version: 2.1.15 Precedence: list Reply-To: Ruby developers List-Id: Ruby developers List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: ruby-core-bounces@ruby-lang.org Sender: "ruby-core" Issue #15592 has been updated by Eregon (Benoit Daloze). This sounds interesting, and would definitely help debugging autoload code. As a note, it can already be achieved on existing releases by monkey-patching Kernel#autoload and Kernel.autoload. I'm against `RubyVM.autoload_mode` as long as RubyVM is supposed to be MRI-only. Global variables seem generally deprecated. Maybe it should be a command-line switch/"feature" like frozen string literals: `--enable-eager-autoload`? ---------------------------------------- Feature #15592: mode that "autoload" behaves "require" immediately https://bugs.ruby-lang.org/issues/15592#change-76734 * Author: akr (Akira Tanaka) * Status: Open * Priority: Normal * Assignee: * Target version: ---------------------------------------- How about a feature to switch "autoload" behavior to "require" immediately. autoload is a feature for lazy loading. matz dislikes autoload as [Feature #5653]. I heard that he dislikes class (and other) definitions at arbitrary timing. I agree that eager loading is safer than lazy loading. However, lazy loading realize shorter loading time and it makes development cycle shorter. It is more important for larger applications as Eregon said in https://bugs.ruby-lang.org/issues/5653#note-39 . It is especially important when library loading causes I/O (code generation from DB schema). These two, safety of eager loading and easier development of lazy loading, conflicts. But if we can distinguish production mode and development mode, we can enjoy both benefits. So, I propose a feature to select autoload behavior from two modes: - autoload behaves as lazy loading as now in development mode - autoload behaves as eager loading (immediately invokes "require") in production mode. There are several idea to switch the mode: - $AUTOLOAD_MODE = :eager or :lazy - RubyVM.autoload_mode = :eager or :lazy - ObjectSpace.autoload_mode = :eager or lazy I'm not sure there is a good enough one in above list, though. -- https://bugs.ruby-lang.org/