Ideally a const inside a function allows you to
use an identifier for a constant value, which is
replaced back to the value by the compiler. So
you have the advantage of using an identifier,
eg. changes are concentrated in one place,
and the advantage of a const, which is the speed.

I'm not sure though, if the compiler really replaces
the value back.

Cheers

On Dec 20, 2007 4:55 PM, Paul Andrews <[EMAIL PROTECTED]> wrote:
>
>
>
>
>
>
> ----- Original Message -----
>  From: "reflexactions" <[EMAIL PROTECTED]>
>  To: <[email protected]>
>  Sent: Thursday, December 20, 2007 3:35 PM
>  Subject: [flexcoders] Re: const?
>
>  > So your telling me that when you write a function if you have a var
>  > that wont change its value for the duration of that function say like:
>  > override protected function updateDisplayList(...):void{
>  > var count:int=numChildren;
>  > ..loop code..
>  > ...finished
>  > }
>
>  I only use constants when the value at declaration time is fixed. I
> wouldn't
>  consider your example to be a constant because numChildren can potentially
>  change, whether it does or not. It would be misleading to the developer to
>  try and describe a value as const when it was based upon a changing value -
>  definitely bad practice.
>
>
>  > you consider that bad code as count should be declared as a const
>
>  No, though the variable may be pointless if numChildren doesn't change and
>  it may be poorly named if numChildren does.
>
>  Paul
>
>  snip
>
>  



-- 
Ralf Bokelberg <[EMAIL PROTECTED]>
Flex & Flash Consultant based in Cologne/Germany

Reply via email to