Dan Sugalski wrote:
> At 02:32 PM 2/6/2001 -0200, Branden wrote:
> >I noticed I couldn't get it to work. The thing is that $x = ... makes a
> >sv_setsv, what copies the value of the other SV (ST(0) in this case), but
> >not its magic, and other stuff. Here is the difference between `variable'
> >and `value'. In Perl5, at least, I could attach magic to a variable, but
not
> >to a value (AFAIK).
>
> No, you attach the magic to a value. Perl just doesn't copy magic when it
> copies data. Whether this is a good thing or not is up in the air. (Half
> the time I want it to, the other half I don't...)

My interpretation is that the `value' is what gets copied, so... But that's
ok...

In a certain way, overloading is a way to attach magic to a value, in Perl5.
I don't know how it's implemented, but if $a contains an object that has
overloaded behaviour, and I do $b = $a, $b will contain a pointer to the
same object, with the same overloaded behaviour. I think in Perl5, it's not
possible to attach magic behaviour to an individual object, but only to a
class of them, so it wouldn't be possible to attach magic to the string
"foo", for instance...

- Branden

Reply via email to