develooper Front page | perl.perl6.language | Postings from April 2005

Re: Question about list context for String.chars

Thread Previous | Thread Next
April 11, 2005 21:43
Re: Question about list context for String.chars
Message ID:
> > > However, I do like the idea of treating a string as an array of chars. I
> > > remember some discussion a while back about making [] on strings do
> > > something useful (but not the same thing as C<substr>), but I forget how
> > > it ended, and my brain is too fried to go hunt it down. But overall I
> > > like that idea. Then you could just say:
> > >
> > >     @array = $string[];
> >
> > This all sounds nice and simple. My only question then is what about
> > the instances where you specifically need the array of graphs, codes,
> > bytes, or whatever? If we can do one, why not all?
> That's why C<$string.chars[]> was proposed -- it would be accompanied
> by .graphs, .codes, and .bytes. That is all fine and dandy, but I
> don't think I should have to think about unicode if i don't want to.
> And if I understand correctly, that means that I want everything to
> use chars by default. And C<$string[]> would be a nice shortcut for
> that.

Yes, that's sort of what I was arguing for, in an underhanded way. I
agree that $string[] is a good shorthand for the most common usage
($string.chars[]) too.

Thread Previous | Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About