• 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: Swift generics, circular type declarations, and segfaults, oh my!
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Swift generics, circular type declarations, and segfaults, oh my!


  • Subject: Re: Swift generics, circular type declarations, and segfaults, oh my!
  • From: has <email@hidden>
  • Date: Sun, 06 Sep 2015 18:25:34 +0100

On 05/09/2015 07:07, Charles Srstka wrote:
On Sep 4, 2015, at 7:59 PM, Quincey Morris <email@hidden <mailto:email@hidden>> wrote:

On Sep 4, 2015, at 16:31 , has <email@hidden <mailto:email@hidden>> wrote:

At risk of derail...

Do you mean “derail” or “detail”? I feel like I’m drowning in details.

Yeah, this is why I kept the original posts light on specifics. Obviously adding these details didn't help clarify at all - but see Charles' final paragraph below.


What I mean is, in:

TextEdit().documents[1].text.words.get()

the instances represented by ‘TextEdit()’, 'TextEdit().documents[1]’, 'TextEdit().documents[1].text’ are just setting the context for what the instance represented by 'TextEdit().documents[1].text.words’ is being asked to retrieve.


Basically. Each of those intermediates describes a valid query in itself; you just keep chaining var/method calls until you build up the query you actually want. Internally, it's just adding to a linked list of AE records (in pseudocode):

    [every word [text [document 1 [application "TextEdit"]]]]

The final 'get' command packs that query into a 'getdata' Apple event and sends it off to the app to evaluate. Kinda like sending XPath queries over XML-RPC.


The way I’m reading it, he or she is wrapping an application’s scripting dictionary, creating a Swift object to wrap each construct that would represent a noun, so to speak, in AppleScript. However, these entities are expensive to obtain, involving IPC, so s/he’s loading them lazily.

Nope (he). Apple event IPC isn't a proxy object-based system like DO; it's not OOP at all. (Dictionaries are a lie.) The AE bridge only models queries, not 'classes'. So I only need to define a few classes, one to represent each type of query: root node, one-to-one relationship, one-to-many relationship, insertion point.

What this means is that the objects are all going to have some number of properties that, when the user accesses them, will necessitate creating a new wrapper object.

Yes. And because some properties (vars) represent one-to-one relationships, others represent one-to-many, they need to instantiate different query classes: ObjectSpecifier/ElementsSpecifier. Which is why I can't just use Self - e.g. the ObjectSpecifier representing the 'text' property needs to return an ElementsSpecifier to represent the 'words' elements.


I’m not the most knowledgeable about AppleScript, but what it sounds like from s/he’s saying is that the relationships between the AppleScript objects fall into three main categories, and for each type of object, there will be only one specific class to which each of the three relationships can point, so the object should be representable by a Swift generic with three parameterized types. However, if an object points to more of the same type of object, this results in something like Foo<Foo>, and this causes either the compiler or the runtime to crash since it’s apparently not built to handle a generic being passed an object of its own type (honestly, this sounds like something warranting a Radar). S/he is asking if anyone knows of any way around this.

Yes! Exactly this. And yeah, I'm getting that sinking Radar feeling too. But since I'm relatively new to Swift, I'm just holding out a vain hope that there's some sort of solution that's embarrassingly obvious to everyone else but me.

Thanks,

has
_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden


  • Follow-Ups:
    • Re: Swift generics, circular type declarations, and segfaults, oh my!
      • From: Quincey Morris <email@hidden>
    • Re: Swift generics, circular type declarations, and segfaults, oh my!
      • From: Charles Srstka <email@hidden>
References: 
 >Swift generics, circular type declarations, and segfaults, oh my! (From: has <email@hidden>)
 >Re: Swift generics, circular type declarations, and segfaults, oh my! (From: Fritz Anderson <email@hidden>)
 >Re: Swift generics, circular type declarations, and segfaults, oh my! (From: has <email@hidden>)
 >Re: Swift generics, circular type declarations, and segfaults, oh my! (From: Quincey Morris <email@hidden>)
 >Re: Swift generics, circular type declarations, and segfaults, oh my! (From: has <email@hidden>)
 >Re: Swift generics, circular type declarations, and segfaults, oh my! (From: Quincey Morris <email@hidden>)
 >Re: Swift generics, circular type declarations, and segfaults, oh my! (From: Charles Srstka <email@hidden>)

  • Prev by Date: Getting started with Cocoa Bindings in My Project?
  • Next by Date: Re: "Computed segue" in iOS?
  • Previous by thread: Re: Swift generics, circular type declarations, and segfaults, oh my!
  • Next by thread: Re: Swift generics, circular type declarations, and segfaults, oh my!
  • Index(es):
    • Date
    • Thread