Submitted by itsme213 (Thu Mar 11 19:03:44 UTC 2004)
<li>unless unambiguous, all params in method def must be in parenthesis </li> <li>allow method name to be split before, between, and after parameters </li> <li>allow keyword params in any position </li> <li><code>self</code> is an optional distinguished parameter indicating position of receiver in method invocation</li>
Examples of method definitions:
<li>def at(i)put(v)</li>
<li>def at(i, put:)</li>
<li>def post (p1:, p2:)...</li>
<li>def if (self:, then:)...</li>
<li>def if(self)then(&block)
</li>
<li>def prefix (self:)...</li>
<li>def mix (self, post:)...</li>
<li>def mix (self) post (y)</li>
<li>def [ (index) ] = (value)</li>
Allow corresponding mix-fix invocations, parenthesis required only when otherwise ambiguous. Examples below correspond to method definitions above, and use R
as receiver
<li>R.at(i) put (5)</li>
<li>R.at(i, put: 5)</li>
<li>R.post (p1:1, p2:2)</li>
<li>if R then: proc</li>
<li>if R then {...}</li>
<li>prefix R</li>
<li>mix R post: y</li>
<li>mix R post y</li>
<li> R [ 5 ] = 0</li>
Two implementations of incremental grammar definition and parsing, both quite doable in Ruby, but I don't know current parser constraints:
Clases (e.g. in modules) can introduce custom mix-fix syntax. Module 'require' chains have corresponding grammar definition incrementally built up.
Ruby's current post-fix and pre-defined operators would be "built-in" by virtue of built-in library modules being required first.
Comments | Current voting | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
|
RCRchive copyright © David Alan Black, 2003-2005.
Powered by .
The two method defs with "self:" should instead be "self".
Although I admit this is an interesting idea, applying this to Ruby makes it different language. I really want to see a language designed with this idea, to prove (or disprove) this is good. But not in Ruby.
Ruby will stay Ruby, even in Ruby2 era.
--matz.