From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Original-To: poffice@blade.nagaokaut.ac.jp Delivered-To: poffice@blade.nagaokaut.ac.jp Received: from kankan.nagaokaut.ac.jp (kankan.nagaokaut.ac.jp [133.44.2.24]) by blade.nagaokaut.ac.jp (Postfix) with ESMTP id 2605C196025D for ; Fri, 17 Jul 2015 18:14:23 +0900 (JST) Received: from funfun.nagaokaut.ac.jp (smtp.nagaokaut.ac.jp [133.44.2.201]) by kankan.nagaokaut.ac.jp (Postfix) with ESMTP id 20E88B5D9B8 for ; Fri, 17 Jul 2015 18:43:21 +0900 (JST) Received: from funfun.nagaokaut.ac.jp (localhost.nagaokaut.ac.jp [127.0.0.1]) by funfun.nagaokaut.ac.jp (Postfix) with ESMTP id 4B72897A839 for ; Fri, 17 Jul 2015 18:43:23 +0900 (JST) X-Virus-Scanned: amavisd-new at nagaokaut.ac.jp Authentication-Results: funfun.nagaokaut.ac.jp (amavisd-new); dkim=fail (1024-bit key) reason="fail (message has been altered)" header.d=sendgrid.me Received: from funfun.nagaokaut.ac.jp ([127.0.0.1]) by funfun.nagaokaut.ac.jp (funfun.nagaokaut.ac.jp [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id CzmRbXKDzXuY for ; Fri, 17 Jul 2015 18:43:22 +0900 (JST) Received: from voscc.nagaokaut.ac.jp (voscc.nagaokaut.ac.jp [133.44.1.100]) by funfun.nagaokaut.ac.jp (Postfix) with ESMTP id C3C6E97A83A for ; Fri, 17 Jul 2015 18:43:22 +0900 (JST) Received: from neon.ruby-lang.org (neon.ruby-lang.org [221.186.184.75]) by voscc.nagaokaut.ac.jp (Postfix) with ESMTP id 60401952447 for ; Fri, 17 Jul 2015 18:43:20 +0900 (JST) Received: from [221.186.184.76] (localhost [IPv6:::1]) by neon.ruby-lang.org (Postfix) with ESMTP id CB350120492; Fri, 17 Jul 2015 18:43:18 +0900 (JST) X-Original-To: ruby-core@ruby-lang.org Delivered-To: ruby-core@ruby-lang.org Received: from o10.shared.sendgrid.net (o10.shared.sendgrid.net [173.193.132.135]) by neon.ruby-lang.org (Postfix) with ESMTPS id B2AD4120470 for ; Fri, 17 Jul 2015 18:43:14 +0900 (JST) DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sendgrid.me; h=from:to:references:subject:mime-version:content-type:content-transfer-encoding:list-id; s=smtpapi; bh=7fZzwp3S/dRzE76LkGnZg4pqZeI=; b=O0A9MUZPgU3zC5Y66R xKSNotdHV+oGmiRaLvHg9O8pKrPrzq2t1zj/5DPBSXgbGcPIizi3L9utFaGS5g7z oZcvoDNJXm6amm0V6R5cd26lsGxjr7Vib052hHKkX4O0S0kXWfahyZNKJ9djU6+2 EOW2HCgnWyL5ftu7uTAaXNVOE= Received: by filter0592p1mdw1.sendgrid.net with SMTP id filter0592p1mdw1.9258.55A8CE2C4 2015-07-17 09:43:08.78182775 +0000 UTC Received: from herokuapp.com (ec2-54-161-222-184.compute-1.amazonaws.com [54.161.222.184]) by ismtpd-009 (SG) with ESMTP id 14e9b655e9b.4828.42cde4 for ; Fri, 17 Jul 2015 09:43:08 +0000 (UTC) Date: Fri, 17 Jul 2015 09:43:08 +0000 From: eregontp@gmail.com To: ruby-core@ruby-lang.org Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Redmine-MailingListIntegration-Message-Ids: 44627 X-Redmine-Project: ruby-trunk X-Redmine-Issue-Id: 11360 X-Redmine-Issue-Author: ko1 X-Redmine-Issue-Assignee: ko1 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/Ymy4QrNMhiuLXJG8OTL2vJD1yS7pJL87eNKzWKgu82hzJjIucj5zC6z0swn5vd C/RBj3XIPkMZxkYqSw/VuWi3hxmEOD9BRsk2J1HI7rg32GCDsDpu+rpi5HbJG2CCuin6MHKWaakH69 xjvSrSWSRN4Be3lgo0aih1w27iznMPydWgSa X-ML-Name: ruby-core X-Mail-Count: 70010 Subject: [ruby-core:70010] [Ruby trunk - Bug #11360] Singleton class doesn't appear by ObjectSpace.each_object 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: , Errors-To: ruby-core-bounces@ruby-lang.org Sender: "ruby-core" Issue #11360 has been updated by Benoit Daloze. Koichi Sasada wrote: > From Ruby 1.6, singleton classes are not appeared. > Is it intentional? I guess the reason is exposing the last layer of singleton classes would expose "VM-internal singleton classes/metaclasses". The documentation of `rb_singleton_class` explains it a bit. But basically the VM needs the metaclass of any class exposed to the user, and exposing them would require another layer, which if exposed as well would need another, etc. Singleton classes which already have a metaclass could be iterated though. ---------------------------------------- Bug #11360: Singleton class doesn't appear by ObjectSpace.each_object https://bugs.ruby-lang.org/issues/11360#change-53443 * Author: Koichi Sasada * Status: Open * Priority: Normal * Assignee: Koichi Sasada * ruby -v: 2.3dev * Backport: 2.0.0: UNKNOWN, 2.1: UNKNOWN, 2.2: UNKNOWN ---------------------------------------- Singleton class doesn't appear by ObjectSpace.each_object. The following is reproducible code. ```ruby class C class << self p [self, self.class] $c = self end end ObjectSpace.each_object(Class){|o| exit if $c == o } raise "#{$c} is not found!" ``` This is because internal_object_p in gc.c skips singleton classes. ```C static int internal_object_p(VALUE obj) { RVALUE *p = (RVALUE *)obj; if (p->as.basic.flags) { switch (BUILTIN_TYPE(p)) { case T_NONE: case T_IMEMO: case T_ICLASS: case T_NODE: case T_ZOMBIE: break; case T_CLASS: if (FL_TEST(p, FL_SINGLETON)) break; default: if (!p->as.basic.klass) break; return 0; } } return 1; } ``` -- https://bugs.ruby-lang.org/