Re: Too few list items doesn't error [WAS: Re: String to multiple-item list coercion]
Re: Too few list items doesn't error [WAS: Re: String to multiple-item list coercion]
- Subject: Re: Too few list items doesn't error [WAS: Re: String to multiple-item list coercion]
- From: Steven Angier <email@hidden>
- Date: Sat, 21 Sep 2002 11:45:07 +1000
On 21/9/02 6:33 AM, "Paul Berkowitz" <email@hidden> wrote:
>
On 9/20/02 1:35 AM, "Steven Angier" <email@hidden> wrote:
>
>
> I may choose to live under a nice cosy rock, but I just learned that
>
> strings can be coerced to multiple-item lists:
>
>
>
> set {a, b, c, d, e} to "abcdefgh"
>
>
Side issue: this exposes a coercion that feels like a bug to me, but I
>
suppose is intentional.
>
>
set ls to {1, 2, 3, 4, 5, 6}
>
set {a, b, c, d, e} to items of ls
>
-- {1, 2, 3, 4, 5, 6}
>
>
No error that you were setting too few items to the list, unlike the
>
situation when you set too many:
>
>
set ls to {1, 2, 3, 4, 5, 6}
>
set {a, b, c, d, e, f, g} to items of ls
>
-- ERROR: Can't get item 7 of {1, 2, 3, 4, 5, 6}
>
>
>
This has real "gotcha" implications, since it also happens with text items
And I think that the same underlying AppleScript "bug" is also apparent in:
on open {theFile}
-- "theFile" being item 1 of the supplied file list
and in:
on DoSomething(param1)
return param1
end
DoSomething(1, 2, 3, 4, 5, 6, 7, 8)
--> 1 (no error!)
That's lots of head-scratching gotchas for newbies.
>
I would prefer that too few items set to a list errored the same way that
>
too many items does, instead of being coerced to a subset of the list.
I agree. One could argue for either behaviour (error or truncation), but its
the inconsistency that you mention that is the real problem.
Steven Angier
Macscript.com
_______________________________________________
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.