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:
<li>Method</li> <li>Parameter</li> <li>Constant</li>
Generalize class facilities like attr
(in the same spirit as SAX events) by doing the following:
<li> Expose classes for as many syntactic elements as possible: Method, Parameter, Constant, perhaps even more fine grained such as LocalVariable, InstanceVaeiable, Block, Expression. </li> <li> Allow these classes to be extended with new methods (of course).</li> <li> Ensure that <code>self</code> is bound to the smallest, most current object in as many places as possible in the grammer e.g.: <ul> <li><code>def foo ** (a *** ...)</code></li> <li>at **, self is Method foo</li> <li>at ***, self is Param a</li> </ul> </li>
Comments | Current voting | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
|
RCRchive copyright © David Alan Black, 2003-2005.
Powered by .
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.:
And so on, as needed. -- Austin Ziegler
This RCR is breaking a few RCR rules:
Please resubmit it, if you really want to propose something.
--matz.