If you want to find out if two variables are bound to the same data, there
is an operator for that

    my $a = 3;
    my $b = 3;
    say $a =:= $b; # False

    my $c := $b;
    say $b =:= $c; # True

On Wed, Feb 12, 2020 at 7:27 AM Aureliano Guedes <guedes.aureli...@gmail.com>
wrote:

> Thank you.
>
> So, I'd like to find a way to test if two variables are bound or not,
> especially concerning their memory address.
>
> If the address is not fixed for a lifetime, I must be able to test it in
> just one cycle.
> > $a.WHERE == $b.WHERE   # I expected FALSE
> True
>
> To a bound variable, I expect the same address, but to an unbounded
> variable, this garbage collector behavior seams assing to the same memory
> location two unbounded variables with the same value. It is right? Must
> reduce memory usage but is a quiet weirdo.
>
> On Wed, Feb 12, 2020 at 10:13 AM Elizabeth Mattijsen <l...@dijkmat.nl>
> wrote:
>
>>
>>
>> > On 12 Feb 2020, at 13:44, Aureliano Guedes <guedes.aureli...@gmail.com>
>> wrote:
>> >
>> > What "WHERE" should return?
>> >
>> > I was trying to find a method to return the memory address of some data.
>> > Then I find the WHERE statement.
>> > https://rosettacode.org/wiki/Address_of_a_variable#Perl_6
>> > https://docs.perl6.org/language/mop#WHERE
>>
>> Please note that the memory address is *NOT* fixed for the lifetime of an
>> object.  Garbage collection may move it to another memory location at *any*
>> time.  I've therefore adapted the documentation of .WHERE to:
>>
>> Returns an C<Int> representing the memory address of the object.  Please
>> note
>> that in the Rakudo implementation of Raku, and possibly other
>> implementations,
>> the memory location of an object is B<NOT> fixed for the lifetime of the
>> object.  So it has limited use for applications, and is intended as a
>> debugging
>> tool only.
>>
>> https://github.com/Raku/doc/commit/3e6270d197
>
>
>
> --
> Aureliano Guedes
> skype: aureliano.guedes
> contato:  (11) 94292-6110
> whatsapp +5511942926110
>

Reply via email to