From: Mike Stok Date: 2002-09-11T01:34:36+09:00 Subject: Re: Larry Wall's comments on Ruby In article <20020910121025.E20993@atdesk.com>, Paul Brannan wrote: >> But then what would Ruby use for method calls on strings? Honestly, I >> don't think this can be cited as an example of an incorrect choice in >> Ruby. > > Ruby could use a different operator, which is what I've read that perl6 > will do, since it is also going to be using "." for method calls. > > I think "+" is more natural to me for concatenation than "*" or "/", and > I would expect that even a Perl programmer would agree. As for "+" vs. > "." or "_" or "~", I feel at home with "+" because of my experience with > BASIC. The fact that it has an overloaded meaning doesn't bother me, > since I'm used to having symbols with overloaded meaning in mathematics > (sigma, for example, can indicate standard deviation or 2-D density; it > just depends on the context). Perl might not have used . for string concatenation were it not for the number/string morphing nature of perl scalars. In Ruby a variable's type tells us what it is, in Perl the operators provide context as to what a scalar ought to be viewed as, and this is why they need an "extra" set of comparison operators e.g. # perl $a = '123 '; $b = 45; # $a + $b => 168 # $a . $b => '123 45' # $a > $b => 1 # $a gt $b => a false value I prefer the explicitness of ruby (requiring .to_?), and its overloading of + isn't too surprising e.g. 2 + 2 => 4 "123 " + "45" => "123 45" [1,2,3] + [4,5] => [1, 2, 3, 4, 5] Mike -- mike@stok.co.uk | The "`Stok' disclaimers" apply. http://www.stok.co.uk/~mike/ | GPG PGP Key 1024D/059913DA mike@exegenix.com | Fingerprint 0570 71CD 6790 7C28 3D60 http://www.exegenix.com/ | 75D2 9EC4 C1C0 0599 13DA