> I don't believe those objects created at runtime via ... abc["xyz"] has any
> type associated with them
That's not true. If you set
abc["xyz"] = "foo"
then
abc["xyz"] is String
should be true, whereas if you set
abc["xyz"] = 3
then
abc["xyz"] is int
should be true. The values you store have definite types at runtime, although
at compile time the type of abc["xyz"] is considered to be *.
Gordon Smith
Adobe Flex SDK Team
From: [email protected] [mailto:[EMAIL PROTECTED] On Behalf Of Dave
Kong
Sent: Monday, December 01, 2008 10:42 AM
To: [email protected]
Subject: Re: [flexcoders] Looking for what this[iscalled]
If you define lung as a public field of the class Whale, then it is no longer a
"dynamic" property, it is declared with a strong type. I don't believe those
objects created at runtime via abc.xyz or abc["xyz"] has any type associated
with them, assuming xyz is not already declared as a field of abc.
On Sun, Nov 30, 2008 at 2:01 PM, gabriel montagné <[EMAIL
PROTECTED]<mailto:[EMAIL PROTECTED]>> wrote:
Hi.
On Sun, Nov 30, 2008 at 10:11 AM, Dave Kong <[EMAIL
PROTECTED]<mailto:davekong%40gmail.com>> wrote:
> Isn't "height" the "dynamic property" of another "dynamic property"
> this["something"] (which is equivalent to this.something)?
I wouldn't exactly say it like that. Dynamically accessing a property of an
object using the [] operator (as opposed to using the dot syntax) has some
special implications, the most important being type checking, both at
compile-time and at run-time.
If you have something like,
package
{
public class Whale
{
public var lung:Lung;
}
}
the compiler will rightfully choke if you tried to do something like
var humpback:Whale = new Whale();
humpback.lung = new Gill();
But it wouldn't be able to notice if you did it like this:
humpback["lung"] = new Gill();
or
humpback["leg"] = new HairyLeg();
There, you'd get your type coercion and property errors only until runtime.
It does have its rightful uses, of course, and you might want to check about
dynamic classes, etc. but you should be mindful about them.
gabriel.
--
gabriel montagné láscaris comneno
http://rojored.com
t/506.8367.6794