[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

[ANN] New Ruby Implementation - RBXML

Brad Ediger

4/1/2008 10:01:00 PM

Ruby is a wonderful language, but its syntax has some shortcomings.
Inspired by Perl, the syntax of Ruby requires many special cases and
is difficult to parse by anything but a full Ruby interpreter. We seek
to fix this issue with a new, unambiguous syntax for Ruby: RBXML.

"Business Reporting and XML go hand in hand. I plan to convert Ruport
to RBXML as soon as I can!"
-- Gregory Brown, Ruby Reports maintainer

<http://www.bradediger.com/blog/2008/04/a_modest_syntax_proposal_...
>
<http://tinyurl.com/...

===========

Consider the following Ruby code. While it is certainly concise, it
achieves this goal through use of obscure symbols such as . and |.
This makes it difficult to read, and more importantly, difficult to
parse by machine.

class Integer
def factorial
(1..self).inject(1) {|p, x| p*x}
end
end

Rubyists talk a lot about metaprogramming, but how are you supposed to
introspect on a language like that? Some projects try to work around
these limitations by letting Ruby code introspect on itself; however,
the result can be unwieldy. Why reinvent the wheel when XML has been
around for years? Consider the much more regular and understandable
syntax in RBXML:

<class name="Integer">
<def name="factorial">
<method-call>
<name>inject</name>
<receiver>
<range exclude-end="false">
<start>
<integer>1</integer>
</start>
<end>self</end>
</range>
</receiver>
<argument>
<integer>1</integer>
</argument>
<block>
<parameter name="p" />
<parameter name="x" />
<code>
<method-call>
<name>*</name>
<receiver>p</receiver>
<argument>x</argument>
</method-call>
</code>
</block>
</method-call>
</def>
</class>

Just as languages in the Lisp family represent their parse trees with
s-expressions, this regular syntax represents the parse tree directly,
with only a small bit of XML parsing. Rubyists now have the advantage
of not having an extra layer of syntax between them and their concepts.

===========

To read more, visit:

<http://www.bradediger.com/blog/2008/04/a_modest_syntax_proposal_...
>
<http://tinyurl.com/...

===========

Brad Ediger
brad@bradediger.com