ruby picture

RCR 228: Uniform meta-access while parsing Ruby code

Submitted by itsme213 (Thu Mar 11 16:03:50 UTC 2004)


Ruby's exposing of self within a class body is one of its powerful extensibility features. This RCR proposes similar uniform access via self to methods, parameters, constants, etc. to allow extensibility of all of these elements.


Facilities such as attr rely on methods on Class being invoked within a class body with self = current_class. By POLS, similar access should be provided to methods defined on syntactic elements such as:



Generalize class facilities like attr (in the same spirit as SAX events) by doing the following:



If I knew more of how the Ruby grammar was being implemented I could probably suggest something.
ruby picture
Comments Current voting

The Ruby grammar is implemented with lex/yacc IIRC. However, I'm not sure that this makes any sense as stated. As of right now, it's not necessary to enclose parameter lists inside of parentheses, so no "code" can be between def foo and (a, ...). I also don't think that meta-code is necessary or useful for the parameter lists themselves.

Far better would be the oft-suggested (and it might even be on the current list of RCRs) change that all keywords return something useful, e.g.:

  • def foo ... end => :foo (or def foo ... end => self.method(:foo))
  • class Foo ... end => Foo
  • module Bar ... end => Bar

And so on, as needed. -- Austin Ziegler

This RCR is breaking a few RCR rules:

  • NEVER mention POLS in the proposal.
  • proposal should be concrete, so that we can implement it.
  • ratinale/reason required. mere generalization is not enough.

Please resubmit it, if you really want to propose something.


Strongly opposed 2
Opposed 2
Neutral 0
In favor 0
Strongly advocate 1
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 .