POSIX file becomes script?!

Try this:

script TheParent
end script

property parent : TheParent

set f to POSIX file "/Users"
return {f's class, f = me, f's parent}

I get

{script, true, «script TheParent»}

That is, f is the script itself, not a file! Note that if the parent property is removed, all is fine. Can someone explain this strange result?

Hi druido,

I think that’s exactly right. The root level script declared the script TheParent as the parent. me is the root level script and so its parent is the script object. Exactly as your result showed. it and me refers to different things.


Interesting. :slight_smile: TheParent’s parent is the main script and the main script’s parent is TheParent. You’ve set up some kind of grandfather paradox! :wink:

Yeah, that is interesting. The child is running things. I was thinking what would be a good use for this. Never seen it before.


1 good reason is to avoid AppleScript being the parent, other uses is for setting up inheritcance between objects in AppleScript which works. A third use with be to set up a collection, where the items in the collection can respond to and query the collection object.