develooper Front page | perl.perl5.porters | Postings from November 1999

Re: assignment overload [Was: [ID 19991101.002] Data::Dumper 2.101 and

Thread Previous
From:
Ilya Zakharevich
Date:
November 10, 1999 19:01
Subject:
Re: assignment overload [Was: [ID 19991101.002] Data::Dumper 2.101 and
Message ID:
19991110220133.B9796@monk.mps.ohio-state.edu
On Wed, Nov 10, 1999 at 09:30:51PM -0500, John Macdonald wrote:
> || Without being able to overload assignment, you can build an
> || object that drives completely like a scalar with one subtle 
> || yet frequently encountered exception: assignment is shallow.
> 
> But what is the meaning of overloaded assignment?  In
> particular, how do you distinguish between assigning a
> new value to an object of a particular type from assigning
> a typed value to a variable (thereby changing the type of
> the variable)?  When you write:
> 
>     my $x = 1;        # $x has an integer value
>     $x = 'abc';       # now it has a string value
> 
> you don't expect the second assignment to be affected by the
> previous contents of $x.  The old contents are simply replaced
> with the new contents *and its type*.

> Overloading assignment only makes sense in a strongly typed
> language.

Which Perl became now (at least enough to make overloading assignment
easy).  See `PREPARE' thread.

Ilya

Thread Previous


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