• 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: First-class procedures in AS
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: First-class procedures in AS


  • Subject: Re: First-class procedures in AS
  • From: Emmanuel <email@hidden>
  • Date: Thu, 18 Dec 2003 09:45:43 +0100

At 9:42 PM -0500 17/12/03, Jim Witte wrote:
> Does Applescript allow you to compile procedures at runtime and treat them as first-class objects? I thought an interesting (if seemingly useless, except perhaps as a CS independent study) project would be to try to implement a subset of Scheme in AppleScript.. I'd probably have to skip "native" continuations as I'm sure they're not supported while running AS code, but if I broke AS code down into steps in an interpreter, I could implement them in that context. (Of course, I wouldn't *need* first-class functions, but they would be nice)

I am not sure what exactly you are trying to do, but Smile offers a favorable environment for that kind of thing. (Smile is really AppleScript's palace).

To be more specific, yet short: Smile maintains a persistent context, and handlers, variables and properties behave like elements of that context. You can say:

--------------------
get name of every handler of context
set handler "fred" of context to "beep 3"
--------------------

Same thing for Smile's "object scripts", the scripts that Smile lets you attach to objects.

Also, you can create a library and use it *on the fly in the same script*.

-------------------- tested
-- make new empty file
set ptd to ((path to desktop as string) & "fred.fred")
set r to open for access file ptd with write permission

-- write library
write "on fred()
display dialog \"hello fred\"
end" to r
close access r

-- load library
add library alias ptd

-- use library
fred()
--------------------

Such advanced scripting features of Smile are explained in documents which are being rewritten. Those documents are not public yet, just ask me if you are interested.

Emmanuel
_______________________________________________
applescript-users mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/applescript-users
Do not post admin requests to the list. They will be ignored.

  • Follow-Ups:
    • Re: First-class procedures in AS
      • From: Gary Lists <email@hidden>
References: 
 >First-class procedures in AS (From: Jim Witte <email@hidden>)

  • Prev by Date: Re: How to prevent Classic from starting?
  • Next by Date: Re: Filter reference form question
  • Previous by thread: Re: First-class procedures in AS
  • Next by thread: Re: First-class procedures in AS
  • Index(es):
    • Date
    • Thread