Re: functions as sort of first class objects
Re: functions as sort of first class objects
- Subject: Re: functions as sort of first class objects
- From: Axel Luttgens <email@hidden>
- Date: Tue, 24 May 2016 16:44:49 +0200
> Le 24 mai 2016 à 06:20, Mitchell L Model a écrit :
>
> I was experimenting today and got the following confusing results:
> ---------------------------------------------
> to a()
> display alert "A"
> end a
>
> to b()
> display alert "B"
> end b
>
> my a() — works, of course
>
> set c to my b — works!
> c() — calls b!! (as I was hoping it would)
>
> repeat with h in {my a, my b}
> h() — error :-(
> delay 1
> end repeat
> ---------------------------------------------
>
> Any guesses as to why h() doesn’t work there but c() does?
Some would say here: don’t do that!
;-)
Anyway: upon each iteration, h is a reference (à la "item i of {…}").
Syntactically, such a reference can’t validly appear in the context of a handler invocation.
This one works:
repeat with g in {a, b}
set h to contents of g
h()
end repeat
HTH,
Axel
_______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users
This email sent to email@hidden