Re: POSIX and lists question
Re: POSIX and lists question
- Subject: Re: POSIX and lists question
- From: has <email@hidden>
- Date: Thu, 11 Aug 2005 17:46:16 +0100
Mark J. Reed wrote:
>on POSIXize(pathString)
>return POSIX file pathString
>end POSIXize
>
>set thePaths to map(theFiles, POSIXize)
>
> Or I could use the apply() function to modify the list in place:
>
>apply(theFiles, POSIXize)
>
> Yeah, I know, mixing metaphors with Perl and Lisp, but I don't know how to
>write a single handler that will honor changes made within the passed-in
>closure. There might be a way with references, but it's beyond my as-yet
>meager AppleScript skillz.
Unfortunately there isn't. Also note that AppleScript doesn't support closures, and passing around handler objects as you're doing is undocumented behaviour with known problems (passing a handler from one script object to another screws up its non-local variable bindings, causing all sorts of unpleasantness). The proper solution is to place the handler in a script object (with any related persistent state stored in properties of that script object) and pass that around instead. It's a bit more verbose, but documented and reliable.
>It'd also be nice if there were a syntax to
>create an anonymous closure on the fly so I wouldn't have to define a named
>handler like POSIXize . . .
Use Smalltalk, Ruby or some other language that provides such features if it troubles you. AppleScript's a pretty basic language and doesn't really rise to that level of sophistication.
HTH
has
--
http://freespace.virgin.net/hamish.sanderson/
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Applescript-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden