in reply to Apparent Inconsistencies in Perl Function Naming
Nat Torkington put in a proposal for Perl 6 that suggests that length(@array) be made to work properly instead of its bizarre current behavior, so you're certainly not the only person to have thought of this. I don't know whether Larry will decide to change it, however.
As for the slicing issue, it's tempting to ask that the positions in a string should be accessed by index as if the string were an array. You can do this in some other languages like C and Pascal where a string is an array. But it's hard to see how to arrange it in Perl, for syntactic reasons if nothing else. (Also, in Perl, a string is not an array.)
But if your suggestion were followed, it would still be inconsistent. @array[3..5] produces a list of three items. But presumably you want your string-slice to produce a single string, not a list. Then in your alternate universe, PawnPrince comes along and asks why the slice notation sometimes produces a list and sometimes an string, and why it isn't consistent. So it's not clear that there's any benefit from your suggestion anyway.
|
---|
Replies are listed 'Best First'. | |
---|---|
Re (tilly) 2 (expectations): Apparent Inconsistencies in Perl Function Naming
by tilly (Archbishop) on Nov 25, 2000 at 21:32 UTC | |
by swiftone (Curate) on Nov 28, 2000 at 02:31 UTC | |
by tilly (Archbishop) on Nov 28, 2000 at 03:10 UTC | |
Re: Re: Apparent Inconsistencies in Perl Function Naming
by kael (Monk) on Nov 26, 2000 at 02:11 UTC | |
by tilly (Archbishop) on Nov 26, 2000 at 03:53 UTC | |
by quidity (Pilgrim) on Nov 26, 2000 at 19:37 UTC | |
by kael (Monk) on Nov 27, 2000 at 05:44 UTC |