Re: Rogue list?
Re: Rogue list?
- Subject: Re: Rogue list?
- From: "Arthur J Knapp" <email@hidden>
- Date: Thu, 10 May 2001 11:33:35 -0400
>
Date: Wed, 9 May 2001 10:52:51 -0700
>
From: Chris Espinosa <email@hidden>
>
Subject: Re: Rogue list?
>
On Tuesday, May 8, 2001, at 06:09 PM, Arthur J Knapp
>
<email@hidden> wrote:
>
> set emptyRecord to run script "{+class usrf;:{}}"
>
Clever!
( did apple employee number 8 just call me clever ?!?! )
:)
>
Also, if you happen to use Script Debugger 2.0, you can obtain
>
> an empty record by asking for:
>
>
>
> set emptyRecord to user data of window 1
>
There are probably many applications that accidentally return an empty
>
record. There's really no reason to.
If some slight improvments were made to the way in which one worked with
AppleScript records, empty records could be useful and would pose no
problems for a scripter.
1) The literal notation for records would have to change, such that a
scripter who was examining her result window or log could tell the
difference between an empty record and an empty list: "{}". The
square brackets would be a good choice, except that AppleScript still
uses them for it's "legacy" linked-lists.
2) The class would have to return "record", obviously. Currently, an
empty record reports itself to be a list.
3) It would be nice to have a new reference form to test for labels,
something like:
if ( abc is label of myRecord ) then
or
if ( abc is property of myRecord ) then
The current method of determining if a label exists is to
error-trap, which isn't very elegent.
4) In my experiments with using record-concatentation with empty
records, I often end up crashing my script editor. This would
also have to be fixed/updated.
5) By far, the most often asked for improvement to AS's record class
is that they act more like "look up" lists, (hashes). At the very
least, it would be nice if record-to-list and list-to-record
coercion was possible:
set myList to {"a", 1, "b", 2, "c", 3, "x y z", 4}
set myRecord to myList as record
-- > {a: 1, b: 2, c: 3, |x y z|: 4}
set valueList to myRecord as list
-- > {1, 2, 3, 4}, current behavior
set myList to myRecord as coerced record -- something like this
-- > {"a", 1, "b", 2, "c", 3, "x y z", 4}
There are scripting additions that do this very thing, of course...
6) Finally, it would be nice to delete entries of a record.
Arthur J. Knapp
http://www.stellarvisions.com
mailto:email@hidden
Hey, check out:
http://www.AppleScriptSourceBook.com