At 04:32 PM 2/6/2001 -0200, Branden wrote:
>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.

It shouldn't. What $b should have is a *copy* of the data in $a, with the 
same overloading magic. Otherwise altering $a would alter $b, which isn't 
what you want.

>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...

Magic can only be attached to individual [SAHG]Vs. It can't be attached to 
whole classes of things. Now, all things of the same type have the same set 
of magic routines, but that's not the same thing. (And you can attach magic 
to the string "foo", though attaching magic to string constants requires 
doing some evil things...)

                                        Dan

--------------------------------------"it's like this"-------------------
Dan Sugalski                          even samurai
[EMAIL PROTECTED]                         have teddy bears and even
                                      teddy bears get drunk

Reply via email to