• 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: Creating list references in handlers. Bad code or bug?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: Creating list references in handlers. Bad code or bug?


  • Subject: RE: Creating list references in handlers. Bad code or bug?
  • From: "Bourque, Jason" <email@hidden>
  • Date: Wed, 3 Oct 2001 08:06:10 -0400

Chris,

Does this mean that

"That means you're working with a copy of
> the original data."
>
This repeated enough could cause memory leak and crash a script?

Thanks,

Jason Bourque
Senior Script Developer
Publishing Automation
MFS Investment Management
617-954-5312

> ----------
> From: Christopher Nebel
> Sent: Tuesday, October 2, 2001 9:27 PM
> To: Victor Yee
> Cc: Applescript Users
> Subject: Re: Creating list references in handlers. Bad code or bug?
>
> On Sunday, September 16, 2001, at 01:19 PM, Victor Yee wrote:
>
> > Hmmm, is this a bug?
> >
> > set x to {1, 2}
> > set end of x's contents to 3
> > x
> > --> {1, 2}
>
> It is, as we say, "working as designed." There are two problems here:
> one is that object specifiers for AppleScript internal objects (like
> lists) are fully evaluated at each sub-bit. The second problem is that
> "contents of x" doesn't give you x's actual live contents, it gives you
> the contents of each item [1]. That means you're working with a copy of
> the original data.
>
> Therefore, saying "set end of x's contents to 3" generates a new list,
> sets *its* end to 3 (which has no effect on x), and then completely
> forgets about it. Yes, this is bizarre, but it's expected.
>
>
> --Chris Nebel
> AppleScript Engineering
>
>
> [1] If that wasn't clear, consider this:
>
> set x to 3
> set y to {1, 2, a reference to x}
> {y, contents of y}
> --> {{1, 2, x of +script;}, {1, 2, 3}}
>
> "contents of" is effectively applied to each item of the list, but only
> one level deep, as this should demonstrate:
>
> set x to 3
> set y to {1, 2, a reference to x}
> set z to {3, 4, a reference to y}
> {z, contents of z}
> --> {{3, 4, y of +script;}, {3, 4, {1, 2, x of +script;}}}
> _______________________________________________
> applescript-users mailing list
> email@hidden
> http://www.lists.apple.com/mailman/listinfo/applescript-users


  • Follow-Ups:
    • Re: Creating list references in handlers. Bad code or bug?
      • From: Christopher Nebel <email@hidden>
  • Prev by Date: Scripting Palm Desktop
  • Next by Date: Re: Problem with writing a list
  • Previous by thread: Re: Creating list references in handlers. Bad code or bug?
  • Next by thread: Re: Creating list references in handlers. Bad code or bug?
  • Index(es):
    • Date
    • Thread