<?xml version="1.0" encoding="UTF-8"?><!-- generator="wordpress/2.1.2" -->
<rss version="2.0" 
	xmlns:content="http://purl.org/rss/1.0/modules/content/">
<channel>
	<title>Comments on: Oh Ruby, who are you trying to fool?</title>
	<link>http://www.rubyfleebie.com/oh-ruby-who-are-you-trying-to-fool/</link>
	<description>Because programming should be fun</description>
	<pubDate>Sat, 22 Nov 2008 08:09:46 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.1.2</generator>

	<item>
		<title>By: jc</title>
		<link>http://www.rubyfleebie.com/oh-ruby-who-are-you-trying-to-fool/#comment-15</link>
		<author>jc</author>
		<pubDate>Fri, 23 Mar 2007 17:11:46 +0000</pubDate>
		<guid>http://www.rubyfleebie.com/oh-ruby-who-are-you-trying-to-fool/#comment-15</guid>
					<description>I don't think this is entirely true.

When you run: "5*8+5" in IRB, it correctly returns 45. If what you say is true, it would be the equivalent of: 5.*(8.+(5)). The inner method would be called first, returning 13, and the outer method would evaluate to 13*5=65. 

So there must be some ruby language magic doing the order of operation rules.</description>
		<content:encoded><![CDATA[<p>I don&#8217;t think this is entirely true.</p>
<p>When you run: &#8220;5*8+5&#8243; in IRB, it correctly returns 45. If what you say is true, it would be the equivalent of: 5.*(8.+(5)). The inner method would be called first, returning 13, and the outer method would evaluate to 13*5=65. </p>
<p>So there must be some ruby language magic doing the order of operation rules.</p>
]]></content:encoded>
				</item>
	<item>
		<title>By: Frank</title>
		<link>http://www.rubyfleebie.com/oh-ruby-who-are-you-trying-to-fool/#comment-16</link>
		<author>Frank</author>
		<pubDate>Fri, 23 Mar 2007 17:37:57 +0000</pubDate>
		<guid>http://www.rubyfleebie.com/oh-ruby-who-are-you-trying-to-fool/#comment-16</guid>
					<description>jc,

5*8+5 is the same as 5.*(8).+(5) which also correctly gives 45 in IRB.

But I understand what you mean. It's true that ruby must check for the precedence of operators to correctly evaluate an arithmetic expression. So when you write : 5+8*5 , it gets transformed to 5.+((8).*(5)) instead of 5.+(8).*(5)</description>
		<content:encoded><![CDATA[<p>jc,</p>
<p>5*8+5 is the same as 5.*(8).+(5) which also correctly gives 45 in IRB.</p>
<p>But I understand what you mean. It&#8217;s true that ruby must check for the precedence of operators to correctly evaluate an arithmetic expression. So when you write : 5+8*5 , it gets transformed to 5.+((8).*(5)) instead of 5.+(8).*(5)</p>
]]></content:encoded>
				</item>
	<item>
		<title>By: Jörg W Mittag</title>
		<link>http://www.rubyfleebie.com/oh-ruby-who-are-you-trying-to-fool/#comment-22</link>
		<author>Jörg W Mittag</author>
		<pubDate>Mon, 26 Mar 2007 13:27:19 +0000</pubDate>
		<guid>http://www.rubyfleebie.com/oh-ruby-who-are-you-trying-to-fool/#comment-22</guid>
					<description>There's a slightly more well-known example for this: the assignment operator.  In Ruby, attributes are *always* private; there is *no way* to access them from the outside.  (Well, I suppose you can do some meta-programming or eval'ing.)  "But wait!", I here you say, "I *can* do something like 'foo.bar = 42', can't I?".  Yes, you can, but(!) that's not an assignment (cue Henri Matisse pipe here), it's a message send.  Ruby sneakily transforms 

foo.bar = 42

into 

foo.bar=(42)

(Note: the equals sign is part of the message name, just like a question mark or exclamation point.)

jwm</description>
		<content:encoded><![CDATA[<p>There&#8217;s a slightly more well-known example for this: the assignment operator.  In Ruby, attributes are *always* private; there is *no way* to access them from the outside.  (Well, I suppose you can do some meta-programming or eval&#8217;ing.)  &#8220;But wait!&#8221;, I here you say, &#8220;I *can* do something like &#8216;foo.bar = 42&#8242;, can&#8217;t I?&#8221;.  Yes, you can, but(!) that&#8217;s not an assignment (cue Henri Matisse pipe here), it&#8217;s a message send.  Ruby sneakily transforms </p>
<p>foo.bar = 42</p>
<p>into </p>
<p>foo.bar=(42)</p>
<p>(Note: the equals sign is part of the message name, just like a question mark or exclamation point.)</p>
<p>jwm</p>
]]></content:encoded>
				</item>
	<item>
		<title>By: Joseph Wright</title>
		<link>http://www.rubyfleebie.com/oh-ruby-who-are-you-trying-to-fool/#comment-23</link>
		<author>Joseph Wright</author>
		<pubDate>Mon, 26 Mar 2007 16:05:16 +0000</pubDate>
		<guid>http://www.rubyfleebie.com/oh-ruby-who-are-you-trying-to-fool/#comment-23</guid>
					<description>&#62; ...In every single languages that I know the existence,
&#62; every arithmetic, bitwise and conditional operators
&#62; are built-in and global keywords. 

You should learn more languages then. Smalltalk, which Ruby copies in many ways, does the same thing, treating *everything* as an object.  When you define a method, it can either be infix (also called binary), which allows for e.g. '5  + 5', where '+' is the method; unary, which has just one argument, or keyword, which looks like 'methodName Arg1: Arg2:', which you might call like 'methodName Arg1: [ code block for example] Arg2: otherarg'.  I don't know how Ruby implements this, I think there is some magic that goes on inside, like you say.

On a related note, in the "Bring your methods to life with punctuation" post, you say:
&#62; I think ruby is the only language that allows a
&#62; programmer to name his method logged? for example.

Not at all. Common Lisp and Scheme allow quite a few different characters, Haskell allows ' in its variable names, and I'm sure there are others, though none of them spring immediately to mind.</description>
		<content:encoded><![CDATA[<p>&gt; &#8230;In every single languages that I know the existence,<br />
&gt; every arithmetic, bitwise and conditional operators<br />
&gt; are built-in and global keywords. </p>
<p>You should learn more languages then. Smalltalk, which Ruby copies in many ways, does the same thing, treating *everything* as an object.  When you define a method, it can either be infix (also called binary), which allows for e.g. &#8216;5  + 5&#8242;, where &#8216;+&#8217; is the method; unary, which has just one argument, or keyword, which looks like &#8216;methodName Arg1: Arg2:&#8217;, which you might call like &#8216;methodName Arg1: [ code block for example] Arg2: otherarg&#8217;.  I don&#8217;t know how Ruby implements this, I think there is some magic that goes on inside, like you say.</p>
<p>On a related note, in the &#8220;Bring your methods to life with punctuation&#8221; post, you say:<br />
&gt; I think ruby is the only language that allows a<br />
&gt; programmer to name his method logged? for example.</p>
<p>Not at all. Common Lisp and Scheme allow quite a few different characters, Haskell allows &#8216; in its variable names, and I&#8217;m sure there are others, though none of them spring immediately to mind.</p>
]]></content:encoded>
				</item>
	<item>
		<title>By: Augusto</title>
		<link>http://www.rubyfleebie.com/oh-ruby-who-are-you-trying-to-fool/#comment-24</link>
		<author>Augusto</author>
		<pubDate>Mon, 26 Mar 2007 16:10:26 +0000</pubDate>
		<guid>http://www.rubyfleebie.com/oh-ruby-who-are-you-trying-to-fool/#comment-24</guid>
					<description>This would be more impressive, if the method declaration would have some way of specifying operator precedence. As it stands, it's bizarre, it's consistent because the operators are really methods but they are treated as a special case ... well because they have to be.

Is there some type of well documented language spec for Ruby were these things are clearly specified (operator precedence?)</description>
		<content:encoded><![CDATA[<p>This would be more impressive, if the method declaration would have some way of specifying operator precedence. As it stands, it&#8217;s bizarre, it&#8217;s consistent because the operators are really methods but they are treated as a special case &#8230; well because they have to be.</p>
<p>Is there some type of well documented language spec for Ruby were these things are clearly specified (operator precedence?)</p>
]]></content:encoded>
				</item>
	<item>
		<title>By: Frank</title>
		<link>http://www.rubyfleebie.com/oh-ruby-who-are-you-trying-to-fool/#comment-25</link>
		<author>Frank</author>
		<pubDate>Mon, 26 Mar 2007 16:34:25 +0000</pubDate>
		<guid>http://www.rubyfleebie.com/oh-ruby-who-are-you-trying-to-fool/#comment-25</guid>
					<description>Jörg, 

It's funny because what you are talking about is exactly the subject of my next article. It's all written already. I just have to publish it tonight. I hope you'll enjoy it. I would really appreciate your comments on it.

Augusto, That's a good question. I really don't know if there's some official documentation about that. Anyone knows?</description>
		<content:encoded><![CDATA[<p>Jörg, </p>
<p>It&#8217;s funny because what you are talking about is exactly the subject of my next article. It&#8217;s all written already. I just have to publish it tonight. I hope you&#8217;ll enjoy it. I would really appreciate your comments on it.</p>
<p>Augusto, That&#8217;s a good question. I really don&#8217;t know if there&#8217;s some official documentation about that. Anyone knows?</p>
]]></content:encoded>
				</item>
	<item>
		<title>By: Frank</title>
		<link>http://www.rubyfleebie.com/oh-ruby-who-are-you-trying-to-fool/#comment-26</link>
		<author>Frank</author>
		<pubDate>Mon, 26 Mar 2007 17:15:20 +0000</pubDate>
		<guid>http://www.rubyfleebie.com/oh-ruby-who-are-you-trying-to-fool/#comment-26</guid>
					<description>I decided to publish the post about ruby assignments right now, just in case you are interested. (it's on the home page)</description>
		<content:encoded><![CDATA[<p>I decided to publish the post about ruby assignments right now, just in case you are interested. (it&#8217;s on the home page)</p>
]]></content:encoded>
				</item>
	<item>
		<title>By: Jörg W Mittag</title>
		<link>http://www.rubyfleebie.com/oh-ruby-who-are-you-trying-to-fool/#comment-31</link>
		<author>Jörg W Mittag</author>
		<pubDate>Mon, 26 Mar 2007 21:25:45 +0000</pubDate>
		<guid>http://www.rubyfleebie.com/oh-ruby-who-are-you-trying-to-fool/#comment-31</guid>
					<description>I had actually started cooking up some code examples very similar to yours but figured they would be unreadable in the comments section anyway, without that nice syntax highlighting.  Saved me some duplicate work (-;

jwm</description>
		<content:encoded><![CDATA[<p>I had actually started cooking up some code examples very similar to yours but figured they would be unreadable in the comments section anyway, without that nice syntax highlighting.  Saved me some duplicate work (-;</p>
<p>jwm</p>
]]></content:encoded>
				</item>
	<item>
		<title>By: Frank</title>
		<link>http://www.rubyfleebie.com/oh-ruby-who-are-you-trying-to-fool/#comment-39</link>
		<author>Frank</author>
		<pubDate>Thu, 29 Mar 2007 20:37:57 +0000</pubDate>
		<guid>http://www.rubyfleebie.com/oh-ruby-who-are-you-trying-to-fool/#comment-39</guid>
					<description>Jörg, yeah it would have been nice if the syntax highlighter was active in the comments as well. (it might had been a little heavy on javascript though... =) )

Joseph, thanks for the info about smalltalk having the same possibility. I have updated the original post.</description>
		<content:encoded><![CDATA[<p>Jörg, yeah it would have been nice if the syntax highlighter was active in the comments as well. (it might had been a little heavy on javascript though&#8230; =) )</p>
<p>Joseph, thanks for the info about smalltalk having the same possibility. I have updated the original post.</p>
]]></content:encoded>
				</item>
</channel>
</rss>
