Re: Since Apple Listens to this List...
Re: Since Apple Listens to this List...
- Subject: Re: Since Apple Listens to this List...
- From: John W Baxter <email@hidden>
- Date: Mon, 11 Feb 2002 20:29:44 -0800
At 1:57 -0800 2/11/2002, Paul Berkowitz wrote:
>
On 2/11/02 1:15 AM, "email@hidden" <email@hidden> wrote:
>
>
> I thought I'd say "I'd love to see a case statement included in a
>
>near-future
>
> revision"; it would be so much more elegant than If/else
>
>if/elseif/elseif/etc
>
>
>
I've heard people say that before. I don't see why it's any better, or even
>
any different. What's the difference? Can you keep referring back to the
>
same case numbers later in a script, even out of the same context structure?
>
If not, what's the advantage?
>
I've always thought it was mostly habit. Pascal's case could do a good bit
of optimizing (the implementations I used decided whether a testing cascade
or a lookup table better suited the particular instance, and compiled
accordingly: if the selectors were in a compact group, the cascade was
usually picked; if the selectors were "sparse"...as, say, several of Apple
Event Manager's four byte codes would be as selectors, then the lookup
table tended to be used).
C's ['switch'] is a cascade...little is gained except the ability to fall
through unintentionally to the next case, producing a broken program. [And
sometimes intentionally, which can be quite useful.]
Python doesn't have one. Perl (unless something has happened since the
mid-90s when we (the company) put Perl on the shelf in favor of Python,
doesn't have case/switch, but has some wild misuse of other constructs
which act like case/switch.
I use the thing if it's available (but not the Perl forms...I didn't train
myself to them), but don't mourn its absence when it's not present.
I don't think the gain would be sufficient in AppleScript to overcome the
"programmer vs scripter" issues (if given a Pascal-like implementation, I
might change my mind...there's room for speed improvements that way, as in
our recent month name discussions).
--John
--
John Baxter email@hidden Port Ludlow, WA, USA
_______________________________________________
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.