Re: script object properties: seeking confirmation
Re: script object properties: seeking confirmation
- Subject: Re: script object properties: seeking confirmation
- From: has <email@hidden>
- Date: Wed, 6 Mar 2002 15:20:43 +0000
Arthur J Knapp wrote:
>
> Bill Hoffman wrote:
>
>
>
>> I can't dynamically create a new property of an object at
>
>> runtime in this manner (like I could in JavaScript, for example, with
>
>> "this.income = 500;")
>
>
> Don't think so. I'm curious though why you'd want to avoid declaring your
>
> object's properties at compile time.
>
>
I am surprised at you, has. ;-)
Oh tsk, Arthur. You of all people should know that:
this.income != this["income"]
The underlying implementation may be similar (hash tables, etc), but how
they act is not. In the first, the property name is fixed at compile time,
even if the variable itself isn't initialised till later. In the second,
the name itself is only defined during runtime. i.e. The behaviour Bill
asked about was analogous to:
{name:"fred", age:27} & {income:500}
Nothing terribly dynamic in that. Of course, what he really wanted was to
do the same thing with script objects, rather than records. As in:
script myObject
property name: "fred"
property age: 27
property occupation: ""
on updateObj()
set occupation to "janitor"
property income : 500
end updateObj
end script
but as any fule kno, you cannot define properties within handlers.
Besides, I think there's a big difference between messing around with
hashes as a simple labelled-item data store, and messing around with the
layout of script objects which [imho] are more intended for encapulating
data with its respective methods as a matter of structural convenience.
Which is not to say I'd be *against* being able to create arbitrarily named
properties during runtime, but it'd be working at a much more fundamental
level to adding a new key-value pair to a hash - i.e. a whole different
kettle of fish. And I think by then you'd really be into talking about
being able to dynamically rewrite *any* code during runtime. (Which'd
certainly be more convenient than having to mess around with that damned
'run script'), but I don't really think that AppleScript is the proper
place for power of that magnitude.)
So c'mon there, lad. Nice try; but you're gonna have to get up *much*
earlier in the morning if you truly want to stymie me... ;)
has
_______________________________________________
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.