• 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: difference between property and variable
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: difference between property and variable


  • Subject: Re: difference between property and variable
  • From: Brennan <email@hidden>
  • Date: Tue, 11 Dec 2007 09:50:04 +0100

On 10/12/07 at 23:11, Mark J. Reed <email@hidden> wrote:

>  Apart from weird implementation-related performance differences, I
> consider the most important distinguishing feature of properties to be
> that they keep their values between executions (if the script is not
> recompiled in between, anyway).

Yes, mostly (see below) and when... has <email@hidden> wrote:

> > - A property's scope is limited to the script object in which it's
> > defined. e.g. If you define a property in your main script, that
> > property will cease to exist when the script finishes running

...he might have been [mis]understood to mean that the properties lose
their values between executions. I'm sure it's not what he meant, but I
just wanted to nitpick his otherwise thorough answer.

What hasn't been mentioned in much/any detail is the use of properties in
explicit script objects (rather than the implicit 'top level' script
object that every .scpt represents), so here's a snippet which just teases
out the difference between properties declared 'at the top' and those
declared inside explicit script objects:

(* OOP example *)

property brennan : missing value

set brennan to constructPerson("brown")
set heidi to constructPerson("red")

brennan's announcementAboutHairColor()
heidi's announcementAboutHairColor()

on constructPerson(hc)

 script person

  property hairColor : ""

  on announcementAboutHairColor()
   display dialog "My hair is " & hairColor
  end announcementAboutHairColor

 end script

 set person's hairColor to hc
 return person

end constructPerson
(* script ends*)

In this case 'brennan' (and his hairColor) will be remembered between
executions of the script (until it is recompiled) whereas heidi (and her
hairColor) will be forgotten because she's not declared as a property of
the .scpt EVEN THOUGH hairColor is declared as a property.

Just wanted to clarify that point.

The great universal truth: Scope ultimately renders all truths meaningless
and valueless.

(Don't tell my girlfriend I'm talking about her like that).

Brennan
 _______________________________________________
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

References: 
 >Re: difference between property and variable (From: "Mark J. Reed" <email@hidden>)

  • Prev by Date: Re: Application responses, Timeouts, Try statements, Activate - how do they really work?
  • Next by Date: Is AppleScript's OOP 'prototype-based' or 'class-based'?
  • Previous by thread: Re: difference between property and variable
  • Next by thread: Re: difference between property and variable
  • Index(es):
    • Date
    • Thread