develooper Front page | perl.perl6.language | Postings from August 2006

Re: ===, =:=, ~~, eq and == revisited (blame ajs!) -- Explained

Thread Previous | Thread Next
August 15, 2006 07:36
Re: ===, =:=, ~~, eq and == revisited (blame ajs!) -- Explained
Message ID:
David Green writes:

> I guess my problem is that [1,2] *feels* like it should === [1,2].
> You can explain that there's this mutable object stuff going on, and I
> can follow that (sort of...), but it seems like an implementation
> detail leaking out.

The currently defined behaviour seems intuitive to me, from a starting
point of Perl 5.  The difference between:

  my $new = \@orig;


  my $new = [@orig];

is that the second one is a copy; square brackets always create a new
anonymous array rather than merely refering to an existing one, and
that's the same thing that's happening here.  Think of square brackets
as meaning something like Array->new and each one is obviously distinct.

> And I feel this way because [1,2] looks like it should be platonically
> unique.

I'd say that C< (1, 2) > looks like that.  But C< [1, 2] > looks like
it's its own thing that won't be equal to another one.


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