develooper Front page | perl.perl6.internals | Postings from July 2002

Re: Mutable vs immutable strings

Thread Previous | Thread Next
From:
Ashley Winters
Date:
July 10, 2002 15:46
Subject:
Re: Mutable vs immutable strings
Message ID:
200207101545.19845.qaqortog@nwlink.com
On Wednesday 10 July 2002 02:39 pm, Melvin Smith wrote:
>
> Since Perl vars type-morph themselves, Perl will use PMC types everywhere
> that there is an exposed interface. Internally you could use an I/S/N
> register.
>
> I see no reason why
>
> foreach my $i (@nums) {
>   ...
> }
>
> should not use an Ix reg for $i, but maybe $i isn't an int at all, or @nums
> is actually a mixed list.

I thought that was the whole point of typing in Perl 6.

my int @nums = (1, "2", 3.1);   # (1,2,3) assuming C<my int @foo> 'works'

for @nums -> $i {}      # $i is a PMC, still
for @nums -> int $i {}  # $i is in an Ix register now
for @nums {}            # will $_ be smart enough to 'int' itself? I hope so

Yes, people will have to think about optimizing their code. It's not great, 
but it's not that onerous. It might be nice if the current topic would type 
itself based on its initializer, when obvious.

Ashley Winters


Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About