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: Deivy Petrescu <email@hidden>
- Date: Tue, 24 May 2016 12:18:48 -0400
> On May 24, 2016, at 10:44 , Axel Luttgens <email@hidden> wrote:
>
> repeat with g in {a, b}
> set h to contents of g
> h()
> end repeat
Ha! This is really interesting.
The first thing I thought was exactly that, h is only a reference to an item in the list.
Thus, as I am used to do, I used the following:
repeat with h in whatever
set h to contents of h
do the rest
end repeat
It turns out that in this case this fails, so if you don’t do the loop with another variable it fails.
in other words,
to a()
display alert "A"
end a
to b()
display alert "B"
end b
repeat with h in {a, b}
set h to contents of h
h()
end repeat
—> error "«script» doesn’t understand the “h” message." number -1708 from «script»
but
to a()
display alert "A"
end a
to b()
display alert "B"
end b
repeat with h in {a, b}
set g to contents of h
g()
end repeat
Unless there is something I am not fundamentally understanding, this is a bug.
Deivy Petrescu
email@hidden
_______________________________________________
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