Re: AppleScriptObjC oddity
Re: AppleScriptObjC oddity
- Subject: Re: AppleScriptObjC oddity
- From: Shane Stanley <email@hidden>
- Date: Mon, 13 Jul 2015 15:20:46 +1000
On 13 Jul 2015, at 2:44 pm, Chris Page <email@hidden> wrote:
Really. Don't do it. It's superfluous, and it conflicts with AppleScript semantics:
I can accept that it conflicts with AppleScript semantics, but I don't accept that it's superfluous -- to me, that implies it returns the same result, which it doesn't. I mean, compare these:
set x to (anNSString's |length|()) - 1 set x to ((anNSString's |length|) as integer) - 1
I guess I'm trying to get my head around where the danger is in the first version, other than stylistically. If you have an Objective-C method that returns a function, you won't be able to invoke it with "foo()".
Can you give an example of such a method? That this works is a complete surprise to me, as the saying goes.
Well I'm not sure it should be. If a method returns a value that has a fair AppleScript equivalent -- an Int, float, NSRect, BOOL, &c -- ASObjC has always returned an instance of the equivalent AppleScript class directly. That can't be happening by accident -- someone must have designed it that way. And if you call a property as a method -- and until relatively recently they were pretty much all methods anyway -- I can't see why you would expect it to behave differently.
I mean, I've been advising people to add the parens since ASObjC came out (when admittedly properties were rarer in Objective-C). I've seen other doing it too. And it's been done here in threads where members of the AppleScript team have been participants. So I guess I'm a bit shocked to hear this advice for the first time, roughly six years later.
|
_______________________________________________
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