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]>wrote:

>   Hi.
>
>
> On Sun, Nov 30, 2008 at 10:11 AM, Dave Kong <[EMAIL 
> PROTECTED]<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
>  
>

Reply via email to