Handlers in a variable
Handlers in a variable
- Subject: Handlers in a variable
- From: "Mark J. Reed" <email@hidden>
- Date: Fri, 15 Jan 2016 22:19:42 -0500
I find it odd that this works:
to double(aNumber)
return aNumber * 2
end double
set someHandler to double
someHandler(4) --=> 8
But this doesn't:
to call(aHandler, aValue)
aHandler(aValue)
end
call(double, 4)
error "«script» doesn’t understand the “aHandler” message." number -1708 from «script»
What is different about the parameter of a handler compared to a local variable that explains this inconsistency?
I know that AS doesn't really do higher-order functions, and the way to fake it is with script objects, kind of like pre-closure Java. But I noticed that variables could hold handlers and thought maybe that had been rectified...
_______________________________________________
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