• 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: functions as sort of first class objects
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: functions as sort of first class objects


  • Subject: Re: functions as sort of first class objects
  • From: Axel Luttgens <email@hidden>
  • Date: Tue, 24 May 2016 16:44:49 +0200

> Le 24 mai 2016 à 06:20, Mitchell L Model a écrit :
>
> I was experimenting today and got the following confusing results:
> ---------------------------------------------
> to a()
> 	display alert "A"
> end a
>
> to b()
> 	display alert "B"
> end b
>
> my a()	— works, of course
>
> set c to my b	— works!
> c()		— calls b!! (as I was hoping it would)
>
> repeat with h in {my a, my b}
> 	h()		— error :-(
> 	delay 1
> end repeat
> ---------------------------------------------
>
> Any guesses as to why h() doesn’t work there but c() does?

Some would say here: don’t do that!
;-)

Anyway: upon each iteration, h is a reference (à la "item i of {…}").
Syntactically, such a reference can’t validly appear in the context of a handler invocation.

This one works:

	repeat with g in {a, b}
		set h to contents of g
		h()
	end repeat

HTH,
Axel





 _______________________________________________
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


  • Follow-Ups:
    • Re: functions as sort of first class objects
      • From: Deivy Petrescu <email@hidden>
References: 
 >functions as sort of first class objects (From: Mitchell L Model <email@hidden>)

  • Prev by Date: Re: Library Use Statement Question
  • Next by Date: AppleScript syntax highlighting
  • Previous by thread: Re: functions as sort of first class objects
  • Next by thread: Re: functions as sort of first class objects
  • Index(es):
    • Date
    • Thread