• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: AppleScriptObjC oddity
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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.

-- 
Shane Stanley <email@hidden>
<www.macosxautomation.com/applescript/apps/>

 _______________________________________________
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

  • Follow-Ups:
    • Objective-C Properties (was Re: AppleScriptObjC oddity)
      • From: Chris Page <email@hidden>
References: 
 >Re: AppleScriptObjC oddity (From: Chris Page <email@hidden>)
 >Re: AppleScriptObjC oddity (From: Shane Stanley <email@hidden>)
 >Re: AppleScriptObjC oddity (From: Chris Page <email@hidden>)

  • Prev by Date: Re: AppleScriptObjC oddity
  • Next by Date: Objective-C Properties (was Re: AppleScriptObjC oddity)
  • Previous by thread: Re: AppleScriptObjC oddity
  • Next by thread: Objective-C Properties (was Re: AppleScriptObjC oddity)
  • Index(es):
    • Date
    • Thread