• 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: Records
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Records


  • Subject: Re: Records
  • From: Christopher Nebel <email@hidden>
  • Date: Thu, 3 Nov 2005 16:56:24 -0800

On Nov 3, 2005, at 3:02 PM, Mark J. Reed wrote:

On 11/3/05, Christopher Nebel <email@hidden> wrote:

The short version is that if the identifier consists entirely of lowercase letters, numbers, and underscores, *and* it doesn't match any application- or AppleScript-defined terminology (such as "file"), then the bars will be discarded. Long version, including why it works that way, available on request, but it's not really useful.

Never let it be said that I let a little thing like lack of utility get in the way of knowledge acquisition! :) I would be quite interested in the long version.


It seems like discarding the pipes runs the risk of the semantics of a script changing if it's decompiled and recompiled in an environment different from that in which it was originally written...

You might think so, but it doesn't. Well, it could, but only if you really worked at it. Here's the deal:


AppleScript variables (actually, identifiers in general) are case- insensitive: "this" is the same variable as "This" or "ThiS". When compiling, variable names are "canonified" by transforming all letters to lowercase -- this canonified name is then the key used to reference the variable, and the original name is stashed off to the side. What the vertical bars do is to (1) inform the parser that every character until the closing bar is part of a single identifier, so you can include spaces, punctuation, kanji, or what have you, but more importantly for this discussion, (2) they suppress the canonification step -- the key is the identifier exactly as you wrote it.

When it's time to decompile, AppleScript compares the key (the canonified name) to a re-canonification of the original name, also taking defined terminology into account. If they match, then it prints the original name. If they don't match, which is only possible if you originally wrote it using bars or if some new terminology showed up such as by adding a scripting addition, then it puts bars around the name. It doesn't actually remember whether you wrote it with bars or not; it effectively derives that information. However, if you |bar| a name that already matches the canonified form, then it winds up discarding the bars.

Getting back to the question of changing semantics, it generally works, and it works better than remembering whether or not bars were used at compile time, because decompilation uses the environment as it exists at decompilation time. You could manage to trick it by compiling a script, changing the environment, decompiling it (some identifier is assumed to lose its bars at this point), changing the environment back, and then recompiling the raw text from step 3. However, raw text scripts are already not guaranteed to be portable across environment changes, so that's not really an issue.


--Chris Nebel AppleScript and Automator Engineering

_______________________________________________
Do not post admin requests to the list. They will be ignored.
Applescript-users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


References: 
 >Re: Records (From: Christopher Nebel <email@hidden>)
 >Re: Records (From: "Mark J. Reed" <email@hidden>)

  • Prev by Date: Release notes for AS 1.10.3 (OS X 10.4.3)
  • Next by Date: Re: Records
  • Previous by thread: Re: Records
  • Next by thread: Re: Records
  • Index(es):
    • Date
    • Thread