Terrence Brannon <brannon / lnc.usc.edu> wrote in message
news:lby9xqj7pp.fsf / lnc.usc.edu...
>
> 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?
>
> --
> Terrence Brannon
>

The trouble with this is trying to figure out why on earth an
array should be conceptually similar to a string. There is a major
ambiguity here in that you either can regard a string as a single
entity, i.e. $String in Perl syntax, or as an array of characters,
i.e. @String. C choses the later mapping, and thus loses the
ability to manipulate strings as first class entities. Perl lost the
ability to resolve the ambiguity when Larry decided to make
$X and @X different variables. In the case of strings, they
clearly should be the same variable, with $X treating the
string as an entity, and @X treating it as an array of characters.
That would get rid of some of the string processing functions.

But that's not the way Perl grew.

Or would you rather have the ability to refer to characters
in a string as if they were mapped into a hash? "1st" -> 1,
 "2nd" -> 2, etc. That would be really othogonal.

John Roth
>