Re: iPhoto returns a real number as a photo id
Re: iPhoto returns a real number as a photo id
- Subject: Re: iPhoto returns a real number as a photo id
- From: Tommy Bollman <email@hidden>
- Date: Tue, 15 Jun 2010 01:09:56 +0200
On 14. juni 2010, at 21.25, Rob Lewis wrote:
>
>>
>>
>>> iPhoto's scripting dictionary says that the "id" property of a photo is an
>>> integer. Yet when you fetch it, it's returned as a real number. What is one
>>> supposed to do with that? Very odd IMO.
>>
>> It looks like they're stored as integers that are outside AS's integer
>> range, and so AS coerces them to reals. Let me ask, what can't you do with
>> them that you could if they were integers?
>
> Well, let's see: apart from the fact that it's damn strange to use a real number as an id number (or is it just me? In a long career, I can't recall ever seeing another instance of this), integers are much easier to read IMO, and more convenient to place in sorted lists.
>
> "every photo whose id is 4.943105932E+9" is just frickin' bizarre. And there's an "insecurity factor" because everyone knows that floating point numbers are very often not exact representations.
>
> Be honest now: if you were designing this, would you choose real as the type for your id numbers?
>>
>>
>>> Other Apple apps (e.g., Address Book) use 128-bit unique IDs, returned as a
>>> string of 32 hex digits, in the same format used by the "uuidgen" command line
>>> utility. These are guaranteed to be unique. I doubt that iPhoto makes any such
>>> guarantee, or at least I can't find any mention of it.
>>
>> Why would they not be unique?
>
> I don't know whether they would or wouldn't be: that's the problem. The id's returned by uuidgen, however, are guaranteed to be spatially and temporally unique. Other Apple apps use them; why not iPhoto? It is perhaps significant that the image property is named "id" and not "unique id" (as it is in some other apps I've seen).
>
> When you're talking about a world in which there are trillions of images out there that are at least potentially candidates for cataloging, this stuff matters.
>>
>> --
>> Shane Stanley <email@hidden>
>
> _______________________________________________
> Do not post admin requests to the list. They will be ignored.
> AppleScript-Users mailing list (email@hidden)
> Help/Unsubscribe/Update your Subscription:
> Archives: http://lists.apple.com/archives/applescript-users
>
> This email sent to email@hidden
What you have got might be class real because the number is represented in scientific notation. Probably to save space.
You will however not find any fraction in this oddly represented number, and that makes it a de facto integer.
It is not a real number, it is an integer that is stored in a variable of class real.
If you ask me of the wisdom of this design decision, then I suppose I have no good answers :).
Best regards
Tommy Bollman
--------------------------------------------------------------------------------------------------
Mollison's Bureaucracy Hypothesis:
If an idea can survive a bureaucratic review
and be implemented it wasn't worth doing.
_______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users
This email sent to email@hidden