Re: Checking on the existence of a file
Re: Checking on the existence of a file
- Subject: Re: Checking on the existence of a file
- From: Harald E Brandt <email@hidden>
- Date: Tue, 04 Dec 2012 15:59:19 +0100
On 4 dec 2012, at 12:24, Shane Stanley <email@hidden> wrote:
> I think leaving off the parentheses is roughly equivalent to using key-value coding -- like using 'valueForKey_("isAbsolutePath")' or 'valueForKey_("absolutePath")'. But again, that doesn't explain the class difference.
Ahaa! I had the feeling it was somehow accessing a property or instance variable when I omitted the parentheses -- when I timed them the version without parentheses actually ran a couple of microseconds faster, to my surprise. (But actually executing 'valueForKey_("isAbsolutePath")' or 'valueForKey_("absolutePath")' is a bit slower than 'isAbsolutePath()').
But I doubt the syntax of omitted parentheses is a "sanctioned" syntax.
I have regarded it as just "sloppy Harald-syntax" that just happened to work:-) (... and for which I could be punished in the future...)
And, as the following shows, don't leave those parentheses out:
If I time the different variants in my timer with a 1000-iteration loop, the version with parentheses (isAbsolutePath()) will run at a steady 45 microseconds per iteration, the KVO method (valueForKey_("isAbsolutePath")) will run at a steady 65 microseconds, whereas the version without parentheses (isAbsolutePath) will start off at only 35 microseconds per iteration, but each time I run the loop the time will increase, and after a few runs AppleScriptObjC Explorer 2 will choke and fail with "*** -[ASRunner newPerformer:]: Internal table overflow. (error -2707)". And any new attempt to run will give me "Error compiling script". It must be restarted.
So, in essence: don't leave those parentheses out -- it's probably not actually supported, and there will be some leakage somewhere!
> If it is a KVO thing, be careful what you wish for...
Absolutely! if it is KVO, I will immediately stop wishing for a ban!
(But I could still wish for a bit more consistency in ASObjC, more like the consistency of pure ObjC. And of course, no memory leakage!)
--heb
_______________________________________________
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