Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: AppleScript-Cocoa Impedance Mismatch



On Nov 1, 2007, at 5:41 PM, Major Domo wrote:

Also, when you have a fixed number of types, I would use an enumeration for the type rather than a string. It's clearer, prevents abuse and mistyping, and mentions the possible values automatically in the scripting dict.

So it turns out this is not actually possible. When you have both an enumerator named "book" and a class named "book," AppleScript interprets the word "book" as a class name and refuses to convert it into a constant. Thus, it seems, we can either have subclasses or have enumerated types, but not both. Hence, the use of strings.


Given time constraints, I think I'm going to have to abandon the subclasses and just have a single "medium" type, as unfortunate as that will be...

Mike, terminology conflicts can be a pain. If you search the archives you'll see past instances.


However, script writers are going to expect that your terminology to be meet certain expectations.

	make new media with properties {type: "book"}

just feels wrong, when it should in fact be

	make new book

Having an enumeration named book and a class named book can run you into trouble. (They have to use the same four character code, and even then in certain cases you'll get funky object specifiers, so it is best to be avoided.)

But do you even really need to have the book enumeration?

In the terminology if you have a media object, and a book object, the user should be able to access them specifically or generically (I realize this is the other question you asked) and as long as the objects specify them selves, use the class operator to determine what kind they are. In that case, having a type property of media which returns an enumerated value "book" is not necessary; and isn't the norm for how things work.

Jim

_______________________________________________
Do not post admin requests to the list. They will be ignored.
Applescript-implementors mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/applescript-implementors/email@hidden

This email sent to email@hidden
References: 
 >Re: AppleScript-Cocoa Impedance Mismatch (From: Major Domo <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.