• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: POSIX and lists question
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: POSIX and lists question


  • Subject: Re: POSIX and lists question
  • From: "Mark J. Reed" <email@hidden>
  • Date: Thu, 11 Aug 2005 14:04:48 -0400

On 8/11/05, has <email@hidden> wrote:
Unfortunately there isn't. Also note that AppleScript doesn't support closures

Funny, 'cause Mr. Neuberg says it does in the book  ("AppleScript ... can generate closures", page 102, last pp), and they seem to work. :)

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).

Not sure what "undocumented" means in this context, since, again, it's in the book,which is where I learned that particular trick.  But it does neglect to mention any harmful side effects  What sort of screwups are we talking about?

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.

Sure, I can do that.  Always happy to use the preferred idiom when it does what I want.  Note that since the script object's properties can be initialized with local variables, that technique also effectively yields closures.

Use Smalltalk, Ruby or some other language that provides such features if it troubles you.

I do use many other languages for most of my daily work, including Ruby, Python, Perl, and _javascript_ - all of which have the ability to create anonymous closures.  I also write what is to some people a surprising amount of shellscript, which sadly doesn't support that capability.  But I still use it, because I don't choose a language based on what a CS prof would view as its "feature set"; I choose the most appropriate tool for the job at hand.  Or at least, the most appropriate out of the ones at my disposal.  And I try to learn many different languages to increase the likelihood that the most appropriate one overall for a given task is one of the ones at my disposal.  Some people learn Perl or Python, and thenceforth do not allow their doorway to be darkened by the likes of shell scripts, awk, and sed, but I am not one of those people.  

AppleScript's a pretty basic language and doesn't really rise to that level of sophistication.

Based on what I've seen so far, I think you're underestimating the sophistication of AppleScript.  I'm not really troubled by what it can't do (well, except remove an item from a list.  That genuinely irks me), but I do happen to enjoy pushing software to its limits.    Even if it means I occasionally run into those limits and break things, as was the case in my attempt at a pure-shell implementation of an object-oriented programming layer on top of ksh/bash.

I'm sorry if you feel that I'm using either AppleScript or this forum inappropriately.  You would prefer, perhaps, if I stuck to questions of more general pragmatic interest?

--
Mark J. Reed <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:

This email sent to email@hidden

  • Follow-Ups:
    • Re: POSIX and lists question
      • From: has <email@hidden>
  • Prev by Date: Encrypt PDF
  • Next by Date: Re: Test for existence of a variable?
  • Previous by thread: Re: POSIX and lists question
  • Next by thread: Re: POSIX and lists question
  • Index(es):
    • Date
    • Thread