Re: Aliases in AppleScripts
Re: Aliases in AppleScripts
- Subject: Re: Aliases in AppleScripts
- From: Christopher Nebel <email@hidden>
- Date: Fri, 14 May 2004 22:01:18 -0700
On May 14, 2004, at 2:25 PM, Cliff Pruitt wrote:
Ultimately, however, it's not a good system. There are just too many
file types, and the differences between them are extremely subtle. I
actually have a cunning plan to get down to exactly one "file" type,
but it may or may not ever see the light of day, because it would
break
existing scripts that rely on the existence of and semantic
differences between "file", "file specification", "alias", and
"<<class furl>>".
I am, however, adamant that files should be considered objects in
their own right -- path strings are not files, and files are not path
strings. Maintaining this distinction is critical in at least some
places, AppleScript syntax being what it is. Consider the difference
in meaning:
length of "Some:string:that:looks:like:a:path"
length of file "Macintosh HD:Users:me:Documents:something clever"
Once you're required to make the distinction in some places, I
maintain that AppleScript should be consistent and require it
everywhere.
Why couldn't the names of the old file types be synonymous with the
new file type for several versions allowing legacy scripts to continue
unbroken?
Nice idea, but it wouldn't work, at least not completely. You could
make "alias" and "file specification" synonyms for "file", which would
solve the existence problem, but there are still the semantic
differences to consider. For example, you currently can't make an
"alias" object to a file that doesn't exist -- some scripts exploit
this to test for the existence of files without using the Finder. If
the One True File class *does* allow that, which it more or less has
to, then those scripts break.
[I]t seems like AppleScript can't decide what type of... Path(?) it
wants to use as far as display. It seems like if I reference
something manually I need to use mac styled delimiters (:) but if I
drop something on, say a AS Studio drop zone, it returns a POSIX path.
Maybe my example is backward or maybe its just altogether off, but
I'm a little confused about what type of path syntax AS expects to be
working with. Is there a hard & fast distinction between using POSIX
& Mac Paths & switching between them?
This is part of the problem, but a relatively small one, I think. HFS-
and POSIX-style paths are simply different ways of expressing the same
thing. Neither is really superior, and if you have one, you can
generate the other. Which path style to use depends on who you're
talking to -- traditional AppleScript parts typically use HFS-style;
Studio tends to use POSIX-style because of its Cocoa base. Remember
that AppleScript the language doesn't impose any path rules on
applications -- an application could use MS-DOS paths if it really felt
like it. However, consistency is valuable, which is why the Scripting
Interface Guidelines exist, and in particular is why they talk about
treating files as objects, not paths. (One of the reasons I'm fond of
Finder-style file specifiers is that they side-step the path style
issue. Of course, they have the problems of being verbose and
backwards.)
I'd love to see some AS documentation broken down a little more into
real world examples or "situational" topics. ... [s]omething that lets
me look up documentation by finding something close to what I'm trying
to do, at the moment. ... Of course its entirely possible that the AS
documentation is just fine & I'm just dumb. One never knows for
sure... :-)
This is an entirely separate problem, but it's a good one. The
existing AppleScript documentation from Apple is structured primarily
as a reference, not as a tutorial, and simply doesn't have the
task-oriented information you're asking for. While I'd love to have
better documentation (and more styles of it) from Apple, it's also a
perfectly valid third-party opportunity; there's no reason a more
tutorial-ish book has to come from Apple.
--Chris Nebel
AppleScript Engineering
_______________________________________________
applescript-users mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/applescript-users
Do not post admin requests to the list. They will be ignored.