From: Dave Cross Date: 2000-12-09T18:40:01+09:00 Subject: [ruby-talk:6960] Re: Why isn't Perl highly orthogonal? On Sat, 09 Dec 2000 08:54:13 GMT, Terrence Brannon wrote: > >One day my boss asked me: "how do you get the length of an array in >Perl?" So I told him: > >scalar @array; > >But of course what irked me is how unintuitive and irregular Perl is >and how this forced my boss to ask me something like that. > >LENGTH $string => length $string >LENGTH @array => scalar @array > >PORTION $string => substring $string, $offset, $length >PORTION @array => @array[$offset..$offset+$length] > >In other words, conceptually similar operations do not map to the same >name in Perl. Why does this make Perl a better and not worse language, >than the intended replacement to Perl, Ruby, which is in fact highly >regular in all places where Perl isn't, with the above being just a >few examples? The length of a string and the number of elemetns in an array really aren't the same thing at all, so it makes sense to me that I find them in different ways. The same goes for substrings and array slices. Thinking of these concepts as similar seems to meto be a hangover from C, where strings are arrays of characters, but surely we've moved on since then. Maybe your boss is a C programmer? Dave... -- SMS: sms@dave.org.uk