Re: Coerce string to string!?
Re: Coerce string to string!?
- Subject: Re: Coerce string to string!?
- From: JJ <email@hidden>
- Date: Thu, 14 Feb 2002 20:37:47 +0100
>
On 2/14/02 6:14 AM, "has" <email@hidden> wrote:
>
>
> Paul Berkowitz wrote:
>
>
>
>>> class of i
>
>>> --> string (OK)
>
>>
>
>> That evaluates 'item 1 of {"String"}' to "String" before it gets its class.
>
>
>
> [and]
>
>
>
>> i is a reference ('item 1 of {"String"}'), whereas Original_String is
>
>> the string "String" itself. Not the same thing. The equals operator '=' is
>
>> extremely particular about such things, whereas other operators such as
>
>> 'contains' are happy to evaluate the reference as they go along.
>
>
>
> i.e. It does one thing in one case and something else in another,
>
> confounding user expectations every time. (Is there anyone who hasn't been
>
> horribly confused by this one at some point?) References are so damn
>
> schizophrenic in behaviour- definitely not AppleScript's finest moment.
>
>
I agree. I wonder what the rationale or justification for that was meant to
>
be. I imagine it must have been decided that one single tool - the 'equals'
>
operator - had to be kept 'pure' for such situations as when one truly
>
needed to discriminate between reference and object, but that all others
>
(well almost all others) could be coerced in a user-friendly, "English-like"
>
fashion. It certainly is confusing when such inconsistencies are allowed to
>
rule.
>
So, what are the real benefits of working with a 'reference' to a object (a
instance) and, how can I know when I'm working with a reference
In this script, I KNOW I'm doing it:
set x to {"String"}
set y to a reference to x's item 1
But in the past example (repeat), I didn't know:
set x to {"String"}
repeat with i in x
i -- a reference to x's item 1, NOT "String" itself
end repeat
Why does this (undesired-unknown) reference inherits all properties of the
referenced object?
I would like this:
class of i -- object reference
contents of i -- "String"
class of i's original object -- string
I. e., in Quark, an "object reference" is "certain info about a object, but
not the object itself".
JJ
_______________________________________________
applescript-users mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/applescript-users
Do not post admin requests to the list. They will be ignored.