Re: How do you check the equivalency of references?
Re: How do you check the equivalency of references?
- Subject: Re: How do you check the equivalency of references?
- From: Nigel Garvey <email@hidden>
- Date: Sat, 11 Aug 2001 01:37:16 +0100
John W Baxter wrote on Fri, 10 Aug 2001 15:49:48 -0700:
>
At 17:52 -0400 8/10/2001, Arthur J Knapp wrote:
>
>> Subject: Re: How do you check the equivalency of references?
>
>> Date: Fri, 10 Aug 2001 14:29:38 +0100
>
>> From: Nigel Garvey <email@hidden>
>
>
>
>> on isRef(val)
>
>> try
>
>> contents of val
>
>> return (result is not val)
>
>> on error
>
>> return false
>
>> end try
>
>> end isRef
>
>
>
> There is another way to determine references:
>
>
>
> count of references in {v} = 1
Looks good!
>
> Richard 23 once pointed out to me a very good reason why the
>
>"contents of" method is better, though I can't recall what it was.
I'll have to try a few things tomorrow morning. Maybe someone in a
different time zone will discover the reason before then. One difference
between the methods is that my handler returns 'false' for a Finder
reference whereas the list method returns 'true'. Which is better depends
on what you want, I suppose.
>
Perhaps it has something to do with
>
>
set v to a reference to 5
>
>
(count of references in {v}) = 1
>
>
--> false
5 is a value rather than a variable. Setting references to values seems
always to return the value itself:
set v to a reference to 5
--> 5
Whereas:
set v to 5
set r to a reference to v
--> v of <<script>>
{r}'s references is not {}
--> true
NG