On Fri, May 12, 2006 at 11:27:29AM +0900, corey konrad wrote:
> how about this cin>> = num, lol i dont know ruby seems like a trade off 
> to me so far. i am just trying to understand all this hype about it. I 
> mean every book i am reading says its the best most awesome easiest to 
> use, just like using natural language, its elegant and beautiful and it 
> will make you cry because its so easy to use, etc etc. I am having a 
> hard time understanding that. If its true i would like to see it at some 
> point.
> 

Well, having to explicitly convert between strings and integers in most
cases is a concious design decision. I do still forget about it sometimes
but luckily, the exceptions make the error easy to find. 


Look at it another way:

In perl, you can do this:

"200" + 1  -> 201	(+ = addition operator, forces numerical context)
"200" . 1  -> 2001	(. = string append operator, forces string context)

but in ruby you only have the + operator, so in principle the result of

"200" + 1 

and

200 + "1"

could be either 201 or 2001. And I'd sort of expect both cases to give
the same result. In any case, this stuff can lead to really confusing
results.

Personally, I think the way Perl handles this sort of thing is easier
for straight forward text manipulation, BUT since Perl depends on the
operator to determine the type of conversion the number of operators
is fairly large, and it becomes seriously unwieldy if you introduce
more types than simple strings and numbers. See for example the perl
table of operators for perl 6 (still under development): 
http://www.ozonehouse.com/mark/blog/code/PeriodicTable.html

Joost.