Re: number
Re: number
- Subject: Re: number
- From: kai <email@hidden>
- Date: Tue, 27 Sep 2005 00:18:43 +0100
On 26 Sep 2005, at 23:02, Nigel Garvey wrote:
Well. Just to argue the point. :-) Those don't look like "coercion
failures of reals" to me, but resolution failures of references.
No argument, Nigel. :-) I was merely referring to the error code for
number -1700 (errAECoercionFail).
In each case, the negation is applied to a reference form in the
script that
doesn't have an explicit or implied operator to get the value for
negation. Once there's an actual _value_, everything works properly
and
any necessary coercions are performed -- even when that value is
itself a
reference:
-(a reference to {x:1.2}'s x)
--> -1.2
set x to "1.2"
-(a reference to x's text)
--> -1.2
'a reference to' is a run-time operator that returns ("gets") a
value of
class reference, as opposed to some compiled script code.
The mystery for me is: why doesn't the "compiled reference" problem
apply
when the items referred to have whole-number values, even when those
values are in text form? And why are whole-number reals coerced to
integer?
Quite. I note that the behaviour is echoed (to an extent) when
performing negation on strings - without introducing a compiled
reference. OK, this works fine:
set x to "1.2"
-x
--> -1.2
But:
set x to "1.0"
-x
--> -1
Although an explicit coercion obviously produces the expected result:
-("1.0" as number)
--> -1.0
As a related aside, 'contents', although sometimes talked of as an
operator, is in fact a property (according to ASLG). So an expression
like 'contents of myRef' is itself a reference!
set myRef to a reference to {x:1.2}'s x
-(myRef) -- negate reference value
--> -1.2
-(contents of myRef) -- negate reference form in script
--> "Can't make 1.2 into type number."
And the behaviour persists even in nested "references":
-(a reference to (contents of (a reference to (contents of myRef))))
--> -1.2
(But each time the negation is applied directly to 'contents of...',
the statement errors.)
It's all too much for me (must be past my bedtime).
However, I appreciate your insightful analysis. Thanks. :-)
---
kai
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Applescript-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden
References: | |
| >Re: number (From: "Nigel Garvey" <email@hidden>) |