Re: NSDate
Re: NSDate
- Subject: Re: NSDate
- From: has <email@hidden>
- Date: Fri, 5 Feb 2010 16:55:04 +0000
Shane Stanley wrote:
>> > Works for me in Script Editor (Mac OS X 10.6.2):
>
> Yes, it's fine in Script Editor and in applets, but it fails in an ASObC
> project. Coercions seem a bit pickier in ASObjC.
Technically, 'date x' is an object specifier, not a coercion. 'x as date' is a coercion, but fails because AppleScript doesn't have a built-in string-to-date coercion handler.
The problem with object specifiers is that they serve two roles in AppleScript: creating date, alias and file primitives, and constructing references. So when you say 'date x', what you're really saying is 'date x of <current container>', which is a reference.
Normally, AppleScript will figure out that what you're really after is a date object and resolve that temporary reference to give you a date object instead. However, there's something in the mechanics of ASOC that causes it to resolve specifiers very differently to vanilla AS.
The result of evaluating an object specifier in ASOC seems to be a raw AS «data...» object containing what I'm guessing is a pointer to an ASOC object which in turn provides a proxy to an actual Cocoa object. But it's hard to say exactly what's going on without a better understanding of ASOC's internal workings, and only the AS engineers know that.
BTW, the only reason 'date "..."' still works in ASOC is that the AS compiler treats date specifiers with a literal string as a special case, converting them to date objects at compilation time. Also, if you try evaluating 'date x' within a 'tell application...' block in vanilla AS, you'll run into problems there too. So it's not like caveats don't already exist.
Personally, I think the simplest solution would be for Apple to acknowledge the limitations of using alias/POSIX file/date specifiers in ASOC, and implement a string-to-date coercion handler (which they already ought to do anyway for consistency) to provide users an equivalent solution. I don't think it's essential that every single relatively minor AS behaviour works exactly the same in ASOC as in vanilla AS, as long as users are told what the gotchas and their solutions are. The most important thing is that the bridge itself is robust and capable, as that's the bit that's easiest to screw up by trying to be too clever.
HTH
has
--
Control AppleScriptable applications from Python, Ruby and ObjC:
http://appscript.sourceforge.net
_______________________________________________
Do not post admin requests to the list. They will be ignored.
applescriptobjc-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden