ruby picture

RCR 153: const_missing should be invoked before toplevel scope is sea

Submitted by legacy (Wed Sep 03 09:09:26 UTC 2003)

Abstract

This is a legacy RCR from Ruby Garden, submitted by pong. Matz has declared these RCRs obsolete, and asked that their authors resubmit them in the new format.

If you define const_missing and you refer to a constant using an explicit scope like this M1::Object then M1::const_missing should be invoked before searching the toplevel scope.

module M1
  def self.const_missing(aSymbol)
    puts "Looking for #{aSymbol}"
   end
end
M1::Blah # Prints "Looking ..."
M1::Object
  1. Returns :: and ruby prints the warning:
  2. "warning: toplevel constant Object referenced by M1::Object"

    

I don't even understand why this is a warning in the first place, it should be an error, imho. And since ruby knows when to print the warning it should be straightforward to consult constant_missing first/instead.

Problem

(RCR imported from old format)

Proposal

Analysis

(RCR imported from old format)

Implementation

(RCR imported from old format)
ruby picture
Comments Current voting


Strongly opposed 0
Opposed 0
Neutral 0
In favor 0
Strongly advocate 0
ruby picture
If you have registered at RCRchive, you may now sign in below. If you have not registered, you may sign up for a username and password. Registering enables you to submit new RCRs, and vote and leave comments on existing RCRs.
Your username:
Your password:

ruby picture

Powered by .